This repository contains a ROS2 package that subscribes to joystick inputs and publishes corresponding velocity commands to the /cmd_vel topic.
Before using this package, you need to install ROS2. Please follow the official ROS2 installation guide: ROS2 Installation Guide
Ensure that you have the necessary ROS2 packages installed before running this repository. You can install them using the following commands:
sudo apt update
sudo apt install ros-humble-joy # Change 'humble' to your ROS2 distribution name if differentBefore running the package, verify that your joystick is detected by your system.
ls /dev/input/Look for a device like js0 (e.g., /dev/input/js0). If not detected, try reconnecting your joystick or installing necessary drivers.
jstest /dev/input/js0If the jstest command is not found, install joystick utilities:
sudo apt install joystickNavigate to your ROS2 workspace and clone this repository:
cd ~/ros2_ws/src
git clone https://github.com/Mehmetmrtgl/ros2_joystick.gitThen, build the package:
cd ~/ros2_ws
colcon build --packages-select joy_listener_cpp
source install/setup.bashTo launch the system and start listening to joystick inputs, run:
ros2 launch joy_listener_cpp start_system.launch.pyThis will start:
joy_node: Reads joystick inputs and publishes them to the/joytopic.joy_listener: Subscribes to/joyand publishes velocity commands to/cmd_vel.
To check if velocity commands are being published, open a new terminal and run:
ros2 topic echo /cmd_velYou should see messages updating when you move the joystick.
- If
joy_nodedoes not publish messages, ensure that your joystick is properly detected andjstestworks. - If
cmd_velmessages are not appearing, check thatjoy_listeneris running. - Source the workspace if required:
source install/setup.bash
Feel free to open issues or submit pull requests if you find any bugs or want to improve this repository.