What does .setPosition() for the neo motors actually do

https://codedocs.revrobotics.com/java/com/revrobotics/sparkmaxrelativeencoder

My team is trying to find a way so our arm(for intake) that goes up and down can be more reliable. We wish for it to be a up button and down button to the same position every time. :smiley:

.setPosition() just sets where the encoder says it is with .getPosition(). Since the encoder is relative, it just gives you the change in position from where it started. .setPosition() is commonly used for “homing” sequences where you take the mechanism to a known position, usually using a limit switch, and then use that to set the position so later positions are consistant.

If you want to control the motor using position feedback from the NEO’s incoder you’d want to look into the PID Controller and Closed-Loop Control options of the Spark MAX.
https://codedocs.revrobotics.com/java/com/revrobotics/sparkmaxpidcontroller

3468 are using this with our Climber Arms this year, here is our code:

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