001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenixpro.configs; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenixpro.hardware.DeviceIdentifier; 011import com.ctre.phoenix6.configs.jni.ConfigJNI; 012 013/** 014 * Class description for the Pigeon 2 IMU sensor that measures orientation. 015 * 016 * This handles the configurations for the {@link com.ctre.phoenixpro.hardware.Pigeon2} 017 * 018 * @deprecated Classes in the phoenixpro package will be removed in 2024. 019 * Users should instead use classes from the phoenix6 package. 020 */ 021@Deprecated(forRemoval = true) 022public class Pigeon2Configurator extends ParentConfigurator 023{ 024 public Pigeon2Configurator (DeviceIdentifier id) 025 { 026 super(id); 027 } 028 029 /** 030 * Refreshes the values of the specified config group. 031 * <p> 032 * This will wait up to {@link #defaultTimeoutSeconds}. 033 * <p> 034 * Call to refresh the selected configs from the device. 035 * 036 * @param configs The configs to refresh 037 * @return StatusCode of refreshing the configs 038 */ 039 public StatusCode refresh(Pigeon2Configuration configs) 040 { 041 return refresh(configs, defaultTimeoutSeconds); 042 } 043 044 /** 045 * Refreshes the values of the specified config group. 046 * <p> 047 * Call to refresh the selected configs from the device. 048 * 049 * @param configs The configs to refresh 050 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 051 * @return StatusCode of refreshing the configs 052 */ 053 public StatusCode refresh(Pigeon2Configuration configs, double timeoutSeconds) 054 { 055 StringBuilder serializedString = new StringBuilder(); 056 StatusCode err = getConfigsPrivate(serializedString, timeoutSeconds); 057 if (err == StatusCode.OK) { 058 /* Only deserialize if we successfully got configs */ 059 configs.deserialize(serializedString.toString()); 060 } 061 return err; 062 } 063 064 /** 065 * Applies the contents of the specified config to the device. 066 * <p> 067 * This will wait up to {@link #defaultTimeoutSeconds}. 068 * <p> 069 * Call to apply the selected configs. 070 * 071 * @param configs Configs to apply against. 072 * @return StatusCode of the set command 073 */ 074 public StatusCode apply(Pigeon2Configuration configs) 075 { 076 return apply(configs, defaultTimeoutSeconds); 077 } 078 079 /** 080 * Applies the contents of the specified config to the device. 081 * <p> 082 * Call to apply the selected configs. 083 * 084 * @param configs Configs to apply against. 085 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 086 * @return StatusCode of the set command 087 */ 088 public StatusCode apply(Pigeon2Configuration configs, double timeoutSeconds) 089 { 090 return setConfigsPrivate(configs.serialize(), timeoutSeconds, configs.FutureProofConfigs, false); 091 } 092 093 094 /** 095 * Refreshes the values of the specified config group. 096 * <p> 097 * This will wait up to {@link #defaultTimeoutSeconds}. 098 * <p> 099 * Call to refresh the selected configs from the device. 100 * 101 * @param configs The configs to refresh 102 * @return StatusCode of refreshing the configs 103 */ 104 public StatusCode refresh(MountPoseConfigs configs) 105 { 106 return refresh(configs, defaultTimeoutSeconds); 107 } 108 109 /** 110 * Refreshes the values of the specified config group. 111 * <p> 112 * Call to refresh the selected configs from the device. 113 * 114 * @param configs The configs to refresh 115 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 116 * @return StatusCode of refreshing the configs 117 */ 118 public StatusCode refresh(MountPoseConfigs configs, double timeoutSeconds) 119 { 120 StringBuilder serializedString = new StringBuilder(); 121 StatusCode err = getConfigsPrivate(serializedString, timeoutSeconds); 122 if (err == StatusCode.OK) { 123 /* Only deserialize if we successfully got configs */ 124 configs.deserialize(serializedString.toString()); 125 } 126 return err; 127 } 128 129 /** 130 * Applies the contents of the specified config to the device. 131 * <p> 132 * This will wait up to {@link #defaultTimeoutSeconds}. 133 * <p> 134 * Call to apply the selected configs. 135 * 136 * @param configs Configs to apply against. 137 * @return StatusCode of the set command 138 */ 139 public StatusCode apply(MountPoseConfigs configs) 140 { 141 return apply(configs, defaultTimeoutSeconds); 142 } 143 144 /** 145 * Applies the contents of the specified config to the device. 146 * <p> 147 * Call to apply the selected configs. 148 * 149 * @param configs Configs to apply against. 150 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 151 * @return StatusCode of the set command 152 */ 153 public StatusCode apply(MountPoseConfigs configs, double timeoutSeconds) 154 { 155 return setConfigsPrivate(configs.serialize(), timeoutSeconds, false, false); 156 } 157 158 159 /** 160 * Refreshes the values of the specified config group. 161 * <p> 162 * This will wait up to {@link #defaultTimeoutSeconds}. 163 * <p> 164 * Call to refresh the selected configs from the device. 165 * 166 * @param configs The configs to refresh 167 * @return StatusCode of refreshing the configs 168 */ 169 public StatusCode refresh(GyroTrimConfigs configs) 170 { 171 return refresh(configs, defaultTimeoutSeconds); 172 } 173 174 /** 175 * Refreshes the values of the specified config group. 176 * <p> 177 * Call to refresh the selected configs from the device. 178 * 179 * @param configs The configs to refresh 180 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 181 * @return StatusCode of refreshing the configs 182 */ 183 public StatusCode refresh(GyroTrimConfigs configs, double timeoutSeconds) 184 { 185 StringBuilder serializedString = new StringBuilder(); 186 StatusCode err = getConfigsPrivate(serializedString, timeoutSeconds); 187 if (err == StatusCode.OK) { 188 /* Only deserialize if we successfully got configs */ 189 configs.deserialize(serializedString.toString()); 190 } 191 return err; 192 } 193 194 /** 195 * Applies the contents of the specified config to the device. 196 * <p> 197 * This will wait up to {@link #defaultTimeoutSeconds}. 198 * <p> 199 * Call to apply the selected configs. 200 * 201 * @param configs Configs to apply against. 202 * @return StatusCode of the set command 203 */ 204 public StatusCode apply(GyroTrimConfigs configs) 205 { 206 return apply(configs, defaultTimeoutSeconds); 207 } 208 209 /** 210 * Applies the contents of the specified config to the device. 211 * <p> 212 * Call to apply the selected configs. 213 * 214 * @param configs Configs to apply against. 215 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 216 * @return StatusCode of the set command 217 */ 218 public StatusCode apply(GyroTrimConfigs configs, double timeoutSeconds) 219 { 220 return setConfigsPrivate(configs.serialize(), timeoutSeconds, false, false); 221 } 222 223 224 /** 225 * Refreshes the values of the specified config group. 226 * <p> 227 * This will wait up to {@link #defaultTimeoutSeconds}. 228 * <p> 229 * Call to refresh the selected configs from the device. 230 * 231 * @param configs The configs to refresh 232 * @return StatusCode of refreshing the configs 233 */ 234 public StatusCode refresh(Pigeon2FeaturesConfigs configs) 235 { 236 return refresh(configs, defaultTimeoutSeconds); 237 } 238 239 /** 240 * Refreshes the values of the specified config group. 241 * <p> 242 * Call to refresh the selected configs from the device. 243 * 244 * @param configs The configs to refresh 245 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 246 * @return StatusCode of refreshing the configs 247 */ 248 public StatusCode refresh(Pigeon2FeaturesConfigs configs, double timeoutSeconds) 249 { 250 StringBuilder serializedString = new StringBuilder(); 251 StatusCode err = getConfigsPrivate(serializedString, timeoutSeconds); 252 if (err == StatusCode.OK) { 253 /* Only deserialize if we successfully got configs */ 254 configs.deserialize(serializedString.toString()); 255 } 256 return err; 257 } 258 259 /** 260 * Applies the contents of the specified config to the device. 261 * <p> 262 * This will wait up to {@link #defaultTimeoutSeconds}. 263 * <p> 264 * Call to apply the selected configs. 265 * 266 * @param configs Configs to apply against. 267 * @return StatusCode of the set command 268 */ 269 public StatusCode apply(Pigeon2FeaturesConfigs configs) 270 { 271 return apply(configs, defaultTimeoutSeconds); 272 } 273 274 /** 275 * Applies the contents of the specified config to the device. 276 * <p> 277 * Call to apply the selected configs. 278 * 279 * @param configs Configs to apply against. 280 * @param timeoutSeconds Maximum amount of time to wait when performing configuration 281 * @return StatusCode of the set command 282 */ 283 public StatusCode apply(Pigeon2FeaturesConfigs configs, double timeoutSeconds) 284 { 285 return setConfigsPrivate(configs.serialize(), timeoutSeconds, false, false); 286 } 287 288 289 /** 290 * The yaw to set the Pigeon2 to right now. 291 * <p> 292 * This will wait up to {@link #defaultTimeoutSeconds}. 293 * <p> 294 * This is available in the configurator in case the user wants 295 * to initialize their device entirely without passing a device 296 * reference down to the code that performs the initialization. 297 * In this case, the user passes down the configurator object 298 * and performs all the initialization code on the object. 299 * 300 * @param newValue Value to set to. 301 * @return StatusCode of the set command 302 */ 303 public StatusCode setYaw(double newValue) { 304 return setYaw(newValue, defaultTimeoutSeconds); 305 } 306 /** 307 * The yaw to set the Pigeon2 to right now. 308 * <p> 309 * This is available in the configurator in case the user wants 310 * to initialize their device entirely without passing a device 311 * reference down to the code that performs the initialization. 312 * In this case, the user passes down the configurator object 313 * and performs all the initialization code on the object. 314 * 315 * @param newValue Value to set to. 316 * @param timeoutSeconds Maximum time to wait up to in seconds. 317 * @return StatusCode of the set command 318 */ 319 public StatusCode setYaw(double newValue, double timeoutSeconds) { 320 String serialized = ConfigJNI.Serializedouble(1012, newValue); 321 return setConfigsPrivate(serialized, timeoutSeconds, false, true); 322 } 323 324 /** 325 * Clear the sticky faults in the device. 326 * <p> 327 * This typically has no impact on the device functionality. Instead, 328 * it just clears telemetry faults that are accessible via API and 329 * Tuner Self-Test. 330 * <p> 331 * This will wait up to {@link #defaultTimeoutSeconds}. 332 * <p> 333 * This is available in the configurator in case the user wants 334 * to initialize their device entirely without passing a device 335 * reference down to the code that performs the initialization. 336 * In this case, the user passes down the configurator object 337 * and performs all the initialization code on the object. 338 * @return StatusCode of the set command 339 */ 340 public StatusCode clearStickyFaults() { 341 return clearStickyFaults(defaultTimeoutSeconds); 342 } 343 /** 344 * Clear the sticky faults in the device. 345 * <p> 346 * This typically has no impact on the device functionality. Instead, 347 * it just clears telemetry faults that are accessible via API and 348 * Tuner Self-Test. 349 * <p> 350 * This is available in the configurator in case the user wants 351 * to initialize their device entirely without passing a device 352 * reference down to the code that performs the initialization. 353 * In this case, the user passes down the configurator object 354 * and performs all the initialization code on the object. 355 * @param timeoutSeconds Maximum time to wait up to in seconds. 356 * @return StatusCode of the set command 357 */ 358 public StatusCode clearStickyFaults(double timeoutSeconds) { 359 String serialized = ConfigJNI.Serializedouble(1476, 0); 360 return setConfigsPrivate(serialized, timeoutSeconds, false, true); 361 } 362}