View Single Post
  #12   Spotlight this post!  
Unread 07-04-2008, 10:30
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,513
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: Accurately "Arcing" in Auton/Hybrid Mode

In our case, what looks a lot like a smooth turn isn't really programmed like one.

Our drive statement looks like this:

left_drive = 127 + drive_straight(total_distance) + turn(angle_desired);
right_drive = 127 + drive_straight(total_distance) - turn(angle_desired);

Here is how it works. Drive_straight is a pid loop that will drive to a "distance". Generally speaking we put something like 100 feet into it this year, because we don't really want to ever stop.

So, generally speaking, you could simplify our drive formulas to this:

left_drive = 254 + turn(angle_desired);
right_drive = 254 - turn(angle_desired);

We use a 300 degree/sec gyro in the turn function. It is a simple PID loop. It can output -254 to +254. We send it "turn 90 degrees" and it calculates the amount to modify the drive values.

This results in one side (the right side) always driving full forward. Because Kevin's gyro code measures any angle to the "left" of zero as a negative, our right drive ends up being right_drive = 254 - (-xxx) which results in right_drive = 254 + xxx. At the end of our loop, we have a sanity check that says
if right_drive > 254
right_drive = 254;
else if right_drive < 0
right_drive = 0;
We have the same for the left.

So our right_drive is pretty much ALWAYS 254. Our left drive is modified by the amount we want to turn.

All this results in a final "turn left 90 degrees" command resulting in a nice smooth curve for example:
left_drive = 200;
right_drive = 254;

or a very sharp "left":
left_drive = 127;
right_drive = 254;

depending on the gain that we're using at the time in the turn routine. The gain is determined by looking at where we think we are on the field.

Oh - and we also used a side sensor that looks for the end of the wall, OR robots, so we go past them before we start our turn. We also used a sensor in front (which I think a lot more robots out there this year should have used) that stops our robot if something is within a couple inches in front of us. That resulted in a lot of "saved" opponent robots when we came around the corner and there was someone that smacked into the center wall blocking our way. It also prevented us from backing head-on into the alliance walls or the center divider if someone managed to spin our robot around.

Last edited by Tom Line : 07-04-2008 at 10:35.