Skip to main content

Steering Leo Rover with a joystick

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


📄Connect via SSH
Learn how to establish an SSH connection with your Leo Rover and access its terminal using Putty or OpenSSH.
📄ROS Development
Detailed guide on ROS development for Leo Rover, covering topics like adding additional functionalities, building ROS packages and more.


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:

cd ~/ros_ws/src
catkin create pkg leo_joy_example --catkin-deps joy teleop_twist_joy

You might need to install dependent packages first:

cd ~/ros_ws
rosdep update
rosdep install --from-paths src -i

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

cd ~/ros_ws/src/leo_joy_example
mkdir launch config

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

<arg name="cmd_vel_topic" default="cmd_vel"/>

<node name="joy_node" pkg="joy" type="joy_node">
<param name="dev" value="/dev/input/js0"/>
<param name="coalesce_interval" value="0.02"/>
<param name="autorepeat_rate" value="30.0"/>

<node name="teleop_node" pkg="teleop_twist_joy" type="teleop_node">
<rosparam command="load" file="$(find leo_joy_example)/config/joy_mapping.yaml"/>
<remap from="cmd_vel" to="$(arg cmd_vel_topic)"/>

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

axis_linear: 1
scale_linear: 0.4
axis_angular: 3
scale_angular: 2.0
enable_button: 5

Now, build the package:

cd ~/ros_ws
catkin build
source devel/setup.bash

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:

rosrun joy joy_node

And on another terminal, run:

rostopic echo /joy

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:

roslaunch leo_joy_example joy.launch

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