dual_motor_sync.mp4
Dual‑motor synchronous motion demo
ROS 2 package for precise synchronous control of two Robstride Dynamics RS03 motors over CAN bus.
For high‑load robotic mechanisms, a single actuator often cannot deliver sufficient torque, so dual mirrored‑motor configurations are widely adopted to share joint loads. Without precise synchronization, discrepancies caused by friction, transmission backlash and timing jitter introduce internal mechanical stress, torsion or even hardware damage.
dual_motor_sync is a ROS2 C++ package for dual‑motor mirrored synchronization over CAN bus. It uses cosine trajectory planning and 500 Hz back‑to‑back CAN frame transmission. Fully configurable via command‑line arguments, it achieves synchronization error down to 0.01°. Torque‑interruption is eliminated for seamless successive motion sequences.
- Achieves synchronization error as low as 0.01°.
- Point-to-point motion with smooth cosine trajectory (zero velocity at start/end)
- Sine wave swing with configurable amplitude, period, and duration
- Real-time position and sync error feedback
- Mirror motion: motor ID 3 positive, motor ID 4 negative
Motors run in MIT mode (PD torque loop). Instead of sending target directly (which causes uncontrolled speed via kp×error), this package generates a time-parameterized cosine trajectory and sends the current point every 2ms. Speed is controlled by duration, while kp/kd only control tracking accuracy.
- Ubuntu22.04(x86_64) + ROS2 Humble
- 2× Robstride RS03
- Power Supply 48V DC
- CAN Adapter(CANdle / gs_usb compatible device)
colcon build && source install/setup.bash
ros2 run dual_motor_sync sync_motor_client angle=60 time=1.0 kp=150 kd=10 hold=false can=can2 id=3 4
ros2 run dual_motor_sync sine_swing amplitude=30 period=2 duration=10- Only one control program at a time: Never run
sync_motor_clientandsine_swingsimultaneously. Both open CAN sockets for the same motor IDs will cause bus conflicts and stale frames. - Zero position before sine swing:
sine_swingoscillates around the zero position. Ensure both motors are at zero (or near zero) before running it, otherwise the command will pull the motors to zero very abruptly, which is dangerous and may cause unexpected result - Hold parameter:
hold=truekeeps motors enabled after motion;hold=falsedisables them automatically. - Parameters modification: For sync_motor_client, Kp, Kd, can channel, CAN ID, angle, motion time, and hold can be adjusted according to your needs. For sine_swing_node, Kp, Kd, can channel, CAN ID, amplitude, period, duration and mirror can be adjusted according to your needs.
- Default parameter value: For sync_motor_client, angle=60, time=2.0, kp=100, kd=10, hold=true, can=can2, id=3 4. For sine_swing_node, amplitude=30, period=2.0, duration=10, kp=100, kd=10, mirror=true, can=can2, id=3 4
Robstride Dynamics: https://github.com/RobStride/robstride_ros_sample