Basic questions about spark max smart motion

I’ve read over the documentation and examples for enabling trapezoidal pid control with spark max controllers, but I am still unsure on how to set it all up and use it. So far, I have set the constants for the pid controller and the max velocity and acceleration parameters. But I have no idea how the controller actually changes modes to start controlling the motors via the pid. Does it just magically do it everytime I call setReference with CANSparkMax.ControlType.kSmartMotion? If I want to to implement a drive forward N meters, do I need to set the encoder position to 0 before the first setReference? How do exit smart motion mode and return to open loop? Do I just stop calling setReference and just start calling set()? What would I do in my comand end() method to ensure the PID was no longer trying to command the motor?

Thanks in advance
AJ

Yes.

Yes

As you mentioned, just a single motor.set(0) should work.

Don’t have an answer about the encoder reset question, I would image you don’t but I’m not sure

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.