frc2399 / 2022-Season

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

Use the navx to drive straight; need this in auton #8

Open Chess318 opened 2 years ago

Chess318 commented 2 years ago

Need to add this ability to the DriveForwardGivenDistance command.

Here is some sample code https://github.com/wpilibsuite/allwpilib/blob/main/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/gyro/Robot.java

also https://wiki.analog.com/first/adis16448_imu_frc/java

Ethan had some ideas also but can't find them right now

edf42001 commented 2 years ago

This is a fun and not too difficult project. Here's some tips and ideas from my experiences:

We have code to turn to a specific angle (N) while standing still. Thus is it pretty easy to turn to a specific angle while driving forward. That's all driving straight is.

Because the angle errors involved with driving straight are small (how would the robot be driving straight and then suddenly facing 90 degrees to the left?) the P gain can be larger. How large? Think about how much turning you would like if the robot was 5 degrees off straight, then test it.

Watch out! You should constrain the maximum turning speed when driving straight. What would happen if the gyro stopped working? Watch this video to find out: https://www.youtube.com/watch?v=2IKyvv7Oe0Y

I don't know if you'd have to invert the turning direction when driving backwards (like in example code). Worth thinking about, drawing a picture, or testing (carefully)

What angle to drive at? Could use the angle the robot starts at when the command starts. Or an angle input into the command. What if the starting angle is a few degrees off? However if you manually input the angle, you have to do that correctly everywhere.

If the robot goes straight, this may not be a priority. If it doesn't, we should implement this. Or, you could implement this as a precaution, then set kP to 0 if you don't want to use it.