ROS 2 node for Raspberry Pi Mouse, built on raspimouse_python_driver.
raspimouse_python_ros2: the node (topics, service, actions)raspimouse_python_msgs: the action definitions
This is an unofficial package developed by volunteers. Topic names and types follow the official rt-net/raspimouse2.
- Raspberry Pi 4 with Ubuntu 24.04 and ROS 2 Jazzy
- The setup of raspimouse_python_driver (config.txt, udev rule)
sudo apt install python3-vcstool python3-colcon-common-extensions python3-rosdepmkdir -p ~/ros2_ws/src && cd ~/ros2_ws/src
git clone https://github.com/YusukeKato/raspimouse_python_ros2.git
vcs import < raspimouse_python_ros2/raspimouse_python_ros2.reposcd ~/ros2_ws
rosdep install --from-paths src -y --ignore-src
colcon buildsource ~/ros2_ws/install/setup.bash
ros2 launch raspimouse_python_ros2 raspimouse.launch.pyTurn on the motor power and drive forward at 0.15 m/s:
ros2 service call /motor_power std_srvs/srv/SetBool "{data: true}"ros2 topic pub -r 10 /cmd_vel geometry_msgs/msg/TwistStamped "{twist: {linear: {x: 0.15}}}"The robot stops when cmd_vel stops for cmd_vel_timeout (0.5 s).
Drive 0.3 m forward at 0.15 m/s, then turn 90 degrees to the left, and stop at the targets:
ros2 action send_goal --feedback /drive_distance raspimouse_python_msgs/action/DriveDistance "{distance: 0.3, speed: 0.15}"ros2 action send_goal --feedback /rotate raspimouse_python_msgs/action/Rotate "{angle: 1.5708, angular_speed: 3.14}"Goals are rejected while the motor power is off or another goal runs; cmd_vel is ignored while a goal runs.
To try the node on a PC without the robot, add use_mock_backend:=true to the launch command.
| Name | Type | |
|---|---|---|
cmd_vel |
geometry_msgs/TwistStamped (Twist with use_stamped_cmd_vel: false) |
subscribed |
leds |
raspimouse_msgs/Leds | subscribed |
buzzer |
std_msgs/Int16 (Hz, 0 stops) | subscribed |
motor_power |
std_srvs/SetBool | service |
drive_distance |
raspimouse_python_msgs/DriveDistance (distance [m], speed [m/s]) | action |
rotate |
raspimouse_python_msgs/Rotate (angle [rad], angular_speed [rad/s]) | action |
odom |
nav_msgs/Odometry, and TF odom -> base_footprint |
published |
light_sensors |
raspimouse_msgs/LightSensors | published |
switches |
raspimouse_msgs/Switches | published |
battery |
sensor_msgs/BatteryState (voltage only) | published |
Parameters and their defaults: config/raspimouse.yaml.
cd ~/ros2_ws
colcon test --packages-select raspimouse_python_ros2
colcon test-result --verbose