View Single Post
  #1   Spotlight this post!  
Unread 04-03-2010, 21:40
biojae's Avatar
biojae biojae is offline
Likes Omni drives :)
AKA: Justin Stocking
FTC #5011 (BOT SQUAD) && FTC#72(Garage bots)&& FRC#0399 (Eagle Robotics)
Team Role: College Student
 
Join Date: Oct 2008
Rookie Year: 2008
Location: Lancaster
Posts: 276
biojae is a jewel in the roughbiojae is a jewel in the roughbiojae is a jewel in the rough
Position Control

Over the fall, I made a simple positioning system using simple Trig and geometry.
That was using the PWM open loop (On the Jaguar at least) voltage control. Now that we are allowed to use CAN, I would like to use the Position control mode. The encoders are hooked directly into the Jaguar.

The simple formulas that I used are as follows:
Code:
S = ((Delta Dist Rightside) + (Delta Dist Leftside)) / 2.0;
X += S * cos(theta);
Y += S * sin(theta);
Theta is from a 300 deg/sec yaw rate gyro.

So, once I had a new estimated position, the distance and angle to the next point were calculated.
The angle and distance would then go into 2 PID calculations.
Each side of the drive would then be set from a simple arcade drive function

Code:
double angle = MathUtils.atan2(pY-Y, pX-X);
double distance = Math.sqrt(Math.pow(pY-Y,2)+Math.pow(pX-X,2));

double leftSpeed  = speed + turn;
double rightSpeed = speed - turn;
That worked nicely, but now I would like to have the Jaguar handle some of the calcs and PID itself.

I would like to use the Jaguar's Position control, tell it how far to turn the wheel and it goes there.

One dimensional movement (forward / backward) is easy, as the distance to tell it is from the distance formula, but once it gets to rotation, I am lost.

From the above equations, I derived these equations:

Code:
Dist Left = sqrt((y-y1)^2 + (x-x1)^2) + (atan2(y-y1,x-x1) - theta1)
Dist Right = sqrt((y-y1)^2 + (x-x1)^2) - (atan2(y-y1,x-x1) - theta1)
would this work if the distance from each side were to be scaled to rotations? or did I make a mistake with my math?
__________________
FTC Team 72 - No site
FRC Team 399 - http://www.team399.org
2010 Rockwell Collins Innovation in Control Award - (Use of the CAN bus, among other reasons) Phoenix, Arizona!

Last edited by biojae : 04-03-2010 at 22:05.