Translational Drive Code

How can we code translational drive off of one joystick? Right now all I can think of is to use and inverse tangent, which obviously isn’t possible. Using inverse tanget it would be (for the first quadrant):

tan-1 (p1_y/p1_x) 'then code torotate it using timing or rotation sensor
pwm1=p1_y
pwm2=p1_y
pwm2=p1_y
pwm4=p1_y 'all the motors go forward/backward now that the angle is set, based on how far the drive moved p1_y

Any ideas?

If you don’t need the code to cycle really fast, you might try something that will do a select (100 * p1_y / p1_x) and try 0 to 10 and 10 to 20 etc. Negatives will hurt, though. Just a whole lot of ifs to approximate a function.

For the ignorant…what’s translational drive?

Tranlational drive is when all the wheels on your robot turn towards the same direction, instead of turning the whole robot. If you do not need to rotate the robot, this makes changing direction much faster. Unless you build in a way to turn, the robot will always stay facing the same direction unless it is bumped.

-Damian Manda

Use your trig identities, friend.

It’s taken me awhile, but I finally found the link I was looking for. There’s some example swerve-drive code over at http://www.first-codex.net, under 2002 code in the Repository. It’s called something like “Pegasus”. Should be a good starting point, even if it is the old 2.0 syntax.

–Rob

Adam, we (226) created the pegasus code last year using some inverse trig approximations to get the vector of the joystick which I think you were looking for, if you can’t find it on the Codex PM me and I will send it to. It is posted to give other teams a start

OK, we figured it out - and far more acurately than the pegasus code (natururally, there is the trade off of program space, but it actually takes up less variable space than their’s).

Basically, we devided the joystick up into octants, than used a taylor approximation on the inverse sine, and decided the power and direction by quadrant using some modified x>y if statements.

If you would like the code, e-mail me.