001/* 002 * Copyright (c) 2018-2021 REV Robotics 003 * 004 * Redistribution and use in source and binary forms, with or without 005 * modification, are permitted provided that the following conditions are met: 006 * 007 * 1. Redistributions of source code must retain the above copyright notice, 008 * this list of conditions and the following disclaimer. 009 * 2. Redistributions in binary form must reproduce the above copyright 010 * notice, this list of conditions and the following disclaimer in the 011 * documentation and/or other materials provided with the distribution. 012 * 3. Neither the name of REV Robotics nor the names of its 013 * contributors may be used to endorse or promote products derived from 014 * this software without specific prior written permission. 015 * 016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 026 * POSSIBILITY OF SUCH DAMAGE. 027 */ 028 029package com.revrobotics; 030 031/** @deprecated Use {@link SparkMaxPIDController} instead. */ 032@Deprecated(forRemoval = true) 033public interface CANPIDController { 034 /** @deprecated Use {@link SparkMaxPIDController.AccelStrategy} instead. */ 035 @Deprecated(forRemoval = true) 036 public enum AccelStrategy { 037 kTrapezoidal(0), 038 kSCurve(1); 039 040 @SuppressWarnings("MemberName") 041 public final int value; 042 043 AccelStrategy(int value) { 044 this.value = value; 045 } 046 047 public static AccelStrategy fromInt(int value) { 048 switch (value) { 049 case 0: 050 return kTrapezoidal; 051 case 1: 052 return kSCurve; 053 default: 054 return kTrapezoidal; 055 } 056 } 057 } 058 059 /** @deprecated Use {@link SparkMaxPIDController.ArbFFUnits} instead. */ 060 @Deprecated(forRemoval = true) 061 public enum ArbFFUnits { 062 kVoltage(0), 063 kPercentOut(1); 064 065 @SuppressWarnings("MemberName") 066 public final int value; 067 068 ArbFFUnits(int value) { 069 this.value = value; 070 } 071 } 072 073 /** 074 * Set the controller reference value based on the selected control mode. 075 * 076 * @param value The value to set depending on the control mode. For basic duty cycle control this 077 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 078 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 079 * (Amps). Native units can be changed using the setPositionConversionFactor() or 080 * setVelocityConversionFactor() methods of the CANEncoder class 081 * @param ctrl the control type 082 * @return {@link REVLibError#kOk} if successful 083 */ 084 public REVLibError setReference(double value, CANSparkMax.ControlType ctrl); 085 086 /** 087 * Set the controller reference value based on the selected control mode. 088 * 089 * @param value The value to set depending on the control mode. For basic duty cycle control this 090 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 091 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 092 * (Amps). Native units can be changed using the setPositionConversionFactor() or 093 * setVelocityConversionFactor() methods of the CANEncoder class 094 * @param ctrl the control type 095 * @return {@link REVLibError#kOk} if successful 096 * @deprecated Use {@link #setReference(double, CANSparkMax.ControlType)} instead. 097 */ 098 @SuppressWarnings("removal") 099 @Deprecated(forRemoval = true) 100 public REVLibError setReference(double value, ControlType ctrl); 101 102 /** 103 * Set the controller reference value based on the selected control mode. This will override the 104 * pre-programmed control mode but not change what is programmed to the controller. 105 * 106 * @param value The value to set depending on the control mode. For basic duty cycle control this 107 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 108 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 109 * (Amps). Native units can be changed using the setPositionConversionFactor() or 110 * setVelocityConversionFactor() methods of the CANEncoder class 111 * @param ctrl Is the control type to override with 112 * @param pidSlot for this command 113 * @return {@link REVLibError#kOk} if successful 114 */ 115 public REVLibError setReference(double value, CANSparkMax.ControlType ctrl, int pidSlot); 116 117 /** 118 * Set the controller reference value based on the selected control mode. This will override the 119 * pre-programmed control mode but not change what is programmed to the controller. 120 * 121 * @param value The value to set depending on the control mode. For basic duty cycle control this 122 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 123 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 124 * (Amps). Native units can be changed using the setPositionConversionFactor() or 125 * setVelocityConversionFactor() methods of the CANEncoder class 126 * @param ctrl Is the control type to override with 127 * @param pidSlot for this command 128 * @return {@link REVLibError#kOk} if successful 129 * @deprecated Use {@link #setReference(double, CANSparkMax.ControlType, int)} instead. 130 */ 131 @Deprecated(forRemoval = true) 132 @SuppressWarnings("removal") 133 public REVLibError setReference(double value, ControlType ctrl, int pidSlot); 134 135 /** 136 * Set the controller reference value based on the selected control mode. This will override the 137 * pre-programmed control mode but not change what is programmed to the controller. 138 * 139 * @param value The value to set depending on the control mode. For basic duty cycle control this 140 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 141 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 142 * (Amps). Native units can be changed using the setPositionConversionFactor() or 143 * setVelocityConversionFactor() methods of the CANEncoder class 144 * @param ctrl Is the control type to override with 145 * @param pidSlot for this command 146 * @param arbFeedforward A value from which is represented in voltage applied to the motor after 147 * the result of the specified control mode. The units for the parameter is Volts. This value 148 * is set after the control mode, but before any current limits or ramp rates. 149 * @return {@link REVLibError#kOk} if successful 150 */ 151 public REVLibError setReference( 152 double value, CANSparkMax.ControlType ctrl, int pidSlot, double arbFeedforward); 153 154 /** 155 * Set the controller reference value based on the selected control mode. This will override the 156 * pre-programmed control mode but not change what is programmed to the controller. 157 * 158 * @param value The value to set depending on the control mode. For basic duty cycle control this 159 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 160 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 161 * (Amps). Native units can be changed using the setPositionConversionFactor() or 162 * setVelocityConversionFactor() methods of the CANEncoder class 163 * @param ctrl Is the control type to override with 164 * @param pidSlot for this command 165 * @param arbFeedforward A value from which is represented in voltage applied to the motor after 166 * the result of the specified control mode. The units for the parameter is Volts. This value 167 * is set after the control mode, but before any current limits or ramp rates. 168 * @return {@link REVLibError#kOk} if successful 169 * @deprecated Use {@link #setReference(double, CANSparkMax.ControlType, int, double)} instead. 170 */ 171 @SuppressWarnings("removal") 172 @Deprecated(forRemoval = true) 173 public REVLibError setReference( 174 double value, ControlType ctrl, int pidSlot, double arbFeedforward); 175 176 /** 177 * Set the controller reference value based on the selected control mode. This will override the 178 * pre-programmed control mode but not change what is programmed to the controller. 179 * 180 * @param value The value to set depending on the control mode. For basic duty cycle control this 181 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 182 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 183 * (Amps). Native units can be changed using the setPositionConversionFactor() or 184 * setVelocityConversionFactor() methods of the CANEncoder class 185 * @param ctrl Is the control type to override with 186 * @param pidSlot for this command 187 * @param arbFeedforward A value from which is represented in voltage applied to the motor after 188 * the result of the specified control mode. The units for the parameter is Volts. This value 189 * is set after the control mode, but before any current limits or ramp rates. 190 * @param arbFFUnits The units the arbitrary feed forward term is in 191 * @return {@link REVLibError#kOk} if successful 192 */ 193 public REVLibError setReference( 194 double value, 195 CANSparkMax.ControlType ctrl, 196 int pidSlot, 197 double arbFeedforward, 198 SparkMaxPIDController.ArbFFUnits arbFFUnits); 199 200 /** 201 * Set the controller reference value based on the selected control mode. This will override the 202 * pre-programmed control mode but not change what is programmed to the controller. 203 * 204 * @param value The value to set depending on the control mode. For basic duty cycle control this 205 * should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity 206 * Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current 207 * (Amps). Native units can be changed using the setPositionConversionFactor() or 208 * setVelocityConversionFactor() methods of the CANEncoder class 209 * @param ctrl Is the control type to override with 210 * @param pidSlot for this command 211 * @param arbFeedforward A value from which is represented in voltage applied to the motor after 212 * the result of the specified control mode. The units for the parameter is Volts. This value 213 * is set after the control mode, but before any current limits or ramp rates. 214 * @param arbFFUnits The units the arbitrary feed forward term is in 215 * @return {@link REVLibError#kOk} if successful 216 * @deprecated Use {@link #setReference(double, CANSparkMax.ControlType, int, double, 217 * SparkMaxPIDController.ArbFFUnits)} instead. 218 */ 219 @SuppressWarnings("removal") 220 @Deprecated(forRemoval = true) 221 public REVLibError setReference( 222 double value, ControlType ctrl, int pidSlot, double arbFeedforward, ArbFFUnits arbFFUnits); 223 224 /** 225 * Set the Proportional Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 226 * Parameter API and should be used infrequently. The parameter does not presist unless 227 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 228 * GUI to tune and save parameters. 229 * 230 * @param gain The proportional gain value, must be positive 231 * @return {@link REVLibError#kOk} if successful 232 */ 233 public REVLibError setP(double gain); 234 235 /** 236 * Set the Proportional Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 237 * Parameter API and should be used infrequently. The parameter does not presist unless 238 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 239 * GUI to tune and save parameters. 240 * 241 * @param gain The proportional gain value, must be positive 242 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 243 * its own set of gain values and can be changed in each control frame using SetReference(). 244 * @return {@link REVLibError#kOk} if successful 245 */ 246 public REVLibError setP(double gain, int slotID); 247 248 /** 249 * Set the Integral Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 250 * Parameter API and should be used infrequently. The parameter does not presist unless 251 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 252 * GUI to tune and save parameters. 253 * 254 * @param gain The integral gain value, must be positive 255 * @return {@link REVLibError#kOk} if successful 256 */ 257 public REVLibError setI(double gain); 258 259 /** 260 * Set the Integral Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 261 * Parameter API and should be used infrequently. The parameter does not presist unless 262 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 263 * GUI to tune and save parameters. 264 * 265 * @param gain The integral gain value, must be positive 266 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 267 * its own set of gain values and can be changed in each control frame using SetReference(). 268 * @return {@link REVLibError#kOk} if successful 269 */ 270 public REVLibError setI(double gain, int slotID); 271 272 /** 273 * Set the Derivative Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 274 * Parameter API and should be used infrequently. The parameter does not presist unless 275 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 276 * GUI to tune and save parameters. 277 * 278 * @param gain The derivative gain value, must be positive 279 * @return {@link REVLibError#kOk} if successful 280 */ 281 public REVLibError setD(double gain); 282 283 /** 284 * Set the Derivative Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 285 * Parameter API and should be used infrequently. The parameter does not presist unless 286 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 287 * GUI to tune and save parameters. 288 * 289 * @param gain The derivative gain value, must be positive 290 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 291 * its own set of gain values and can be changed in each control frame using SetReference(). 292 * @return {@link REVLibError#kOk} if successful 293 */ 294 public REVLibError setD(double gain, int slotID); 295 296 /** 297 * Set the Derivative Filter constant of the PIDF controller on the SPARK MAX. This uses the Set 298 * Parameter API and should be used infrequently. The parameter does not presist unless 299 * burnFlash() is called. 300 * 301 * @param gain The derivative filter value, must be a positive number between 0 and 1 302 * @return {@link REVLibError#kOk} if successful 303 */ 304 public REVLibError setDFilter(double gain); 305 306 /** 307 * Set the Derivative Filter constant of the PIDF controller on the SPARK MAX. This uses the Set 308 * Parameter API and should be used infrequently. The parameter does not presist unless 309 * burnFlash() is called. 310 * 311 * @param gain The derivative filter value, must be a positive number between 0 and 1 312 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 313 * its own set of gain values and can be changed in each control frame using SetReference(). 314 * @return {@link REVLibError#kOk} if successful 315 */ 316 public REVLibError setDFilter(double gain, int slotID); 317 318 /** 319 * Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 320 * Parameter API and should be used infrequently. The parameter does not presist unless 321 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 322 * GUI to tune and save parameters. 323 * 324 * @param gain The feed-forward gain value 325 * @return {@link REVLibError#kOk} if successful 326 */ 327 public REVLibError setFF(double gain); 328 329 /** 330 * Set the Feed-froward Gain constant of the PIDF controller on the SPARK MAX. This uses the Set 331 * Parameter API and should be used infrequently. The parameter does not presist unless 332 * burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX 333 * GUI to tune and save parameters. 334 * 335 * @param gain The feed-forward gain value 336 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 337 * its own set of gain values and can be changed in each control frame using SetReference(). 338 * @return {@link REVLibError#kOk} if successful 339 */ 340 public REVLibError setFF(double gain, int slotID); 341 342 /** 343 * Set the IZone range of the PIDF controller on the SPARK MAX. This value specifies the range the 344 * |error| must be within for the integral constant to take effect. 345 * 346 * <p>This uses the Set Parameter API and should be used infrequently. The parameter does not 347 * presist unless burnFlash() is called. The recommended method to configure this parameter is to 348 * use the SPARK MAX GUI to tune and save parameters. 349 * 350 * @param IZone The IZone value, must be positive. Set to 0 to disable 351 * @return {@link REVLibError#kOk} if successful 352 */ 353 public REVLibError setIZone(double IZone); 354 355 /** 356 * Set the IZone range of the PIDF controller on the SPARK MAX. This value specifies the range the 357 * |error| must be within for the integral constant to take effect. 358 * 359 * <p>This uses the Set Parameter API and should be used infrequently. The parameter does not 360 * presist unless burnFlash() is called. The recommended method to configure this parameter is to 361 * use the SPARK MAX GUI to tune and save parameters. 362 * 363 * @param IZone The IZone value, must be positive. Set to 0 to disable 364 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 365 * its own set of gain values and can be changed in each control frame using SetReference(). 366 * @return {@link REVLibError#kOk} if successful 367 */ 368 public REVLibError setIZone(double IZone, int slotID); 369 370 /** 371 * Set the min amd max output for the closed loop mode. 372 * 373 * <p>This uses the Set Parameter API and should be used infrequently. The parameter does not 374 * presist unless burnFlash() is called. The recommended method to configure this parameter is to 375 * use the SPARK MAX GUI to tune and save parameters. 376 * 377 * @param min Reverse power minimum to allow the controller to output 378 * @param max Forward power maximum to allow the controller to output 379 * @return {@link REVLibError#kOk} if successful 380 */ 381 public REVLibError setOutputRange(double min, double max); 382 383 /** 384 * Set the min amd max output for the closed loop mode. 385 * 386 * <p>This uses the Set Parameter API and should be used infrequently. The parameter does not 387 * presist unless burnFlash() is called. The recommended method to configure this parameter is to 388 * use the SPARK MAX GUI to tune and save parameters. 389 * 390 * @param min Reverse power minimum to allow the controller to output 391 * @param max Forward power maximum to allow the controller to output 392 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 393 * its own set of gain values and can be changed in each control frame using SetReference(). 394 * @return {@link REVLibError#kOk} if successful 395 */ 396 public REVLibError setOutputRange(double min, double max, int slotID); 397 398 /** 399 * Get the Proportional Gain constant of the PIDF controller on the SPARK MAX. 400 * 401 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 402 * non-blocking call and will return a cached value if the parameter is not returned by the 403 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 404 * 405 * @return double P Gain value 406 */ 407 public double getP(); 408 409 /** 410 * Get the Proportional Gain constant of the PIDF controller on the SPARK MAX. 411 * 412 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 413 * non-blocking call and will return a cached value if the parameter is not returned by the 414 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 415 * 416 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 417 * its own set of gain values and can be changed in each control frame using SetReference(). 418 * @return double P Gain value 419 */ 420 public double getP(int slotID); 421 422 /** 423 * Get the Integral Gain constant of the PIDF controller on the SPARK MAX. 424 * 425 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 426 * non-blocking call and will return a cached value if the parameter is not returned by the 427 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 428 * 429 * @return double I Gain value 430 */ 431 public double getI(); 432 433 /** 434 * Get the Integral Gain constant of the PIDF controller on the SPARK MAX. 435 * 436 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 437 * non-blocking call and will return a cached value if the parameter is not returned by the 438 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 439 * 440 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 441 * its own set of gain values and can be changed in each control frame using SetReference(). 442 * @return double I Gain value 443 */ 444 public double getI(int slotID); 445 446 /** 447 * Get the Derivative Gain constant of the PIDF controller on the SPARK MAX. 448 * 449 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 450 * non-blocking call and will return a cached value if the parameter is not returned by the 451 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 452 * 453 * @return double D Gain value 454 */ 455 public double getD(); 456 457 /** 458 * Get the Derivative Gain constant of the PIDF controller on the SPARK MAX. 459 * 460 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 461 * non-blocking call and will return a cached value if the parameter is not returned by the 462 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 463 * 464 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 465 * its own set of gain values and can be changed in each control frame using SetReference(). 466 * @return double D Gain value 467 */ 468 public double getD(int slotID); 469 470 /** 471 * Get the Derivative Filter constant of the PIDF controller on the SPARK MAX. 472 * 473 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 474 * non-blocking call and will return a cached value if the parameter is not returned by the 475 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 476 * 477 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 478 * its own set of gain values and can be changed in each control frame using SetReference(). 479 * @return double D Filter value 480 */ 481 public double getDFilter(int slotID); 482 483 /** 484 * Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX. 485 * 486 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 487 * non-blocking call and will return a cached value if the parameter is not returned by the 488 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 489 * 490 * @return double F Gain value 491 */ 492 public double getFF(); 493 494 /** 495 * Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX. 496 * 497 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 498 * non-blocking call and will return a cached value if the parameter is not returned by the 499 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 500 * 501 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 502 * its own set of gain values and can be changed in each control frame using SetReference(). 503 * @return double F Gain value 504 */ 505 public double getFF(int slotID); 506 507 /** 508 * Get the IZone constant of the PIDF controller on the SPARK MAX. 509 * 510 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 511 * non-blocking call and will return a cached value if the parameter is not returned by the 512 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 513 * 514 * @return double IZone value 515 */ 516 public double getIZone(); 517 518 /** 519 * Get the IZone constant of the PIDF controller on the SPARK MAX. 520 * 521 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 522 * non-blocking call and will return a cached value if the parameter is not returned by the 523 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 524 * 525 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 526 * its own set of gain values and can be changed in each control frame using SetReference(). 527 * @return double IZone value 528 */ 529 public double getIZone(int slotID); 530 531 /** 532 * Get the derivative filter constant of the PIDF controller on the SPARK MAX. 533 * 534 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 535 * non-blocking call and will return a cached value if the parameter is not returned by the 536 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 537 * 538 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 539 * its own set of gain values and can be changed in each control frame using SetReference(). 540 * @return double D Filter 541 */ 542 // public double getDFilter(int slotID = 0); 543 544 /** 545 * Get the min output of the PIDF controller on the SPARK MAX. 546 * 547 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 548 * non-blocking call and will return a cached value if the parameter is not returned by the 549 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 550 * 551 * @return double min value 552 */ 553 public double getOutputMin(); 554 555 /** 556 * Get the min output of the PIDF controller on the SPARK MAX. 557 * 558 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 559 * non-blocking call and will return a cached value if the parameter is not returned by the 560 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 561 * 562 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 563 * its own set of gain values and can be changed in each control frame using SetReference(). 564 * @return double min value 565 */ 566 public double getOutputMin(int slotID); 567 568 /** 569 * Get the max output of the PIDF controller on the SPARK MAX. 570 * 571 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 572 * non-blocking call and will return a cached value if the parameter is not returned by the 573 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 574 * 575 * @return double max value 576 */ 577 public double getOutputMax(); 578 579 /** 580 * Get the max output of the PIDF controller on the SPARK MAX. 581 * 582 * <p>This uses the Get Parameter API and should be used infrequently. This function uses a 583 * non-blocking call and will return a cached value if the parameter is not returned by the 584 * timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds) 585 * 586 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 587 * its own set of gain values and can be changed in each control frame using SetReference(). 588 * @return double max value 589 */ 590 public double getOutputMax(int slotID); 591 592 /** 593 * Configure the maximum velocity of the SmartMotion mode. This is the velocity that is reached in 594 * the middle of the profile and is what the motor should spend most of its time at 595 * 596 * @param maxVel The maxmimum cruise velocity for the motion profile in RPM 597 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 598 * its own set of gain values and can be changed in each control frame using SetReference(). 599 * @return {@link REVLibError#kOk} if successful 600 */ 601 public REVLibError setSmartMotionMaxVelocity(double maxVel, int slotID); 602 603 /** 604 * Configure the maximum acceleration of the SmartMotion mode. This is the accleration that the 605 * motor velocity will increase at until the max velocity is reached 606 * 607 * @param maxAccel The maxmimum acceleration for the motion profile in RPM per second 608 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 609 * its own set of gain values and can be changed in each control frame using SetReference(). 610 * @return {@link REVLibError#kOk} if successful 611 */ 612 public REVLibError setSmartMotionMaxAccel(double maxAccel, int slotID); 613 614 /** 615 * Configure the mimimum velocity of the SmartMotion mode. Any requested velocities below this 616 * value will be set to 0. 617 * 618 * @param minVel The minimum velocity for the motion profile in RPM 619 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 620 * its own set of gain values and can be changed in each control frame using SetReference(). 621 * @return {@link REVLibError#kOk} if successful 622 */ 623 public REVLibError setSmartMotionMinOutputVelocity(double minVel, int slotID); 624 625 /** 626 * Configure the allowed closed loop error of SmartMotion mode. This value is how much deviation 627 * from your setpoint is tolerated and is useful in preventing oscillation around your setpoint. 628 * 629 * @param allowedErr The allowed deviation for your setpoint vs actual position in rotations 630 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 631 * its own set of gain values and can be changed in each control frame using SetReference(). 632 * @return {@link REVLibError#kOk} if successful 633 */ 634 public REVLibError setSmartMotionAllowedClosedLoopError(double allowedErr, int slotID); 635 636 /** 637 * NOTE: As of the 2022 FRC season, the firmware only supports the trapezoidal motion profiling 638 * acceleration strategy. 639 * 640 * <p>Configure the acceleration strategy used to control acceleration on the motor. 641 * 642 * @param accelStrategy The acceleration strategy to use for the automatically generated motion 643 * profile 644 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 645 * its own set of gain values and can be changed in each control frame using SetReference(). 646 * @return {@link REVLibError#kOk} if successful 647 */ 648 public REVLibError setSmartMotionAccelStrategy(AccelStrategy accelStrategy, int slotID); 649 650 /** 651 * Get the maximum velocity of the SmartMotion mode. This is the velocity that is reached in the 652 * middle of the profile and is what the motor should spend most of its time at 653 * 654 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 655 * its own set of gain values and can be changed in each control frame using SetReference(). 656 * @return The maxmimum cruise velocity for the motion profile in RPM 657 */ 658 public double getSmartMotionMaxVelocity(int slotID); 659 660 /** 661 * Get the maximum acceleration of the SmartMotion mode. This is the accleration that the motor 662 * velocity will increase at until the max velocity is reached 663 * 664 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 665 * its own set of gain values and can be changed in each control frame using SetReference(). 666 * @return The maxmimum acceleration for the motion profile in RPM per second 667 */ 668 public double getSmartMotionMaxAccel(int slotID); 669 670 /** 671 * Get the mimimum velocity of the SmartMotion mode. Any requested velocities below this value 672 * will be set to 0. 673 * 674 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 675 * its own set of gain values and can be changed in each control frame using SetReference(). 676 * @return The minimum velocity for the motion profile in RPM 677 */ 678 public double getSmartMotionMinOutputVelocity(int slotID); 679 680 /** 681 * Get the allowed closed loop error of SmartMotion mode. This value is how much deviation from 682 * your setpoint is tolerated and is useful in preventing oscillation around your setpoint. 683 * 684 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 685 * its own set of gain values and can be changed in each control frame using SetReference(). 686 * @return The allowed deviation for your setpoint vs actual position in rotations 687 */ 688 public double getSmartMotionAllowedClosedLoopError(int slotID); 689 690 /** 691 * Get the acceleration strategy used to control acceleration on the motor. As of the 2022 FRC 692 * season, the strategy is always trapezoidal motion profiling, regardless of what the device may 693 * report. 694 * 695 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 696 * its own set of gain values and can be changed in each control frame using SetReference(). 697 * @return The acceleration strategy to use for the automatically generated motion profile. 698 */ 699 public SparkMaxPIDController.AccelStrategy getSmartMotionAccelStrategy(int slotID); 700 701 /** 702 * Configure the maximum I accumulator of the PID controller. This value is used to constrain the 703 * I accumulator to help manage integral wind-up 704 * 705 * @param iMaxAccum The max value to contrain the I accumulator to 706 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 707 * its own set of gain values and can be changed in each control frame using SetReference(). 708 * @return {@link REVLibError#kOk} if successful 709 */ 710 public REVLibError setIMaxAccum(double iMaxAccum, int slotID); 711 712 /** 713 * Get the maximum I accumulator of the PID controller. This value is used to constrain the I 714 * accumulator to help manage integral wind-up 715 * 716 * @param slotID Is the gain schedule slot, the value is a number between 0 and 3. Each slot has 717 * its own set of gain values and can be changed in each control frame using SetReference(). 718 * @return The max value to contrain the I accumulator to 719 */ 720 public double getIMaxAccum(int slotID); 721 722 /** 723 * Set the I accumulator of the PID controller. This is useful when wishing to force a reset on 724 * the I accumulator of the PID controller. You can also preset values to see how it will respond 725 * to certain I characteristics 726 * 727 * <p>To use this function, the controller must be in a closed loop control mode by calling 728 * setReference() 729 * 730 * @param iAccum The value to set the I accumulator to 731 * @return {@link REVLibError#kOk} if successful 732 */ 733 public REVLibError setIAccum(double iAccum); 734 735 /** 736 * Get the I accumulator of the PID controller. This is useful when wishing to see what the I 737 * accumulator value is to help with PID tuning 738 * 739 * @return The value of the I accumulator 740 */ 741 public double getIAccum(); 742 743 /** 744 * Set the controller's feedback device 745 * 746 * <p>The default feedback device in brushless mode is assumed to be the integrated encoder and 747 * the default feedback device in brushed mode is assumed to be a quadrature encoder. This is used 748 * to changed to another feedback device for the controller, such as an analog sensor. 749 * 750 * <p>If there is a limited range on the feedback sensor that should be observed by the 751 * PIDController, it can be set by calling SetFeedbackSensorRange() on the sensor object. 752 * 753 * @param sensor The sensor to use as a feedback device 754 * @return {@link REVLibError#kOk} if successful 755 */ 756 public REVLibError setFeedbackDevice(final MotorFeedbackSensor sensor); 757 758 /** @deprecated Use {@link CANPIDController#setFeedbackDevice(MotorFeedbackSensor)} instead */ 759 @SuppressWarnings("removal") 760 @Deprecated(forRemoval = true) 761 public REVLibError setFeedbackDevice(final CANSensor sensor); 762}