Control Theory

Hello folks!

For those who do not remember me, my name is Robert. I have been a Vex fan since the very beginning when RadioShack was selling Vex kits :eek: and even before that admiring the robots on vexlabs.com. I have come a far way since I built my first squarebot a couple years back and I am forever grateful for discovering Vex and the implications it had on my college education. Now to get to business!

I am currently an aerospace engineering student and am looking forward to graduate studies in the field of control theory. You may ask, what is control theory? Personally I had never heard of it when I was in high school… You might have heard the intimidating ‘PID’ word floating around the robotics’ threads or were amazed by how well the world championship robots follow the white line SO accurately or how an arm moved to a position so fast and smooth without jerking the entire bot. Well I was always intrigued by these sophisticated robots (especially the balancing bot) but I never could quite figure out how these robots worked. Well NOW that I have this stuff figured out pretty well, I have decided to give back to the Vex community and make a series of tutorials introducing you to controls. These tutorials would start with the very basics and would make their way through quite sophisticated material, all the while keeping you guys in mind. The only real downside is that these tutorials would be mostly theoretical though since I do not have a Vex Kit anymore and cannot test anything (too expensive for me when they upgraded… :() but i’m hoping they’re helpful enough for you guys to apply this knowledge

So the question is. What would you guys like to see? line following, balancing bot, arm movement, encoders, gyros, u name it!

Technic-R-C

balancing robot on a gateway ball :slight_smile:

I would like to see PID in line following. I’ve read a ton about it, and can understand PID in encoders for arms, and drive, but cannot understand PID in line following. It would be very helpful!

Hey that’s awesome! Thanks for giving back to the VEX community! :slight_smile:
I would be interested in seeing a PID arm controller, noting that there is gravity at play, and varying elements in the basket; would a static offset value added to the motors be good, or just a higher Integral Constant? I would be interested in seeing the implementation of the PID controller as well as how you would tune it.

However, the thing that Vexes me the most (pun so totally intended :smiley: ) is how in the world you account for delta time inside of a control loop (for the I and D), instead of relying on the executing speed being constant and adjusting your constants to compensate?

dt is constant (or at least should be) since it should take the same amount of time to go through the loop every time.

If not then try this

while true
{
reset timer
your code
while (timer < desired dt)
{
}
}

basically it will not go around the loop again until the timer trips your desired loop time, thus making dt constant.

Right, and thanks!
I was also wondering how to use Delta Time as a factor in the math, instead of slowing down the code to make sure it executes at a certain speed; especially if I run it as a task, it’s possible I may have variable execution times, and I would like to know if I can just divide or multiply something by Delta Time, and what units I would need things to be in, to get a working dynamic (variable time) PID controller system.

WOW!! Glad to see you back!!! I am an “Old Timer” too…

Aerospace Engineering, a most excellent field…

Yes, please develop some Tutorials…

I still have my Vex Kits, and have Multiple PIC Controllers with the 75Mhz Control System, One Cortex with the VEXnet and most of the Vex Sensors… I also have all Four Versions of EasyC, All Three Versions of RobotC and MPLAB with the C18 Compiler…

I would be more than willing, to Setup Hardware and Test, and Take Pictures…

I have the Accelerometer, but no Gyro, ( but I am willing to buy one, please Twist My Arm… )… I have started, but not finished working with the Accelerometer to detect Direction and Speed… I think that much can be accomplished with Motion Detection and the Accelerometer… My Math is at Beginning Calculus… ( Still trying to Wrap My Head around it… ) So I have much deficiency and Gaps in my Knowledge… :wink:

My Math is at Beginning Calculus, and I understand PID Loops, basically…

So, you should be able to, Dynamically Calculate your Main Loop Time, and adjust your DT accordingly. As Long as you don’t Asynchronously Block your execution by using random Wait Delays…

Basically, instead of changing your Loop Time to Match your Calculations, you Change your Calculations to Match your Loop Time…

Welcome back,

Anything that you can write up would be great! Depending on their length, maybe the tutorials could be created as pages in the vex wiki or at least links to them could be added. I think they would be great references and learning tools for VEX users of all skill levels.

If MarkO can get code tested and working then maybe we can get some of it setup to run on the VEX Pro also. I started a page to help with programming the VEX Pro and I think it would be great to be able to add examples of these subjects to it.