Using a joystick or a gamepad in ROS
A joystick is an input device that can be used for controlling the movement of the cursor or a pointer on a computer device. However, with this device, we can perform or control a wide range of actions.
In this section, we will discuss how to interface the joystick device to the ROS framework and control a real or simulated robot. A wide range of joystick devices is available for use in several applications.
How to do it…
- Install the necessary packages and driver, before working with the joystick.
- To install these packages in Ubuntu, we have to execute the following command:
$ sudo apt-get install ros-kinetic-joystick-drivers
$ rosstack profile & rospack profile
- Download the
joystick_drivers
package from the repository and build the package from the source:
$ cd ~/catkin_ws/src $ git clone https://github.com/ros-drivers/joystick_drivers.git $ cd .. $ catkin_make
How it works…
After installing the packages, we will connect our joystick to the computer system...