In this example, we will create a simple package that will let you control Leo Rover using a joystick connected to your computer.
We will use two nodes that are available in the ROS distribution:
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 Leo 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 Leo Rover by holding down the enable button and moving the joy axes you set.