Go to Post It's official: we've run out of things to talk about. - Jessica Boucher [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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.
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
CAN Jaguar Enable Control .vi Initial Encoder Position TonyP CAN 0 26-02-2010 19:23
CAN Position control code? taichichuan C/C++ 8 13-02-2010 11:46
Position Control using potentiometer? biojae CAN 13 03-02-2010 20:12
Antenna position Torboticsmember Rules/Strategy 2 16-02-2008 11:18
Which position is A vs. C MattB703 Rules/Strategy 3 29-03-2006 08:56


All times are GMT -5. The time now is 03:35.

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