View Single Post
  #5   Spotlight this post!  
Unread 10-31-2016, 06:02 PM
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,509
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Gyro vs. Encoders for Driving Straight

I think you are traveling the wrong route - so to speak. 3 inches of drift left to right really isn't bad. The reality of driving with an FRC robot is that when you add up the drivetrain backlash, bumps, slips, and other mechanical losses you will never drive perfectly straight.

That's why vision, or sensors of some type are a necessity. It's the law of diminishing returns. You can spend weeks, or months working to get your robot to drive perfectly straight. But when you build your 2017 robot you will face a whole new set of challenges getting it perfect. Or you can spend that same time learning to utilize the vision examples so that when you hit a bump, or wall, or when you start using your new robot for 2017 you'll be able to hit a shot every time.

If you still want to continue optimizing driving straight, gerthworm nailed it.

The addition of a P term to each side of your drivetrain utilizing the gyro will get you darn close to perfect.

P is the proportional, or error term. It's calculated like this:

Proportional_Term = Constant * (Desired_Gyro_Angle - Actual_Gyro_Angle)
Left_Drive = Left_Drive + Proportional_Term
Right_Drive = Right_Drive - Proportional_Term


You may need to swap the +/- in the calculation depending on your drivetrain direction. Simply increase the constant term until you start driving straight. Start very small - like .05 or .1 for your Constant.

This is the most basic form of PID driving straight.

Edit: On another note, try not to saturate your drivetrain. That means try not to send it a full +1 or -1. There are a number of ways to scale the output so that you can still maintain straight driving at full speed.

Last edited by Tom Line : 10-31-2016 at 06:04 PM.
Reply With Quote