frc2399 / 2022-Season

This is our NEW repository for the 2022 Season.
Other
0 stars 5 forks source link

Use NavX to make precise turns #29

Open hschilling opened 2 years ago

hschilling commented 2 years ago

Use the NavX to make precise turns.

Use NavX sample code initially

Learn about PID controls by watching the video https://www.youtube.com/watch?v=UOuRx9Ujsog

More good video about PID https://www.youtube.com/watch?v=jIKBWO7ps0w

Also more basic info about PID controls

https://docs.wpilib.org/en/stable/docs/software/advanced-controls/introduction/introduction-to-pid.html

https://docs.wpilib.org/en/stable/docs/software/advanced-controls/introduction/tuning-pid-controller.html

https://docs.wpilib.org/en/stable/docs/software/advanced-controls/controllers/pidcontroller.html

Here is code that uses a PID Controller for moving a set distance using an ultrasonic sensor, but the same principles can apply for the turning and using the NavX

https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ultrasonicpid/Robot.java

Here is code for turning to an angle

https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyrodrivecommands/commands/TurnToAngle.java

Eventually, make use of PID Subsystems and PID Commands

https://docs.wpilib.org/en/stable/docs/software/commandbased/pid-subsystems-commands.html#pid-control-through-pidsubsystems-and-pidcommands