All pages
Powered by GitBook
1 of 1

Loading...

Position Control Mode

Position Control is used to point the motor in a specific direction. It takes a setpoint in rotations (or whatever unit your selected encoder's position conversion factor is in) and uses the PID loop to move to that position. The Position control mode pipes directly into a PID controller with the configured encoder.

A properly tuned Position control loop should respond quickly and accurately to a setpoint change and should not oscillate around the target.

To run the motor in Position control mode, set the PID Controller setpoint as shown below.

API Docs:

API Reference:

For more complex mechanisms or motions where closer control over acceleration and velocity are needed, see MAXMotion Position Control

setSetpoint
SetSetpoint
This loop was tuned to show the curve, an ideal controller would move much quicker. In a perfect world, this motion would be nearly instantaneous.
m_controller.setSetpoint(setPoint, ControlType.kPosition);
using namespace rev::spark;

m_controller.SetSetpoint(setPoint, SparkBase::ControlType::kPosition);