MAXMotion Position Control

MAXMotion Position Control is a second-degree closed loop controller, allowing for smooth and consistent motions from one position to another by limiting both the velocity and acceleration of the motor. These can be configured via the MAXMotion Parameters, setting a target acceleration and a "cruise" velocity. The motor will spin up, honoring the acceleration target, hold speed at the cruise velocity, and then slow down honoring the acceleration target to arrive at the setpoint.

MAXMotion Position Control runs on top of an internal position PID controller, so the tuning process begins similarly to a typical position closed loop controller, with the P and D constants (See Getting Started with PID Tuning for more on this). Note that these values may need tweaked once you set your velocity and acceleration targets in order to smooth out the motion.

When setting your maximum velocity and maximum acceleration parameters, keep a few things in mind:

  • Maximum velocity is in units of revolutions per minute by default

  • Maximum acceleration is in units of RPM per second by default

  • Your current limits may interfere with motions that move too quickly or hold against gravity for too long

  • Try to achieve a good balance of smoothness and consistency with speed

Setting a high acceleration or velocity could cause the mechanism to shift or move your robot and may be dangerous to stand close to, so use extra caution when speeding things up

Tips for Smooth Motions

  • If your motion seems jittery, try adjusting your PID constants. If the target acceleration is faster or slower than your PIDs allow, the mechanism may appear to shake or jitter and speed and accuracy will be lost.

  • Keep an eye on the current draw, as hitting limits may interfere with the functionality of MAXMotion. Increasing current limits or changing the gear ratio on your mechanism can help reduce the chances of this happening.

  • Feed forwards may help smoothness but also may hurt it, depending on your mechanism. MAXMotion may be able to handle the motion on its own without any help at all.

  • As MAXMotion runs on an underlying position closed loop controller, a kF gain is not recommended and may lead to unexpected results. Instead, lean on the PID constants to handle this.

Using MAXMotion

After tuning your constants, calling MAXMotion is as simple as passing in the setpoint to the controller.

m_controller.setReference(setPoint, SparkBase.ControlType.kMAXMotionPositionControl);

API Docs: setReference

Migrating from Smart Motion

As Smart Motion and MAXMotion Position Control use different underlying control methods, all PID constants will need to be re-tuned from scratch

Smart Motion used a different method for smooth second-degree motion control, but MAXMotion can be applied anywhere Smart Motion was previously. Maximum velocity and acceleration constants may be transferable, but should be tested with caution. All other constants will need re-tuned from scratch, including all PIDs.

MAXMotion has several improvements over Smart Motion, and should offer better consistency, a better tuning experience, better position retention, and an all-around better user experience. It is highly recommended to migrate all systems using Smart Motion to MAXMotion.

Last updated