My team is new to Command Based programming this year and currently we are trying to create a basic autonomous command that drives a specific distance using the integrated neo encoder. It uses the relative encoder class, however whenever we run autonomous the motors simply jerk forward and then stop. Here is a link to the src code:
Hello, thanks for your response. Right now I have the conditional to end once the encoder distance is greater than or equal to the desired distance. However, I still have the same issue. Teleop works perfectly fine, so I am not sure what the problem is.
Enable your robot.
Write down the current encoder reading.
Drive 3 ft. (Painters tape line with a tape measure.)
Write down the new encoder reading.
That is the number of units to drive 3 ft.
In your command, you need to do the same thing.
Save off the current encoder reading. (Do this in the initialize() )
Drive until that initial value + the number of encoder units is greater than how far you want the robot to drive.
Thank you so much. Just figured out the issue. I just forgot to add the drivetrain as a dependency in the encoder drive subsystem. I will be sure to use this method when fine turning the encoder drive.