# Precision Turns During Autonomous

Good Morning,
I have done some ‘film study’ of matches at the Kalahari Classic and the Gateway to the West Signature Events, and I have seen that the top tier teams always seem to have an elite autonomous that appears very reliable and consistent. How do these teams achieve this? Do they use PID loops, odometry, an interial sensor, motor encoders, all of the above, none of the above? I am the programmer on my team and have tried to use the inertial sensor, motor encoders, a basic PID loop, and my efforts have proved fruitless; our autonomous is 50/50 at best.

This video shows an example of the autonomous that I am talking about:
Notice 2011D in the bottom right especially

It depends heavily on the team! Almost all of the teams will use PID in some shape or form, a significant amount of them will use Odom or some other field positioning system (which means determining exactly where on the field you are), and many of them will also use other algorithms, such as Pure Pursuit.

My team uses PID and is in the process of implementing Odom, with the hope of PP before regionals. At the time that we competed at the Speedway Signature Event, we had just PID and did just fine.

My first question: do you feel confident that you understand the theory and the math behind PID?
Second question: do you feel confident that you understand how to implement PID?

And just for some information: the only thing the sensors (motor encoders, inertials, etc) do is feed data into the algorithms (PID, Odom, etc). The sensor values themselves probably shouldn’t be used to determine anything about controlling movement.

1 Like

To answer Question 1 and 2 in short: Not really. My coach and I have been trying to learn whatever we can from the forums and YouTube, but have only picked up the code itself, never really an explanation of the PID theory or math behind it. We’ve only ever been able to implement PID loops on the fly, and have never implemented them because we understand them. Is there (a) resource(s) that you would recommend for us to learn PID theory, math, and/ or implementation?

all I know on this is that a GPS sensor isn’t the best option, you didn’t list it, but in case you were thinking of using a GPS sensor, from my experience it eats up a lot of the brain’s CPU and does not leave room for much else.

From my experience, An Introduction to PID Controllers by George Gillard is very good, and also PID Controller - BLRS Wiki is helpful. I hope this helps!

@Max_Waldman Said it pretty well, those resources are great. However, resources for learning the theory tend to use bigger words that don’t always make sense. Here’s one way to explain it (below). if you want a better, more logical (and mathy) explanation I can do that, but be warned, some of these concepts require having taken Calculus to understand completely

all the Ks are constants that you get to manipulate and change, in order to affect how much weight you want the different data pieces to have in how fast you are going to go
the error gets scaled according to kP (the name proportional represents the fact that this piece of output is directly proportional to the remaining error)
the speed (which is the derivative of the error, hence the name derivative) gets scaled according to kD
the accumulation of error (which is the integral of the error, hence the name integral) gets scaled according to kI

error is simply the difference between the target distance to travel and how far the robot has actually traveled. so for example, 10.2 inches left to go.
speed is simply the change in error between the last loop through the PID controller and the current. so for example, last loop the error was 10.35, and now error is 10.2, so the speed is 0.15 inches/loop
accumulation of error is more complex. the gist is, each time through the loop, an outside constant gets increased by the error, accumulating each error and getting very large. So, in this scenario, the AoE from those two single loops is 20.55 inches.

1 Like

Yeah, my team figured that out \$400 too late.

That paper is the most comprehensive, but also detailed explanation of PID loops that I’ve come across.

@1082X Do you use motor encoders, an inertial sensor, or some other sensor as the inputs for your PID loops?

P.S. We had to rebuild most of my team’s bot, so my response was delayed.

Motor Encoders for lateral distance (although tracking wheels will soon replace this, pending builders not being lazy) and Inertial Sensor for turning angle.

Tracking Wheel = wheel that is independent of drivetrain, attached to rotation sensor. The wheel only moves according to (and the rotation sensor only senses) the robot’s actual movement as opposed to the rotation of the motors (for example, if you are stuck on barrier and your motors are spinning, but you’re not actually moving)

1 Like