Smart Motion Control
Last updated
Last updated
Smart Motion Control is a complex control mode that allows for smoother and more controlled movements from one position to another. By configuring the maximum velocity and acceleration, as shown in Smart Motion Parameters, this control mode will create a motion that accelerates, holds a constant "cruise" velocity, and then decelerates to a stop at the setpoint.
Tuning the PID Controller for Smart Motion may be difficult on mechanisms with a very limited range of motion.
This control mode takes a setpoint in units of rotations, but the underlying implementation executes a Velocity PID controller, so the PID tuning process will be more like a Velocity controller.
The Smart Motion Example Program is a good tool for tuning this control loop, as it allows you to toggle between Smart Motion and Velocity control to fine-tune the constants and parameters.
Smart Motion's function is the same as that of WPILib's TrapezoidalProfile, which uses an underlying position-based PID controller which may be easier to tune and can sometimes provide better results.
Running Smart Motion Control is as easy as any other control mode: configure the constants, pick your setpoints, and set it as the mode when you apply the position target, as seen below:
API Docs: setReference
Using the Velocity Control mode will rotate your mechanism continuously. Please exercise caution while tuning. Utilize hard and soft limits to protect your robot.