What do you guys use in order to turn? Gyro or Encoder and why

We’ve been using Encoders so far and we’re wondering what other teams use and what the advantages of the usage are

You will pretty much never, ever get a reliable reading for angle from a wheel-mounted encoder. Robots just don’t turn in a consistent way when they’re scrubbing wheels. I’m sure someone smarter than me can come up with a mathematical explanation, but the gist of it is that the wheels are designed to go forward and backwards in a linear fashion. When the robot turns, you add a (slight) horizontal component to that motion which will throw off your readings.

Gyros are the better option because they always give highly-accurate angles regardless of wheel size or other factors necessary when using encoders. Plus, if an encoder slips, accuracy is further diminished. Using encoders for angle values is simply not reliable enough, and as such it’s worth it to use a gyro.

The best option is to use both for error checking and redundancy. A general rule of robotics is that the more information you can gather about your environment, the better.

*If you have a swerve drivetrain, and you’re driving on a flat field, and your inverse kinematics algorithm is correct, and you limit acceleration and velocity to reasonable values, and you have drive encoders on all 4 wheels, and you steer the wheels to the correct angles before driving them, and you are trying to rotate in-place around the center of the contact patch rectangle of the 4 wheels, you should be able to fuse the 4 encoder readings to let you turn a desired change in heading angle.

tl;dr: use a gyro

I’m confused where the both option is…

Both. The gyro is great because it is immune to wheel slip issues and can cope with unmodeled robot dynamics. Encoders are great because they are super fast and high resolution.

  1. Compute “angular displacement error” as desired heading - current gyro heading (take note to handle the angle wrapping edge cases appropriately).

  2. Compute a goal distance for each of your drive wheels using an inverse kinematics function (angular displacement error is the input, wheel displacements are the outputs). Ideally this function is a perfect model of how wheel displacement affects robot pose, but even if it’s quite a bit off, this method will still converge.

  3. Use encoders with PID (or better yet, a motion profile) to smoothly control each wheel to stop at the desired distance. We used the Talon SRX Motion Magic control mode to do this in 2017.

  4. Repeat 1-3 in a loop (10 to 200 times per second) until angular displacement error is below an acceptable threshold. This ensures that even if your wheels are slipping, you continue to make progress towards your goal by changing the wheel displacement goals accordingly.

It depends.

For a non-rushed autonomous routine where we’re doing gentle accelerations and can control wheel slip, we’ll usually go with an encoder, as it gives us a good range as well as orientation. If we are interested in maintaining a straight line or orientation during teleop (e.g. field centric driving, maintaining orientation while crossing rough terrain), a gyro is essential. As others have already noted “Why not both?”

**Like so:

https://www.chiefdelphi.com/forums/showpost.php?p=1440383&postcount=36**