|
Interfacing Windows Joystick to RoboRealm? No0bert from United States [11 posts] |
16 year
|
I haven't found anything on this but here is my setup:
Motors->Sabertooth 2x25->TTL->USB->Roborealm
I am using a PS2 controller, but I am sure that makes no difference as long as it is recognizable as a PaP USB Windows Controller
Is there a way to control said motors with a windows Joystick in the RoboRealm program?
How so?
|
|
|
Anonymous |
16 year
|
|
|
Anonymous from United Kingdom [99 posts] |
16 year
|
Briefly:
Import the joystick module and make sure that you are receiving commands from the joystick. (If not, then check using the windows joystick control) In my experience, anything that works in one, works in the other.
Now Write a bit of VBscript that maps the joystick commands to the motion commands of the motors: Here is a possible bit:
joystick_x = GetVariable("JOYSTICK_X")
joystick_y = GetVariable("JOYSTICK_Y")
if joystick_x > 200 then
motor_left = 200
end if
if joystick_x < -200 then
motor_output = abs(int(joystick_x/4)+5)&"A"
end if
if joystick_y > 200 then
motor_output = abs(int(joystick_y/4)-5)&"X"
end if
if joystick_y < -200 then
motor_output = abs(int(joystick_y/4)+5)&"W"
end if
if abs(joystick_x)< 100 and abs(joystick_y) < 100 then
motor_output = "S"
end if
SetVariable("MOTOR_OUTPUT"),motor_output
Note, I am not using a sabertooth in this code (Instead a serial PID controller) You will want to replace the motor_output = ......
with
left_motor = 200
right _ motor = 200
etc. At the end you will need to use SetVariable for both motors IE
SetVariable("LEFT_MOTOR"),left_motor
SetVariable("RIGHT_MOTOR"),right_motor
Last thing is to setup the Sabertooth control to use those two values (LEFT_MOTOR) and (RIGHT_MOTOR) to control the two motors on your bot. You will need to do some experimentation to find the optimal values to make it go left, right etc. If you are using an analog stick, you will probably want to use some sort of analog control.
I am including a robo file for controlling a robot over the serial port using the joystick.
have fun,
profmason
program.robo
|
|
|
No0bert from United States [11 posts] |
16 year
|
Thanks mate!
Do I have to use a COM emulator?
I haven't yet received my SLA batteries to power this whole thing, so I have yet to try
|
|
|
Anonymous from United Kingdom [99 posts] |
16 year
|
|
|
No0bert from United States [11 posts] |
16 year
|
I know what a USB-TTL cable is, I already made one, and it works, but do I need a COM emulator to use with RoboRealm?
|
|
|
Anonymous |
16 year
|
Yes, you would need the driver for the USB-TTL cable ... i.e. something like
http://www.ftdichip.com/FTDrivers.htm
if it uses that chip. Once installed it will appear like a COM port but will actually be a virtualized one. Not unlike a USB-Serial type cable.
STeven.
|
|
|
Greg Karp from United States [1 posts] |
15 year
|
Thank you for providing this information, this article is very helpful!
Does anyone know if this configuration would work with a playstation like controller, such as a logitech gamepad or something similar? I assume I would have to use the joystick module to figure out what each button controls and affects.
Any help would be greatly appreciated!
Thanks!
Greg
|
|
|
Anonymous |
15 year
|
Greg,
It will largely depend on how windows deal with that controller. We also use the Saiteck Pad with good success ... but we're not sure how that relates to what you have.
And, yes, the joystick module would be the thing to test with that joystick.
STeven.
|
|
|
Anonymous |
15 year
|
I have used a generic game pad and a logitech cordless rumble pad. Basically anything that windows recognizes as a joystick will work. BTW the cordless rumble pads are a great way to remote control your robotics projects.
have fun,
mmason
|
|