Advanced guides

Steering the Rover with a joystick


In this example, we will create a simple package that will let you control the Rover using a joystick connected to your computer.

We will use two nodes that are available in the ROS distribution:

  • joy_node (from joy package) - for getting input from the joystick and publishing it on a topic.
  • teleop_node (from teleop_twist_joy package) - for getting messages from the joystick topic and publishing corresponding steering commands to the Rover.

We assume that you have already created a workspace like in the previous example.

Start by creating an empty package with the specified dependencies:

You might need to install dependent packages first:

Now, add launch/ and config/ directories inside your package:

Inside launch/ directory, add the joy.launch file with the following content:

Inside config/ directory, add the joy_mapping.yaml file:

Now, build the package:

Before you start your launch file, you might need to remap axes and buttons to suit the joystick you have. Start joy_node by typing:

And on another terminal, run:

Move the axes you want to use for the linear and angular movements of the Rover and check which values are being changed on axes[] array (remember that the values are indexed from 0).

Choose the button that will be used to enable the command publishing. Check which value is being changed on the buttons[] array when you click the button.

Now, change the axis_linear , axis_angular, enable_button parameters in joy_mapping.yaml file.

Close the joy_node and start your the joy.launch file:

You should now be able to steer the Rover by holding down the enable button and moving the joy axes you set.


Need help? Contact us - contact@fictionlab.pl