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.phoenix6.hardware.traits; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenix6.controls.*; 011import com.ctre.phoenix6.controls.compound.*; 012 013/** 014 * Requires Phoenix Pro; Contains all FOC-exclusive control functions available 015 * for devices that support FOC. 016 */ 017public interface SupportsFOC extends CommonDevice 018{ 019 020 021 /** 022 * Request a specified motor current (field oriented control). 023 * <p> 024 * This control request will drive the motor to the requested motor 025 * (stator) current value. This leverages field oriented control 026 * (FOC), which means greater peak power than what is documented. 027 * This scales to torque based on Motor's kT constant. 028 * <ul> 029 * <li> <b>TorqueCurrentFOC Parameters:</b> 030 * <ul> 031 * <li> <b>Output:</b> Amount of motor current in Amperes 032 * <li> <b>MaxAbsDutyCycle:</b> The maximum absolute motor output that can 033 * be applied, which effectively limits the 034 * velocity. For example, 0.50 means no more 035 * than 50% output in either direction. This 036 * is useful for preventing the motor from 037 * spinning to its terminal velocity when there 038 * is no external torque applied unto the 039 * rotor. Note this is absolute maximum, so 040 * the value should be between zero and one. 041 * <li> <b>Deadband:</b> Deadband in Amperes. If torque request is within 042 * deadband, the bridge output is neutral. If deadband 043 * is set to zero then there is effectively no 044 * deadband. Note if deadband is zero, a free spinning 045 * motor will spin for quite a while as the firmware 046 * attempts to hold the motor's bemf. If user expects 047 * motor to cease spinning quickly with a demand of 048 * zero, we recommend a deadband of one Ampere. This 049 * value will be converted to an integral value of 050 * amps. 051 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 052 * output is zero (or within deadband). 053 * Set to false to use the NeutralMode 054 * configuration setting (default). 055 * This flag exists to provide the 056 * fundamental behavior of this control 057 * when output is zero, which is to 058 * provide 0A (zero torque). 059 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 060 * This allows users to use other limit 061 * switch sensors connected to robot 062 * controller. This also allows use of 063 * active sensors that require external 064 * power. 065 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 066 * This allows users to use other limit 067 * switch sensors connected to robot 068 * controller. This also allows use of 069 * active sensors that require external 070 * power. 071 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 072 * switches and the LimitForwardMotion and 073 * LimitReverseMotion parameters, instead 074 * allowing motion. 075 * <p> 076 * This can be useful on mechanisms such 077 * as an intake/feeder, where a limit 078 * switch stops motion while intaking but 079 * should be ignored when feeding to a 080 * shooter. 081 * <p> 082 * The hardware limit faults and 083 * Forward/ReverseLimit signals will still 084 * report the values of the limit switches 085 * regardless of this parameter. 086 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 087 * instead allowing motion. 088 * <p> 089 * This can be useful when calibrating the 090 * zero point of a mechanism such as an 091 * elevator. 092 * <p> 093 * The software limit faults will still 094 * report the values of the software 095 * limits regardless of this parameter. 096 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 097 * request until a timesync boundary (requires 098 * Phoenix Pro and CANivore). This eliminates the 099 * impact of nondeterministic network delays in 100 * exchange for a larger but deterministic control 101 * latency. 102 * <p> 103 * This requires setting the ControlTimesyncFreqHz 104 * config in MotorOutputConfigs. Additionally, when 105 * this is enabled, the UpdateFreqHz of this 106 * request should be set to 0 Hz. 107 * </ul> 108 * </ul> 109 * 110 * @param request Control object to request of the device 111 * @return Code response of the request 112 */ 113 StatusCode setControl(TorqueCurrentFOC request); 114 115 /** 116 * Request PID to target position with torque current feedforward. 117 * <p> 118 * This control mode will set the motor's position setpoint to the 119 * position specified by the user. In addition, it will apply an 120 * additional torque current as an arbitrary feedforward value. 121 * <ul> 122 * <li> <b>PositionTorqueCurrentFOC Parameters:</b> 123 * <ul> 124 * <li> <b>Position:</b> Position to drive toward in rotations. 125 * <li> <b>Velocity:</b> Velocity to drive toward in rotations per second. 126 * This is typically used for motion profiles 127 * generated by the robot program. 128 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 129 * Amperes. This is added to the output of the 130 * onboard feedforward terms. 131 * <p> 132 * User can use motor's kT to scale Newton-meter to 133 * Amperes. 134 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 135 * Use the configuration api to set the gain values for 136 * the selected slot before enabling this feature. Slot 137 * must be within [0,2]. 138 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 139 * output is zero (or within deadband). 140 * Set to false to use the NeutralMode 141 * configuration setting (default). 142 * This flag exists to provide the 143 * fundamental behavior of this control 144 * when output is zero, which is to 145 * provide 0A (zero torque). 146 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 147 * This allows users to use other limit 148 * switch sensors connected to robot 149 * controller. This also allows use of 150 * active sensors that require external 151 * power. 152 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 153 * This allows users to use other limit 154 * switch sensors connected to robot 155 * controller. This also allows use of 156 * active sensors that require external 157 * power. 158 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 159 * switches and the LimitForwardMotion and 160 * LimitReverseMotion parameters, instead 161 * allowing motion. 162 * <p> 163 * This can be useful on mechanisms such 164 * as an intake/feeder, where a limit 165 * switch stops motion while intaking but 166 * should be ignored when feeding to a 167 * shooter. 168 * <p> 169 * The hardware limit faults and 170 * Forward/ReverseLimit signals will still 171 * report the values of the limit switches 172 * regardless of this parameter. 173 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 174 * instead allowing motion. 175 * <p> 176 * This can be useful when calibrating the 177 * zero point of a mechanism such as an 178 * elevator. 179 * <p> 180 * The software limit faults will still 181 * report the values of the software 182 * limits regardless of this parameter. 183 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 184 * request until a timesync boundary (requires 185 * Phoenix Pro and CANivore). This eliminates the 186 * impact of nondeterministic network delays in 187 * exchange for a larger but deterministic control 188 * latency. 189 * <p> 190 * This requires setting the ControlTimesyncFreqHz 191 * config in MotorOutputConfigs. Additionally, when 192 * this is enabled, the UpdateFreqHz of this 193 * request should be set to 0 Hz. 194 * </ul> 195 * </ul> 196 * 197 * @param request Control object to request of the device 198 * @return Code response of the request 199 */ 200 StatusCode setControl(PositionTorqueCurrentFOC request); 201 202 /** 203 * Request PID to target velocity with torque current feedforward. 204 * <p> 205 * This control mode will set the motor's velocity setpoint to the 206 * velocity specified by the user. In addition, it will apply an 207 * additional torque current as an arbitrary feedforward value. 208 * <ul> 209 * <li> <b>VelocityTorqueCurrentFOC Parameters:</b> 210 * <ul> 211 * <li> <b>Velocity:</b> Velocity to drive toward in rotations per second. 212 * <li> <b>Acceleration:</b> Acceleration to drive toward in rotations per 213 * second squared. This is typically used for 214 * motion profiles generated by the robot program. 215 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 216 * Amperes. This is added to the output of the 217 * onboard feedforward terms. 218 * <p> 219 * User can use motor's kT to scale Newton-meter to 220 * Amperes. 221 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 222 * Use the configuration api to set the gain values for 223 * the selected slot before enabling this feature. Slot 224 * must be within [0,2]. 225 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 226 * output is zero (or within deadband). 227 * Set to false to use the NeutralMode 228 * configuration setting (default). 229 * This flag exists to provide the 230 * fundamental behavior of this control 231 * when output is zero, which is to 232 * provide 0A (zero torque). 233 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 234 * This allows users to use other limit 235 * switch sensors connected to robot 236 * controller. This also allows use of 237 * active sensors that require external 238 * power. 239 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 240 * This allows users to use other limit 241 * switch sensors connected to robot 242 * controller. This also allows use of 243 * active sensors that require external 244 * power. 245 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 246 * switches and the LimitForwardMotion and 247 * LimitReverseMotion parameters, instead 248 * allowing motion. 249 * <p> 250 * This can be useful on mechanisms such 251 * as an intake/feeder, where a limit 252 * switch stops motion while intaking but 253 * should be ignored when feeding to a 254 * shooter. 255 * <p> 256 * The hardware limit faults and 257 * Forward/ReverseLimit signals will still 258 * report the values of the limit switches 259 * regardless of this parameter. 260 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 261 * instead allowing motion. 262 * <p> 263 * This can be useful when calibrating the 264 * zero point of a mechanism such as an 265 * elevator. 266 * <p> 267 * The software limit faults will still 268 * report the values of the software 269 * limits regardless of this parameter. 270 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 271 * request until a timesync boundary (requires 272 * Phoenix Pro and CANivore). This eliminates the 273 * impact of nondeterministic network delays in 274 * exchange for a larger but deterministic control 275 * latency. 276 * <p> 277 * This requires setting the ControlTimesyncFreqHz 278 * config in MotorOutputConfigs. Additionally, when 279 * this is enabled, the UpdateFreqHz of this 280 * request should be set to 0 Hz. 281 * </ul> 282 * </ul> 283 * 284 * @param request Control object to request of the device 285 * @return Code response of the request 286 */ 287 StatusCode setControl(VelocityTorqueCurrentFOC request); 288 289 /** 290 * Requests Motion Magic® to target a final position using a motion 291 * profile. Users can optionally provide a torque current 292 * feedforward. 293 * <p> 294 * Motion Magic® produces a motion profile in real-time while 295 * attempting to honor the Cruise Velocity, Acceleration, and 296 * (optional) Jerk specified via the Motion Magic® configuration 297 * values. This control mode does not use the Expo_kV or Expo_kA 298 * configs. 299 * <p> 300 * Target position can be changed on-the-fly and Motion Magic® will do 301 * its best to adjust the profile. This control mode is based on 302 * torque current, so relevant closed-loop gains will use Amperes for 303 * the numerator. 304 * <ul> 305 * <li> <b>MotionMagicTorqueCurrentFOC Parameters:</b> 306 * <ul> 307 * <li> <b>Position:</b> Position to drive toward in rotations. 308 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 309 * Amperes. This is added to the output of the 310 * onboard feedforward terms. 311 * <p> 312 * User can use motor's kT to scale Newton-meter to 313 * Amperes. 314 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 315 * Use the configuration api to set the gain values for 316 * the selected slot before enabling this feature. Slot 317 * must be within [0,2]. 318 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 319 * output is zero (or within deadband). 320 * Set to false to use the NeutralMode 321 * configuration setting (default). 322 * This flag exists to provide the 323 * fundamental behavior of this control 324 * when output is zero, which is to 325 * provide 0A (zero torque). 326 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 327 * This allows users to use other limit 328 * switch sensors connected to robot 329 * controller. This also allows use of 330 * active sensors that require external 331 * power. 332 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 333 * This allows users to use other limit 334 * switch sensors connected to robot 335 * controller. This also allows use of 336 * active sensors that require external 337 * power. 338 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 339 * switches and the LimitForwardMotion and 340 * LimitReverseMotion parameters, instead 341 * allowing motion. 342 * <p> 343 * This can be useful on mechanisms such 344 * as an intake/feeder, where a limit 345 * switch stops motion while intaking but 346 * should be ignored when feeding to a 347 * shooter. 348 * <p> 349 * The hardware limit faults and 350 * Forward/ReverseLimit signals will still 351 * report the values of the limit switches 352 * regardless of this parameter. 353 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 354 * instead allowing motion. 355 * <p> 356 * This can be useful when calibrating the 357 * zero point of a mechanism such as an 358 * elevator. 359 * <p> 360 * The software limit faults will still 361 * report the values of the software 362 * limits regardless of this parameter. 363 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 364 * request until a timesync boundary (requires 365 * Phoenix Pro and CANivore). This eliminates the 366 * impact of nondeterministic network delays in 367 * exchange for a larger but deterministic control 368 * latency. 369 * <p> 370 * This requires setting the ControlTimesyncFreqHz 371 * config in MotorOutputConfigs. Additionally, when 372 * this is enabled, the UpdateFreqHz of this 373 * request should be set to 0 Hz. 374 * </ul> 375 * </ul> 376 * 377 * @param request Control object to request of the device 378 * @return Code response of the request 379 */ 380 StatusCode setControl(MotionMagicTorqueCurrentFOC request); 381 382 /** 383 * Requests Motion Magic® to target a final velocity using a motion 384 * profile. This allows smooth transitions between velocity set 385 * points. Users can optionally provide a torque feedforward. 386 * <p> 387 * Motion Magic® Velocity produces a motion profile in real-time while 388 * attempting to honor the specified Acceleration and (optional) Jerk. 389 * This control mode does not use the CruiseVelocity, Expo_kV, or 390 * Expo_kA configs. 391 * <p> 392 * If the specified acceleration is zero, the Acceleration under 393 * Motion Magic® configuration parameter is used instead. This allows 394 * for runtime adjustment of acceleration for advanced users. Jerk is 395 * also specified in the Motion Magic® persistent configuration 396 * values. If Jerk is set to zero, Motion Magic® will produce a 397 * trapezoidal acceleration profile. 398 * <p> 399 * Target velocity can also be changed on-the-fly and Motion Magic® 400 * will do its best to adjust the profile. This control mode is based 401 * on torque current, so relevant closed-loop gains will use Amperes 402 * for the numerator. 403 * <ul> 404 * <li> <b>MotionMagicVelocityTorqueCurrentFOC Parameters:</b> 405 * <ul> 406 * <li> <b>Velocity:</b> Target velocity to drive toward in rotations per 407 * second. This can be changed on-the fly. 408 * <li> <b>Acceleration:</b> This is the absolute Acceleration to use 409 * generating the profile. If this parameter is 410 * zero, the Acceleration persistent configuration 411 * parameter is used instead. Acceleration is in 412 * rotations per second squared. If nonzero, the 413 * signage does not matter as the absolute value 414 * is used. 415 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 416 * Amperes. This is added to the output of the 417 * onboard feedforward terms. 418 * <p> 419 * User can use motor's kT to scale Newton-meter to 420 * Amperes. 421 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 422 * Use the configuration api to set the gain values for 423 * the selected slot before enabling this feature. Slot 424 * must be within [0,2]. 425 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 426 * output is zero (or within deadband). 427 * Set to false to use the NeutralMode 428 * configuration setting (default). 429 * This flag exists to provide the 430 * fundamental behavior of this control 431 * when output is zero, which is to 432 * provide 0A (zero torque). 433 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 434 * This allows users to use other limit 435 * switch sensors connected to robot 436 * controller. This also allows use of 437 * active sensors that require external 438 * power. 439 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 440 * This allows users to use other limit 441 * switch sensors connected to robot 442 * controller. This also allows use of 443 * active sensors that require external 444 * power. 445 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 446 * switches and the LimitForwardMotion and 447 * LimitReverseMotion parameters, instead 448 * allowing motion. 449 * <p> 450 * This can be useful on mechanisms such 451 * as an intake/feeder, where a limit 452 * switch stops motion while intaking but 453 * should be ignored when feeding to a 454 * shooter. 455 * <p> 456 * The hardware limit faults and 457 * Forward/ReverseLimit signals will still 458 * report the values of the limit switches 459 * regardless of this parameter. 460 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 461 * instead allowing motion. 462 * <p> 463 * This can be useful when calibrating the 464 * zero point of a mechanism such as an 465 * elevator. 466 * <p> 467 * The software limit faults will still 468 * report the values of the software 469 * limits regardless of this parameter. 470 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 471 * request until a timesync boundary (requires 472 * Phoenix Pro and CANivore). This eliminates the 473 * impact of nondeterministic network delays in 474 * exchange for a larger but deterministic control 475 * latency. 476 * <p> 477 * This requires setting the ControlTimesyncFreqHz 478 * config in MotorOutputConfigs. Additionally, when 479 * this is enabled, the UpdateFreqHz of this 480 * request should be set to 0 Hz. 481 * </ul> 482 * </ul> 483 * 484 * @param request Control object to request of the device 485 * @return Code response of the request 486 */ 487 StatusCode setControl(MotionMagicVelocityTorqueCurrentFOC request); 488 489 /** 490 * Requests Motion Magic® to target a final position using an 491 * exponential motion profile. Users can optionally provide a torque 492 * current feedforward. 493 * <p> 494 * Motion Magic® Expo produces a motion profile in real-time while 495 * attempting to honor the Cruise Velocity (optional) and the 496 * mechanism kV and kA, specified via the Motion Magic® configuration 497 * values. Note that unlike the slot gains, the Expo_kV and Expo_kA 498 * configs are always in output units of Volts. 499 * <p> 500 * Setting Cruise Velocity to 0 will allow the profile to run to the 501 * max possible velocity based on Expo_kV. This control mode does not 502 * use the Acceleration or Jerk configs. 503 * <p> 504 * Target position can be changed on-the-fly and Motion Magic® will do 505 * its best to adjust the profile. This control mode is based on 506 * torque current, so relevant closed-loop gains will use Amperes for 507 * the numerator. 508 * <ul> 509 * <li> <b>MotionMagicExpoTorqueCurrentFOC Parameters:</b> 510 * <ul> 511 * <li> <b>Position:</b> Position to drive toward in rotations. 512 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 513 * Amperes. This is added to the output of the 514 * onboard feedforward terms. 515 * <p> 516 * User can use motor's kT to scale Newton-meter to 517 * Amperes. 518 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 519 * Use the configuration api to set the gain values for 520 * the selected slot before enabling this feature. Slot 521 * must be within [0,2]. 522 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 523 * output is zero (or within deadband). 524 * Set to false to use the NeutralMode 525 * configuration setting (default). 526 * This flag exists to provide the 527 * fundamental behavior of this control 528 * when output is zero, which is to 529 * provide 0A (zero torque). 530 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 531 * This allows users to use other limit 532 * switch sensors connected to robot 533 * controller. This also allows use of 534 * active sensors that require external 535 * power. 536 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 537 * This allows users to use other limit 538 * switch sensors connected to robot 539 * controller. This also allows use of 540 * active sensors that require external 541 * power. 542 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 543 * switches and the LimitForwardMotion and 544 * LimitReverseMotion parameters, instead 545 * allowing motion. 546 * <p> 547 * This can be useful on mechanisms such 548 * as an intake/feeder, where a limit 549 * switch stops motion while intaking but 550 * should be ignored when feeding to a 551 * shooter. 552 * <p> 553 * The hardware limit faults and 554 * Forward/ReverseLimit signals will still 555 * report the values of the limit switches 556 * regardless of this parameter. 557 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 558 * instead allowing motion. 559 * <p> 560 * This can be useful when calibrating the 561 * zero point of a mechanism such as an 562 * elevator. 563 * <p> 564 * The software limit faults will still 565 * report the values of the software 566 * limits regardless of this parameter. 567 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 568 * request until a timesync boundary (requires 569 * Phoenix Pro and CANivore). This eliminates the 570 * impact of nondeterministic network delays in 571 * exchange for a larger but deterministic control 572 * latency. 573 * <p> 574 * This requires setting the ControlTimesyncFreqHz 575 * config in MotorOutputConfigs. Additionally, when 576 * this is enabled, the UpdateFreqHz of this 577 * request should be set to 0 Hz. 578 * </ul> 579 * </ul> 580 * 581 * @param request Control object to request of the device 582 * @return Code response of the request 583 */ 584 StatusCode setControl(MotionMagicExpoTorqueCurrentFOC request); 585 586 /** 587 * Requests Motion Magic® to target a final position using a motion 588 * profile. This dynamic request allows runtime changes to Cruise 589 * Velocity, Acceleration, and (optional) Jerk. Users can optionally 590 * provide a torque current feedforward. 591 * <p> 592 * Motion Magic® produces a motion profile in real-time while 593 * attempting to honor the specified Cruise Velocity, Acceleration, 594 * and (optional) Jerk. This control mode does not use the Expo_kV or 595 * Expo_kA configs. 596 * <p> 597 * Target position can be changed on-the-fly and Motion Magic® will do 598 * its best to adjust the profile. This control mode is based on 599 * torque current, so relevant closed-loop gains will use Amperes for 600 * the numerator. 601 * <ul> 602 * <li> <b>DynamicMotionMagicTorqueCurrentFOC Parameters:</b> 603 * <ul> 604 * <li> <b>Position:</b> Position to drive toward in rotations. 605 * <li> <b>Velocity:</b> Cruise velocity for profiling. The signage does 606 * not matter as the device will use the absolute 607 * value for profile generation. 608 * <li> <b>Acceleration:</b> Acceleration for profiling. The signage does 609 * not matter as the device will use the absolute 610 * value for profile generation. 611 * <li> <b>Jerk:</b> Jerk for profiling. The signage does not matter as the 612 * device will use the absolute value for profile 613 * generation. 614 * <p> 615 * Jerk is optional; if this is set to zero, then Motion 616 * Magic® will not apply a Jerk limit. 617 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 618 * Amperes. This is added to the output of the 619 * onboard feedforward terms. 620 * <p> 621 * User can use motor's kT to scale Newton-meter to 622 * Amperes. 623 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 624 * Use the configuration api to set the gain values for 625 * the selected slot before enabling this feature. Slot 626 * must be within [0,2]. 627 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 628 * output is zero (or within deadband). 629 * Set to false to use the NeutralMode 630 * configuration setting (default). 631 * This flag exists to provide the 632 * fundamental behavior of this control 633 * when output is zero, which is to 634 * provide 0A (zero torque). 635 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 636 * This allows users to use other limit 637 * switch sensors connected to robot 638 * controller. This also allows use of 639 * active sensors that require external 640 * power. 641 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 642 * This allows users to use other limit 643 * switch sensors connected to robot 644 * controller. This also allows use of 645 * active sensors that require external 646 * power. 647 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 648 * switches and the LimitForwardMotion and 649 * LimitReverseMotion parameters, instead 650 * allowing motion. 651 * <p> 652 * This can be useful on mechanisms such 653 * as an intake/feeder, where a limit 654 * switch stops motion while intaking but 655 * should be ignored when feeding to a 656 * shooter. 657 * <p> 658 * The hardware limit faults and 659 * Forward/ReverseLimit signals will still 660 * report the values of the limit switches 661 * regardless of this parameter. 662 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 663 * instead allowing motion. 664 * <p> 665 * This can be useful when calibrating the 666 * zero point of a mechanism such as an 667 * elevator. 668 * <p> 669 * The software limit faults will still 670 * report the values of the software 671 * limits regardless of this parameter. 672 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 673 * request until a timesync boundary (requires 674 * Phoenix Pro and CANivore). This eliminates the 675 * impact of nondeterministic network delays in 676 * exchange for a larger but deterministic control 677 * latency. 678 * <p> 679 * This requires setting the ControlTimesyncFreqHz 680 * config in MotorOutputConfigs. Additionally, when 681 * this is enabled, the UpdateFreqHz of this 682 * request should be set to 0 Hz. 683 * </ul> 684 * </ul> 685 * 686 * @param request Control object to request of the device 687 * @return Code response of the request 688 */ 689 StatusCode setControl(DynamicMotionMagicTorqueCurrentFOC request); 690 691 /** 692 * Requests Motion Magic® Expo to target a final position using an 693 * exponential motion profile. This dynamic request allows runtime 694 * changes to the profile kV, kA, and (optional) Cruise Velocity. 695 * Users can optionally provide a torque current feedforward. 696 * <p> 697 * Motion Magic® Expo produces a motion profile in real-time while 698 * attempting to honor the specified Cruise Velocity (optional) and 699 * the mechanism kV and kA. Note that unlike the slot gains, the 700 * Expo_kV and Expo_kA parameters are always in output units of Volts. 701 * <p> 702 * Setting the Cruise Velocity to 0 will allow the profile to run to 703 * the max possible velocity based on Expo_kV. This control mode does 704 * not use the Acceleration or Jerk configs. 705 * <p> 706 * Target position can be changed on-the-fly and Motion Magic® will do 707 * its best to adjust the profile. This control mode is based on 708 * torque current, so relevant closed-loop gains will use Amperes for 709 * the numerator. 710 * <ul> 711 * <li> <b>DynamicMotionMagicExpoTorqueCurrentFOC Parameters:</b> 712 * <ul> 713 * <li> <b>Position:</b> Position to drive toward in rotations. 714 * <li> <b>kV:</b> Mechanism kV for profiling. Unlike the kV slot gain, 715 * this is always in units of V/rps. 716 * <p> 717 * This represents the amount of voltage necessary to hold a 718 * velocity. In terms of the Motion Magic® Expo profile, a 719 * higher kV results in a slower maximum velocity. 720 * <li> <b>kA:</b> Mechanism kA for profiling. Unlike the kA slot gain, 721 * this is always in units of V/rps². 722 * <p> 723 * This represents the amount of voltage necessary to 724 * achieve an acceleration. In terms of the Motion Magic® 725 * Expo profile, a higher kA results in a slower 726 * acceleration. 727 * <li> <b>Velocity:</b> Cruise velocity for profiling. The signage does 728 * not matter as the device will use the absolute 729 * value for profile generation. Setting this to 0 730 * will allow the profile to run to the max possible 731 * velocity based on Expo_kV. 732 * <li> <b>FeedForward:</b> Feedforward to apply in torque current in 733 * Amperes. This is added to the output of the 734 * onboard feedforward terms. 735 * <p> 736 * User can use motor's kT to scale Newton-meter to 737 * Amperes. 738 * <li> <b>Slot:</b> Select which gains are applied by selecting the slot. 739 * Use the configuration api to set the gain values for 740 * the selected slot before enabling this feature. Slot 741 * must be within [0,2]. 742 * <li> <b>OverrideCoastDurNeutral:</b> Set to true to coast the rotor when 743 * output is zero (or within deadband). 744 * Set to false to use the NeutralMode 745 * configuration setting (default). 746 * This flag exists to provide the 747 * fundamental behavior of this control 748 * when output is zero, which is to 749 * provide 0A (zero torque). 750 * <li> <b>LimitForwardMotion:</b> Set to true to force forward limiting. 751 * This allows users to use other limit 752 * switch sensors connected to robot 753 * controller. This also allows use of 754 * active sensors that require external 755 * power. 756 * <li> <b>LimitReverseMotion:</b> Set to true to force reverse limiting. 757 * This allows users to use other limit 758 * switch sensors connected to robot 759 * controller. This also allows use of 760 * active sensors that require external 761 * power. 762 * <li> <b>IgnoreHardwareLimits:</b> Set to true to ignore hardware limit 763 * switches and the LimitForwardMotion and 764 * LimitReverseMotion parameters, instead 765 * allowing motion. 766 * <p> 767 * This can be useful on mechanisms such 768 * as an intake/feeder, where a limit 769 * switch stops motion while intaking but 770 * should be ignored when feeding to a 771 * shooter. 772 * <p> 773 * The hardware limit faults and 774 * Forward/ReverseLimit signals will still 775 * report the values of the limit switches 776 * regardless of this parameter. 777 * <li> <b>IgnoreSoftwareLimits:</b> Set to true to ignore software limits, 778 * instead allowing motion. 779 * <p> 780 * This can be useful when calibrating the 781 * zero point of a mechanism such as an 782 * elevator. 783 * <p> 784 * The software limit faults will still 785 * report the values of the software 786 * limits regardless of this parameter. 787 * <li> <b>UseTimesync:</b> Set to true to delay applying this control 788 * request until a timesync boundary (requires 789 * Phoenix Pro and CANivore). This eliminates the 790 * impact of nondeterministic network delays in 791 * exchange for a larger but deterministic control 792 * latency. 793 * <p> 794 * This requires setting the ControlTimesyncFreqHz 795 * config in MotorOutputConfigs. Additionally, when 796 * this is enabled, the UpdateFreqHz of this 797 * request should be set to 0 Hz. 798 * </ul> 799 * </ul> 800 * 801 * @param request Control object to request of the device 802 * @return Code response of the request 803 */ 804 StatusCode setControl(DynamicMotionMagicExpoTorqueCurrentFOC request); 805 806 /** 807 * Differential control with torque current average target and 808 * position difference target. 809 * <ul> 810 * <li> <b>Diff_TorqueCurrentFOC_Position Parameters:</b> 811 * <ul> 812 * <li> <b>AverageRequest:</b> Average TorqueCurrentFOC request of the 813 * mechanism. 814 * <li> <b>DifferentialRequest:</b> Differential PositionTorqueCurrentFOC 815 * request of the mechanism. 816 * </ul> 817 * </ul> 818 * 819 * @param request Control object to request of the device 820 * @return Code response of the request 821 */ 822 StatusCode setControl(Diff_TorqueCurrentFOC_Position request); 823 824 /** 825 * Differential control with position average target and position 826 * difference target using torque current control. 827 * <ul> 828 * <li> <b>Diff_PositionTorqueCurrentFOC_Position Parameters:</b> 829 * <ul> 830 * <li> <b>AverageRequest:</b> Average PositionTorqueCurrentFOC request of 831 * the mechanism. 832 * <li> <b>DifferentialRequest:</b> Differential PositionTorqueCurrentFOC 833 * request of the mechanism. 834 * </ul> 835 * </ul> 836 * 837 * @param request Control object to request of the device 838 * @return Code response of the request 839 */ 840 StatusCode setControl(Diff_PositionTorqueCurrentFOC_Position request); 841 842 /** 843 * Differential control with velocity average target and position 844 * difference target using torque current control. 845 * <ul> 846 * <li> <b>Diff_VelocityTorqueCurrentFOC_Position Parameters:</b> 847 * <ul> 848 * <li> <b>AverageRequest:</b> Average VelocityTorqueCurrentFOC request of 849 * the mechanism. 850 * <li> <b>DifferentialRequest:</b> Differential PositionTorqueCurrentFOC 851 * request of the mechanism. 852 * </ul> 853 * </ul> 854 * 855 * @param request Control object to request of the device 856 * @return Code response of the request 857 */ 858 StatusCode setControl(Diff_VelocityTorqueCurrentFOC_Position request); 859 860 /** 861 * Differential control with Motion Magic® average target and position 862 * difference target using torque current control. 863 * <ul> 864 * <li> <b>Diff_MotionMagicTorqueCurrentFOC_Position Parameters:</b> 865 * <ul> 866 * <li> <b>AverageRequest:</b> Average MotionMagicTorqueCurrentFOC request 867 * of the mechanism. 868 * <li> <b>DifferentialRequest:</b> Differential PositionTorqueCurrentFOC 869 * request of the mechanism. 870 * </ul> 871 * </ul> 872 * 873 * @param request Control object to request of the device 874 * @return Code response of the request 875 */ 876 StatusCode setControl(Diff_MotionMagicTorqueCurrentFOC_Position request); 877 878 /** 879 * Differential control with Motion Magic® Expo average target and 880 * position difference target using torque current control. 881 * <ul> 882 * <li> <b>Diff_MotionMagicExpoTorqueCurrentFOC_Position Parameters:</b> 883 * <ul> 884 * <li> <b>AverageRequest:</b> Average MotionMagicExpoTorqueCurrentFOC 885 * request of the mechanism. 886 * <li> <b>DifferentialRequest:</b> Differential PositionTorqueCurrentFOC 887 * request of the mechanism. 888 * </ul> 889 * </ul> 890 * 891 * @param request Control object to request of the device 892 * @return Code response of the request 893 */ 894 StatusCode setControl(Diff_MotionMagicExpoTorqueCurrentFOC_Position request); 895 896 /** 897 * Differential control with Motion Magic® Velocity average target and 898 * position difference target using torque current control. 899 * <ul> 900 * <li> <b>Diff_MotionMagicVelocityTorqueCurrentFOC_Position Parameters:</b> 901 * <ul> 902 * <li> <b>AverageRequest:</b> Average MotionMagicVelocityTorqueCurrentFOC 903 * request of the mechanism. 904 * <li> <b>DifferentialRequest:</b> Differential PositionTorqueCurrentFOC 905 * request of the mechanism. 906 * </ul> 907 * </ul> 908 * 909 * @param request Control object to request of the device 910 * @return Code response of the request 911 */ 912 StatusCode setControl(Diff_MotionMagicVelocityTorqueCurrentFOC_Position request); 913 914 /** 915 * Differential control with torque current average target and 916 * velocity difference target. 917 * <ul> 918 * <li> <b>Diff_TorqueCurrentFOC_Velocity Parameters:</b> 919 * <ul> 920 * <li> <b>AverageRequest:</b> Average TorqueCurrentFOC request of the 921 * mechanism. 922 * <li> <b>DifferentialRequest:</b> Differential VelocityTorqueCurrentFOC 923 * request of the mechanism. 924 * </ul> 925 * </ul> 926 * 927 * @param request Control object to request of the device 928 * @return Code response of the request 929 */ 930 StatusCode setControl(Diff_TorqueCurrentFOC_Velocity request); 931 932 /** 933 * Differential control with position average target and velocity 934 * difference target using torque current control. 935 * <ul> 936 * <li> <b>Diff_PositionTorqueCurrentFOC_Velocity Parameters:</b> 937 * <ul> 938 * <li> <b>AverageRequest:</b> Average PositionTorqueCurrentFOC request of 939 * the mechanism. 940 * <li> <b>DifferentialRequest:</b> Differential VelocityTorqueCurrentFOC 941 * request of the mechanism. 942 * </ul> 943 * </ul> 944 * 945 * @param request Control object to request of the device 946 * @return Code response of the request 947 */ 948 StatusCode setControl(Diff_PositionTorqueCurrentFOC_Velocity request); 949 950 /** 951 * Differential control with velocity average target and velocity 952 * difference target using torque current control. 953 * <ul> 954 * <li> <b>Diff_VelocityTorqueCurrentFOC_Velocity Parameters:</b> 955 * <ul> 956 * <li> <b>AverageRequest:</b> Average VelocityTorqueCurrentFOC request of 957 * the mechanism. 958 * <li> <b>DifferentialRequest:</b> Differential VelocityTorqueCurrentFOC 959 * request of the mechanism. 960 * </ul> 961 * </ul> 962 * 963 * @param request Control object to request of the device 964 * @return Code response of the request 965 */ 966 StatusCode setControl(Diff_VelocityTorqueCurrentFOC_Velocity request); 967 968 /** 969 * Differential control with Motion Magic® average target and velocity 970 * difference target using torque current control. 971 * <ul> 972 * <li> <b>Diff_MotionMagicTorqueCurrentFOC_Velocity Parameters:</b> 973 * <ul> 974 * <li> <b>AverageRequest:</b> Average MotionMagicTorqueCurrentFOC request 975 * of the mechanism. 976 * <li> <b>DifferentialRequest:</b> Differential VelocityTorqueCurrentFOC 977 * request of the mechanism. 978 * </ul> 979 * </ul> 980 * 981 * @param request Control object to request of the device 982 * @return Code response of the request 983 */ 984 StatusCode setControl(Diff_MotionMagicTorqueCurrentFOC_Velocity request); 985 986 /** 987 * Differential control with Motion Magic® Expo average target and 988 * velocity difference target using torque current control. 989 * <ul> 990 * <li> <b>Diff_MotionMagicExpoTorqueCurrentFOC_Velocity Parameters:</b> 991 * <ul> 992 * <li> <b>AverageRequest:</b> Average MotionMagicExpoTorqueCurrentFOC 993 * request of the mechanism. 994 * <li> <b>DifferentialRequest:</b> Differential VelocityTorqueCurrentFOC 995 * request of the mechanism. 996 * </ul> 997 * </ul> 998 * 999 * @param request Control object to request of the device 1000 * @return Code response of the request 1001 */ 1002 StatusCode setControl(Diff_MotionMagicExpoTorqueCurrentFOC_Velocity request); 1003 1004 /** 1005 * Differential control with Motion Magic® Velocity average target and 1006 * velocity difference target using torque current control. 1007 * <ul> 1008 * <li> <b>Diff_MotionMagicVelocityTorqueCurrentFOC_Velocity Parameters:</b> 1009 * <ul> 1010 * <li> <b>AverageRequest:</b> Average MotionMagicVelocityTorqueCurrentFOC 1011 * request of the mechanism. 1012 * <li> <b>DifferentialRequest:</b> Differential VelocityTorqueCurrentFOC 1013 * request of the mechanism. 1014 * </ul> 1015 * </ul> 1016 * 1017 * @param request Control object to request of the device 1018 * @return Code response of the request 1019 */ 1020 StatusCode setControl(Diff_MotionMagicVelocityTorqueCurrentFOC_Velocity request); 1021 1022 /** 1023 * Differential control with torque current average target and torque 1024 * current difference target. 1025 * <ul> 1026 * <li> <b>Diff_TorqueCurrentFOC_Open Parameters:</b> 1027 * <ul> 1028 * <li> <b>AverageRequest:</b> Average TorqueCurrentFOC request of the 1029 * mechanism. 1030 * <li> <b>DifferentialRequest:</b> Differential TorqueCurrentFOC request of 1031 * the mechanism. 1032 * </ul> 1033 * </ul> 1034 * 1035 * @param request Control object to request of the device 1036 * @return Code response of the request 1037 */ 1038 StatusCode setControl(Diff_TorqueCurrentFOC_Open request); 1039 1040 /** 1041 * Differential control with position average target and torque 1042 * current difference target. 1043 * <ul> 1044 * <li> <b>Diff_PositionTorqueCurrentFOC_Open Parameters:</b> 1045 * <ul> 1046 * <li> <b>AverageRequest:</b> Average PositionTorqueCurrentFOC request of 1047 * the mechanism. 1048 * <li> <b>DifferentialRequest:</b> Differential TorqueCurrentFOC request of 1049 * the mechanism. 1050 * </ul> 1051 * </ul> 1052 * 1053 * @param request Control object to request of the device 1054 * @return Code response of the request 1055 */ 1056 StatusCode setControl(Diff_PositionTorqueCurrentFOC_Open request); 1057 1058 /** 1059 * Differential control with velocity average target and torque 1060 * current difference target. 1061 * <ul> 1062 * <li> <b>Diff_VelocityTorqueCurrentFOC_Open Parameters:</b> 1063 * <ul> 1064 * <li> <b>AverageRequest:</b> Average VelocityTorqueCurrentFOC request of 1065 * the mechanism. 1066 * <li> <b>DifferentialRequest:</b> Differential TorqueCurrentFOC request of 1067 * the mechanism. 1068 * </ul> 1069 * </ul> 1070 * 1071 * @param request Control object to request of the device 1072 * @return Code response of the request 1073 */ 1074 StatusCode setControl(Diff_VelocityTorqueCurrentFOC_Open request); 1075 1076 /** 1077 * Differential control with Motion Magic® average target and torque 1078 * current difference target. 1079 * <ul> 1080 * <li> <b>Diff_MotionMagicTorqueCurrentFOC_Open Parameters:</b> 1081 * <ul> 1082 * <li> <b>AverageRequest:</b> Average MotionMagicTorqueCurrentFOC request 1083 * of the mechanism. 1084 * <li> <b>DifferentialRequest:</b> Differential TorqueCurrentFOC request of 1085 * the mechanism. 1086 * </ul> 1087 * </ul> 1088 * 1089 * @param request Control object to request of the device 1090 * @return Code response of the request 1091 */ 1092 StatusCode setControl(Diff_MotionMagicTorqueCurrentFOC_Open request); 1093 1094 /** 1095 * Differential control with Motion Magic® Expo average target and 1096 * torque current difference target. 1097 * <ul> 1098 * <li> <b>Diff_MotionMagicExpoTorqueCurrentFOC_Open Parameters:</b> 1099 * <ul> 1100 * <li> <b>AverageRequest:</b> Average MotionMagicExpoTorqueCurrentFOC 1101 * request of the mechanism. 1102 * <li> <b>DifferentialRequest:</b> Differential TorqueCurrentFOC request of 1103 * the mechanism. 1104 * </ul> 1105 * </ul> 1106 * 1107 * @param request Control object to request of the device 1108 * @return Code response of the request 1109 */ 1110 StatusCode setControl(Diff_MotionMagicExpoTorqueCurrentFOC_Open request); 1111 1112 /** 1113 * Differential control with Motion Magic® Velocity average target and 1114 * torque current difference target. 1115 * <ul> 1116 * <li> <b>Diff_MotionMagicVelocityTorqueCurrentFOC_Open Parameters:</b> 1117 * <ul> 1118 * <li> <b>AverageRequest:</b> Average MotionMagicVelocityTorqueCurrentFOC 1119 * request of the mechanism. 1120 * <li> <b>DifferentialRequest:</b> Differential TorqueCurrentFOC request of 1121 * the mechanism. 1122 * </ul> 1123 * </ul> 1124 * 1125 * @param request Control object to request of the device 1126 * @return Code response of the request 1127 */ 1128 StatusCode setControl(Diff_MotionMagicVelocityTorqueCurrentFOC_Open request); 1129 1130 /** 1131 * Control device with generic control request object. 1132 * <p> 1133 * User must make sure the specified object is castable to a valid control request, 1134 * otherwise this function will fail at run-time and return the NotSupported StatusCode 1135 * 1136 * @param request Control object to request of the device 1137 * @return Status Code of the request, 0 is OK 1138 */ 1139 StatusCode setControl(ControlRequest request); 1140 1141} 1142