|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
||||
|
||||
|
For the ignorant.....what's translational drive?
|
|
#4
|
|||||
|
|||||
|
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 |
|
#5
|
||||
|
||||
|
Use your trig identities, friend.
|
|
#6
|
||||||
|
||||||
|
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 |
|
#7
|
|||||
|
|||||
|
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
|
|
#8
|
|||
|
|||
|
YEA!
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is your most prefered programming language? | Hailfire | Programming | 156 | 19-01-2005 21:42 |
| 1 stick drive to 2 stick drive | wayne 05 | Programming | 18 | 01-04-2004 16:41 |
| Direct drive or Chain? | Suneet | Technical Discussion | 32 | 27-03-2003 23:00 |
| TechnoKats Automated Test Drive Code | Greg McCoy | Programming | 1 | 16-01-2003 17:45 |
| "Motors and Drive train edition" of Fresh From the Forum | Ken Leung | CD Forum Support | 6 | 29-01-2002 12:32 |