Tag Archives: joystick

Control your robot with a joystick in ROS

In other tutorials, I showed how to get access to the joystick and how to code with that. In this tutorial, I’m  gonna show you how to do that without writing any line of code.

First, install the required packages:

Now call the following

 

This will publish the topic “/joy_node” which is type of “sensor_msgs/Joy

Now you need to create your favorite message from that, for instance, if you want to move your robot you need to create “Twist” and publish that over /cmd_vel. To do that, create a yaml file and call it “joystick_param.yaml”, then put the following in the file and save it:

 

 

 

 

Now load it to ROS param:

Then you can call joy_teleop.py, so it will check the values that you set into teleop and publish 

/chatter and /cmd_vel

Alternatively, you can just call the following which will do lines above at once:

 

read more:

joy, joy_teleop, teleop_twist_joy, teleop_example

Controlling your robot with joystick and reading data from it

First, install the necessary package:

make sure your joystick is working:

also, make sure your controller has correct permissions:

The permission on the last column must be rw, if it “–” like this:

then correct the permission:

run the Joy node and roscore:

The joystick data are being published under /joy topic. To see the data:

to use the joystick  in your code follow this guideline:

full code at my Github.