Converting X,Y mouse positions to skid seering commands
For quick demonstrations/easy testing of hardware, i am trying to write a pygame interface to a skid steering robot.
I am at the point where i have a control screen with a center, and the x,y position of the cursor relative to that. I can determine whether overall it should be going straight, left, or right, forwards or backwards depending on the mouse position with the vertical axis being "overall forward motion" but i want to use the horizontal axis to determine the left/right split, with the total "forwards motion" available from the verticle axis being split left/right by how far the values of the horizontal axis are from center
I am sure this sort of thing has been done before - does anybody have some pointers?
UPDATE:
Thanks for the help everybody - i seem to have gotten it sorted - i am sure it could be prettier though.The code should be pretty obvious - i made some changes to make it easier to drive the TReX - it now checks for negative values, and sets a flag for that motor to reverse, and then flips the value to positive. this is the sort of data the trex is expecting.
It is hard to do a complete test currently due to the speed of the robot and the length of my USB cable. Next up will be IP connectivity between a pygame/wxwidgets client running on a netbook, connecting to a python server running on the robot's netbook, interfacing with the TReX motor controller and a Polou servo controller. Also, i found a simple bit of c code to allow easy reading of linux's mouse device inputs for X,Y positioning
http://jwr.d2p.com.au/robobot/| Attachment | Size |
|---|---|
| pygamesteering.py_.txt | 4.17 KB |



@ Tue, 2009-05-19 18:14
Mixing X and Y
Forgot...
Here's how to mix your X and Y.
http://letsmakerobots.com/node/5358
@ Tue, 2009-05-19 18:06
Did it...
I have done it with processing but I'm sure your code will be similar.
http://letsmakerobots.com/node/7044
--Bear in mind that the "X" criss-crossing the control window is just for a visual representation to the user, it has no bearng on the code. As the curser moves away from the center (Center being off, like a joystick) speed is increased on the relavent motor. I can't remember if I did my X/Y mixing in Processing or in the robot. Final drive on the 'bot is via PWM signals from a picaxe 40x2.
@ Tue, 2009-05-19 15:05
If the mouse is left of
@ Tue, 2009-05-19 15:37
I have made the changes, all
@ Tue, 2009-05-19 15:10
Cheers! The ideas i had
Cheers!
The ideas i had going through my head were more of a "determine the current left/right ratio and apply that to the throttle value" with some trig thrown in. You laid out a way to do what i need perfectly, thankyou!