Skip to content

About

ROS 2 node for Raspberry Pi Mouse

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

raspimouse_python_ros2

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.

Requirements

Build

sudo apt install python3-vcstool python3-colcon-common-extensions python3-rosdep
mkdir -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.repos
cd ~/ros2_ws
rosdep install --from-paths src -y --ignore-src
colcon build

Run

source ~/ros2_ws/install/setup.bash
ros2 launch raspimouse_python_ros2 raspimouse.launch.py

Turn 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.

Interfaces

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.

Test

cd ~/ros2_ws
colcon test --packages-select raspimouse_python_ros2
colcon test-result --verbose

License

MIT

About

ROS 2 node for Raspberry Pi Mouse

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages