ROS 2 ros2_control hardware interface for the Astro differential-drive mobile robot.
Handles serial communication with a Teensy microcontroller and exposes velocity command and position/velocity state interfaces for both wheels.
- ROS 2 Humble
colconbuild toollibserial-dev
sudo apt install libserial-devInstall ROS 2 dependencies:
sudo apt install \
ros-humble-ros2-control \
ros-humble-ros2-controllers \
ros-humble-controller-manager \
ros-humble-robot-state-publisher \
ros-humble-joint-state-broadcaster \
ros-humble-diff-drive-controller \
ros-humble-rviz2# Create workspace (skip if you already have one)
mkdir -p ~/astro_hw_ws/src
cd ~/astro_hw_ws/src
# Clone the repository
git clone <repository-url> astro_hardware_interface
# Install remaining ROS dependencies
cd ~/astro_hw_ws
rosdep install --from-paths src --ignore-src -r -y
# Build
colcon build --packages-select astro_hardware_interface
# Source the workspace
source install/setup.bash- Connect the Teensy to the PC via USB. The default serial device is
/dev/ttyACM0at 115200 baud. - To use a different port, edit
description/ros2_control/astro.ros2_control.xacro. - Grant serial port access if needed:
sudo usermod -aG dialout $USER
# Log out and back in for the change to take effectros2 launch astro_hardware_interface view_robot.launch.pyros2 launch astro_hardware_interface astro_hardware.launch.pyThis starts:
ros2_control_nodewith the Astro hardware interfacerobot_state_publisherjoint_state_broadcasterastro_diff_drive_controller- RViz
ros2 control list_hardware_interfacesExpected output:
command interfaces
left_wheel_joint/velocity [available] [claimed]
right_wheel_joint/velocity [available] [claimed]
state interfaces
left_wheel_joint/position
left_wheel_joint/velocity
right_wheel_joint/position
right_wheel_joint/velocity
ros2 control list_controllersExpected output:
astro_diff_drive_controller[diff_drive_controller/DiffDriveController] active
joint_state_broadcaster[joint_state_broadcaster/JointStateBroadcaster] active
ros2 topic pub --rate 30 /astro_diff_drive_controller/cmd_vel_unstamped geometry_msgs/msg/Twist "{
linear: {x: 0.5, y: 0.0, z: 0.0},
angular: {x: 0.0, y: 0.0, z: 0.5}
}"The robot accepts:
linear.x— forward/backward velocity (m/s), max ±1.0 m/sangular.z— rotational velocity (rad/s), max ±1.0 rad/s
astro_hardware_interface/
├── hardware/
│ ├── astro_interface.cpp # Hardware interface implementation
│ └── include/astro_hardware_interface/
│ ├── astro_interface.hpp # AstroHardware class
│ ├── teensy_comms.hpp # Serial communication with Teensy
│ └── wheel.hpp # Wheel state/command data
├── bringup/
│ ├── launch/astro_hardware.launch.py
│ └── config/astro_controllers.yaml
├── description/
│ ├── launch/view_robot.launch.py
│ ├── urdf/ # Robot URDF/xacro model
│ ├── ros2_control/ # ros2_control hardware config
│ └── rviz/ # RViz configurations
└── astro_hardware_interface.xml # pluginlib plugin description
| Parameter | Value |
|---|---|
| Wheel separation | 0.304 m |
| Wheel radius | 0.036 m |
| Serial device | /dev/ttyACM0 |
| Baud rate | 115200 |
| Control loop rate | 30 Hz |
| Encoder counts/rev | 3436 |