eRob Master is a ROS 2-based CANopen motor controller used to control motors that support the CANopen protocol via CAN bus. This controller supports position and velocity control, and provides a series of ROS 2 interfaces for motor monitoring and control.
- CANopen protocol communication support
- Position and velocity control support
- ROS 2 topics and service interfaces
- Real-time monitoring of motor status, position, and velocity
- Support for motor initialization, start, stop, and reset
- Profile parameter settings support (velocity, acceleration, deceleration)
- ROS 2 (Humble or higher version recommended)
- CAN interface (e.g., Socket-CAN adapter)
- Motors supporting CANopen protocol
-
Clone repository
git clone git@github.com:ZeroErrControl/eRob_CANopen_Linux.git
-
Build
cd ~/eRob_CANopen_Linux colcon build
-
Launch node
source install/setup.bash ros2 launch erob_master canopen_ros2.launch.py
sudo modprobe can
sudo modprobe can_rawsudo ip link set can0 type can bitrate 1000000
sudo ip link set up can0ip -details link show can0Launch with default parameters
ros2 launch erob_master canopen_ros2.launch.pyros2 launch erob_master canopen_ros2.launch.py can_interface:=can0 node_id:=2 auto_start:=trueControl motor position by publishing to /target_position topic:
- Move to 90 degrees
ros2 topic pub /target_position std_msgs/msg/Float32 "data: 90.0" --once- Move to 180 degrees
ros2 topic pub /target_position std_msgs/msg/Float32 "data: 180.0" --onceControl motor velocity by publishing to /target_velocity topic:
- Set velocity to 10 degrees/second
ros2 topic pub /target_velocity std_msgs/msg/Float32 "data: 10.0" --once- Set velocity to -10 degrees/second
ros2 topic pub /target_velocity std_msgs/msg/Float32 "data: -10.0" --onceros2 service call /start_erob std_srvs/srv/Triggerros2 service call /stop_erob std_srvs/srv/Triggerros2 service call /reset_erob std_srvs/srv/Trigger- Set to position mode
ros2 service call /set_erob_mode std_srvs/srv/SetBool "data: true"- Set to velocity mode
ros2 service call /set_erob_mode std_srvs/srv/SetBool "data: false"ros2 topic echo /erob_statusros2 topic echo /erob_positionros2 topic echo /erob_velocity| Topic Name | Message Type | Description |
|---|---|---|
| /target_position | std_msgs/msg/Float32 | Set target position (degrees) |
| /target_velocity | std_msgs/msg/Float32 | Set target velocity (degrees/second) |
| /erob_status | std_msgs/msg/String | Motor status information |
| /erob_position | std_msgs/msg/Float32 | Current position (degrees) |
| /erob_velocity | std_msgs/msg/Float32 | Current velocity (degrees/second) |
| Service Name | Service Type | Description |
|---|---|---|
| /start_erob | std_srvs/srv/Trigger | Start motor |
| /stop_erob | std_srvs/srv/Trigger | Stop motor |
| /reset_erob | std_srvs/srv/Trigger | Reset motor |
| /set_erob_mode | std_srvs/srv/SetBool | Set motor mode (true: position mode, false: velocity mode) |
| Parameter Name | Type | Default Value | Description |
|---|---|---|---|
| can_interface | string | "can0" | CAN interface name |
| node_id | int | 2 | CANopen node ID |
| auto_start | bool | true | Whether to auto-start motor |
| profile_velocity | int | 5 | Profile velocity (degrees/second) |
| profile_acceleration | int | 5 | Profile acceleration (degrees/second²) |
| profile_deceleration | int | 5 | Profile deceleration (degrees/second²) |
- Check if CAN interface is properly configured: ip -details link show can0
- Ensure CAN interface is up: sudo ip link set up can0
- Verify CAN bus connections are correct
- Check if motor power is connected
- Confirm node ID is correct
- Monitor CAN bus communication using candump: candump can0
- Check motor status: ros2 topic echo /erob_status
- Some motors may not support standard CiA402 operation mode switching. In this case, the controller will attempt to work in the current mode.
- Using candump to monitor CAN communication Install can-utils
sudo apt-get install can-utilscandump can0Apache License 2.0