Society of Robots - Robot Forum

Software => Software => Topic started by: Sylvestre on January 14, 2012, 06:25:15 PM

Title: Using a Joystick to Control a Robot
Post by: Sylvestre on January 14, 2012, 06:25:15 PM
Hey everyone,

I am thinking of using a joystick such as one in the link below to control my rescue robot.  If I used this, I would just have it connected (Usb obviously) to the laptop I'm controlling the robot from.

How difficult would it be to program something like this?  Would someone who has done this before care to share some example code? (preferably in C)
http://www.amazon.com/Logitech-Extreme-Joystick-Silver-Black/dp/B00009OY9U/ref=sr_1_4?ie=UTF8&qid=1326586764&sr=8-4 (http://www.amazon.com/Logitech-Extreme-Joystick-Silver-Black/dp/B00009OY9U/ref=sr_1_4?ie=UTF8&qid=1326586764&sr=8-4)
Title: Re: Using a Joystick to Control a Robot
Post by: Redcap on January 15, 2012, 08:53:57 PM
I'll be the first to admit I don't know a great deal about joysticks, but to get the replies started...

Most joysticks I've seen have a setup interface where you can define which each movement/button press should be such as tilt to the left = left arrow, "fire" button = spacebar etc.

I'm only assuming, but from there it may just be a case of having the code look for a press of the left arrow key, which (I assume) would also see the Joystick being tilted to the left as this key being pressed. etc

Hopefully someone with more experience with this comes along very soon to enlighten us both ;)
Title: Re: Using a Joystick to Control a Robot
Post by: Sylvestre on February 12, 2012, 12:13:33 AM
ok thanks for the information!  Yeah hopefully helps us out.
Title: Re: Using a Joystick to Control a Robot
Post by: Daanii on February 16, 2012, 12:47:15 AM
What operating system are you using? If you use Windows, the thing I use is DirectInput. You can then get a value from the various axes and buttons on the joystick.

How will you send signals to your robot from the laptop?

I have some code that might be helpful, if you are using Windows.
Title: Re: Using a Joystick to Control a Robot
Post by: Resilient on February 16, 2012, 02:15:55 AM
If you want something cross platform check out SDL

http://www.libsdl.org/ (http://www.libsdl.org/)
Title: Re: Using a Joystick to Control a Robot
Post by: Sylvestre on August 26, 2012, 11:38:15 PM
I need to revisit this topic.  Sorry for my delayed response.  Now to the answers of your questions.

Quote
What operating system are you using? If you use Windows, the thing I use is DirectInput. You can then get a value from the various axes and buttons on the joystick.

I am using Windows.

Quote
How will you send signals to your robot from the laptop?

Serial communication.


I'll check out both SDL and DirectInput.  Thanks for the response