Go to Post IF teams did NOT READ THE FIRST MANUAL AND Q&A SITE, it is not FIRST's fault, it is the TEAM'S fault - sburro [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 28-02-2012, 16:18
jutayo23 jutayo23 is offline
Systems Team
AKA: Justin Yost
FRC #1124 (The ÜberBots)
Team Role: Programmer
 
Join Date: Apr 2010
Rookie Year: 2008
Location: Avon, CT
Posts: 7
jutayo23 is on a distinguished road
Re: Gyro Autobalancing

Team 1124 has gotten autonomous bridge balancing to work very well. Here's a video of our previous year's robot with the balancing code on it (this was before this year's robot was completed) You'll notice the bridge in this video is easily tipped. Our bridge was too light, which made balancing harder to achieve. The code worked even better when we tried it with a competition bridge.

http://www.youtube.com/watch?v=z2RpnQAU1dY

If anyone's interested in our method:

We use both a gyro and accelerometer to balance our robot. The gyro is good at giving an accurate angular rate, but not absolute angle, while the accelerometer is good at giving an accurate absolute angle, but not angular rate. We decided to combine the best features of both these sensors to get the best control.

I don't want to release the entire code yet, but here's essentially how it works.
It uses a state machine to decide how to behave. The driver drives the robot slowly up the bridge until the gyro rate is greater than a certain amount in either direction, at which point the code takes control of driving. The robot then drives in the opposite direction until a second significant angular rate is detected. After this sequence, the accelerometer is read for an accurate angle reading. If it is determined that balancing failed, it restarts. If it determines it is balanced, it holds its position and waits for the gyro to return a significant rate allowing it to re-balance.
You should be able to see all of these steps from the video above.

We use closed loop control on the drive (with PID) to control the rate at which the robot drives up the ramp in order to keep consistency.

Our drivers have been very pleased with this feature. It has yet to fail. It almost always balances the robot on the first try. When it doesn't, it gets it on its second, as seen in the video. This method is much faster than when our drivers attempted it manually.

I'd be happy to answer any questions related to our method of balancing, PID, or the sensors we used. Good luck to anyone else attempting this!
__________________
Justin Yost
Systems Team
President
  #17   Spotlight this post!  
Unread 28-02-2012, 16:29
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: Gyro Autobalancing

Quote:
Originally Posted by Tom Line View Post
I was not aware that the competition bridges are calibrated with springs. I was under the impression that they use their own considerable weight and the off-center position of their hinges to effect their self centering. Can you please point me to the documentation that led you to this conclusion?

In addition, I believed that the bridges needed to be within 5 degrees of level to be balanced. Where did the 15 degrees come from? That is a considerable angle.
Hmm, maybe I'm assuming too much. I presumed springs were used, but I was wrong It is, in fact, a double hinge.

Quote:
2.2.5 The Bridges
Robots traverse the center of the Court by crossing over either one of three Bridges or the 4 in. tall by 6 in. wide, smooth steel Barriers running between them. Each Alliance has one dedicated Bridge for their use at end of their Alley. An additional white Coopertition Bridge is located at the center of the Court. Each Bridge is 48 in. wide, 88 in. long (outside dimensions), and sits with the top platform 12 in. high off the ground when level. Each Bridge is mounted on a double-hinge that allows the Bridge to tip towards either end of Court. The top surface of each bridge includes an array of 15 small holes, details of which are included in the official field drawings.

A Bridge will count as Balanced if it is within 5° of horizontal and all Robots touching it are fully supported by it.
There's the rule stating when the bridge is balanced. It was 5, not 15. Memory fails me again! I'll be doing more research next time I try to 'help' someone out
  #18   Spotlight this post!  
Unread 28-02-2012, 16:45
Luiz12 Luiz12 is offline
Registered User
FRC #4210
 
Join Date: Jan 2012
Location: South Gate
Posts: 45
Luiz12 is an unknown quantity at this point
Re: Gyro Autobalancing

Did I end up getting the PID structure correct...
  #19   Spotlight this post!  
Unread 28-02-2012, 21:16
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Gyro Autobalancing

Quote:
Originally Posted by Luiz12 View Post
So from what I understand is that I have to have a set point, which I assume would be zero since when the angle reaches zero
Yes, but it's a bit more complicated than that. Keep in mind that the gyro measures yaw (change in angle) around an axis through the gyro itself, but your robot does not balance around this axis; it balances on the bridge. You may have issues because the yaw rate is not directly proportional to the bridge angle.

Quote:
Originally Posted by Luiz12 View Post
basically from what I've read the only thing that I would need to tune would be the proportional gain.
As mentioned earlier, mechanical systems have momentum; for this reason, a proportional gain will almost always result in oscillation around the setpoint. Because of the double hinge setup for the bridge, however, it has a noticeable resistance to tipping, so an incredibly small P may allow you to successfully balance without tuning I or D, but your robot will be moving very slowly to the setpoint, which could possibly, depending on your wheels/drivetrain, be ineffective due to stalling or slipping. For a time-effective balancing mechanism, you will likely want to tune both P and I.

Searching the forums will yield a wealth of discussion on how to tune a PID loop; there are also a number of discussions about how to tune PI loops and ignore the D.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #20   Spotlight this post!  
Unread 28-02-2012, 21:25
Luiz12 Luiz12 is offline
Registered User
FRC #4210
 
Join Date: Jan 2012
Location: South Gate
Posts: 45
Luiz12 is an unknown quantity at this point
Re: Gyro Autobalancing

Well my plan was to just get the robot on the bridge on regular control, then press the button to begin the balancing then just let go of the button when its sufficiently balanced. Now for mounting the gyro it would be mounted vertically, not laying flat parallel to the floor right?
  #21   Spotlight this post!  
Unread 28-02-2012, 21:41
Ziv Ziv is offline
Has code to be writing...
FRC #0125 (Nutrons)
Team Role: Alumni
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Boston
Posts: 39
Ziv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of light
Re: Gyro Autobalancing

Quote:
Originally Posted by Luiz12 View Post
Well my plan was to just get the robot on the bridge on regular control, then press the button to begin the balancing then just let go of the button when its sufficiently balanced.
This is a good idea. It's good to give as much control as possible to the driver, making it his or her choice whether or not to use a particular feature in a particular situation. (For example, if another robot is pushing you up the ramp, you probably want to stay put.)

Quote:
Originally Posted by Luiz12 View Post
Now for mounting the gyro it would be mounted vertically, not laying flat parallel to the floor right?
Correct. The axis of rotation of the KOP gyro is perpendicular to the chip. For balancing, you probably want this axis to be parallel to the axels of your wheels, which means mounting it vertically.
  #22   Spotlight this post!  
Unread 28-02-2012, 22:23
Luiz12 Luiz12 is offline
Registered User
FRC #4210
 
Join Date: Jan 2012
Location: South Gate
Posts: 45
Luiz12 is an unknown quantity at this point
Re: Gyro Autobalancing

Now from what I read, I know to tune the PID I must start with zero values on I and D and then adjust the PID until it begins to oscillate ( which I assumes means the robot) then divide it by half. (from what I read on wikipedia) but do I increase the P or decrease, and in what increments should increase by? It then says,"Then increase Ki until any offset is corrected in sufficient time for the process" which I really don't understand. Do I adjust this if I see any lag or what does it mean?
  #23   Spotlight this post!  
Unread 28-02-2012, 22:33
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Gyro Autobalancing

Quote:
Originally Posted by Ziv View Post
This is a good idea. It's good to give as much control as possible to the driver, making it his or her choice whether or not to use a particular feature in a particular situation. (For example, if another robot is pushing you up the ramp, you probably want to stay put.)
I agree with this as well. With our method, we have the driver enable the balancing, but (while retaining driver control) the driver will drive the robot up the bridge until the robot senses a tip. Then, the robot will take control away from the driver and do the rest of the balancing itself.


Quote:
Originally Posted by Luiz12 View Post
It then says,"Then increase Ki until any offset is corrected in sufficient time for the process" which I really don't understand. Do I adjust this if I see any lag or what does it mean?
Basically, when you have Ki at zero, the system might take longer (than you want) to reach its setpoint. You use Ki in order to reduce this time. Think of the error accumulating over time and getting factored in. Therefore, the longer the system has had a nonzero error, the bigger the value the Ki term acts on is.

With that base, I don't really use a set system to tune Ki. I just usually start with a very small value (like around 0.01) and test it out. From there, if you watch your system and how long it takes to reach its setpoint, and determine how Ki should be changed. I usually tweak numbers by a factor of 2 or by a factor of 10 (depending on how much I think needs to be adjusted) and go from there.

tl;dr: Tune PID constants by guessing and checking until you get something satisfactory.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
  #24   Spotlight this post!  
Unread 28-02-2012, 22:44
Luiz12 Luiz12 is offline
Registered User
FRC #4210
 
Join Date: Jan 2012
Location: South Gate
Posts: 45
Luiz12 is an unknown quantity at this point
Re: Gyro Autobalancing

My P value by default is at 1. Should I leave it like this or start from .01. or should I start from 1 and then increase by .01.
  #25   Spotlight this post!  
Unread 28-02-2012, 22:45
slijin's Avatar
slijin slijin is offline
Pockets
AKA: Samuel Lijin
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York City
Posts: 537
slijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to beholdslijin is a splendid one to behold
Re: Gyro Autobalancing

Quote:
Originally Posted by Luiz12 View Post
Now from what I read, I know to tune the PID I must start with zero values on I and D and then adjust the PID until it begins to oscillate ( which I assumes means the robot) then divide it by half. (from what I read on wikipedia) but do I increase the P or decrease, and in what increments should increase by? It then says,"Then increase Ki until any offset is corrected in sufficient time for the process" which I really don't understand. Do I adjust this if I see any lag or what does it mean?
You may want to look into reading this paper instead of Wikipedia.

Ki is the integration coefficient; that is, the I function of the PID controller integrates, i.e. accumulates, your error (how far you are from the setpoint), and allows you to correct for error that has accumulated as a result of oscillation from tuning P alone.

-edit- There's no definitive answer; it's almost wholly experimental, especially because the return rate of the gyro doesn't directly correlate with the "wobbling" of the bridge as you try to balance.
__________________

2010-12 CT Chairman's
2011 Galileo 5th seed
2010 NY Regional Winners
  #26   Spotlight this post!  
Unread 28-02-2012, 22:55
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Gyro Autobalancing

Quote:
Originally Posted by Luiz12 View Post
My P value by default is at 1. Should I leave it like this or start from .01. or should I start from 1 and then increase by .01.
This may come off as a terrible answer, but do what works. Start with the default values, and observe how they make your system react. Then, modify the values accordingly.
Do you need the system to correct more? Raise Kp.
Do you need the system to correct faster? Raise Ki.
Do you need the system to slow down as it approaches the setpoint? Raise Kd.
Those are some overly general descriptions, but they work well in a pinch (and they also work oppositely).

It will be very hard to give specifics on PID constants without knowing about the system it will be acting on, because sometimes small changes can have huge impacts. That's why PID tuning takes such a long time - it's a lot of guess and check work until it works in a way you like.

In the meantime, I suggest to you do some reading on PID controller theory/tuning theory. Also, try and understand how the math behind them works in as much depth as possible (look through source code - I know you can look through the PID VI in LabVIEW). If you can understand how and why a PID controller works, it becomes that much easier to make one do your bidding.

Some other links to read when you have time (in no particular order. I like this one because NI is awesome and does a great job with their tutorials and support).
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android
  #27   Spotlight this post!  
Unread 03-03-2012, 10:39
uofifox uofifox is offline
Registered User
FRC #2202
 
Join Date: Oct 2011
Location: Wisconsin
Posts: 2
uofifox is an unknown quantity at this point
Re: Gyro Autobalancing

I have a question about your use of PID. What are you using for error computation? I mean if you're using accelerometer and gyro, are you simply using them to determine change occurs and using hte accelerometer to determine if you're close or closer to being level to determine your error?
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:00.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi