Skip to content

Repository files navigation

Control Physical Servo Motors using ROS2 Controllers

This repository demonstrates the integration of IPE servo motors with the ROS2 control framework. It implements a custom EtherCAT master using the SOEM library to initialize, communicate with, and control the motors.

Screenshot from 2025-10-11 15-07-12

Overview

This project provides practical examples of using standard ros2_control controllers to manage real hardware. It includes two distinct demos, each showcasing a different control paradigm:

Differential Drive Controller: Treats two servo motors as wheels for a mobile robot.

Joint Trajectory Controller: Treats two servo motors as joints of a robotic arm.

SOEM Package Setup

The SOEM package is only included in the joint_trajectory_controller directory but is required for both demos.

Before running the differential drive controller, copy the SOEM package to the corresponding hardware directory:

 cp -r ros2_control_hardware_joint_trajectory_controller/src/my_robot_hardware/SOEM \
       ros2_control_hardware_differential_drive_controller/src/my_robot_hardware/

Build the Workspace

Build each package before running it. For example, to build the differential drive controller:

  cd ros2_control_hardware_differential_drive_controller
  colcon build

Demos

Before running any demo, ensure the shell scripts have execute permissions:

 chmod +x replace_with_your_sh_file.sh

1. Differential Drive Controller

This demo configures two motors in CSV (Cyclic Synchronous Velocity) mode to act as the wheels of a differential drive robot.

Usage:

Launch the demo (this will start RViz and activate the motors):

 ./run_ipe_ros2_control.sh

This script automatically sources the necessary ROS 2 setup files, grants sudo permissions to the EtherCAT master, and launches the main control node.

To control the robot using your keyboard, open a new terminal and run:

 ./run_ipe_ros2_control.sh

2. Joint Trajectory Controller

This demo configures two motors in CSP (Cyclic Synchronous Position) mode to act as joints for a robotic arm.

Usage:

Launch the demo (this will start RViz and activate the motors):

 ./run_ipe_ros2_control.sh

To send a pre-defined trajectory goal to the joints, run:

 ./send_trajectory.sh

Customizing the Trajectory

To modify the goal positions, edit the test_joint_trajectory.py script. All controller parameters (e.g., PID gains, state publishing rates) are defined in the my_robot_controllers.yaml file. You can modify or add parameters in this file based on your hardware requirements.

The configuration follows the official ros2_controllers structure. For reference, please see:

https://github.com/ros-controls/ros2_controllers/tree/master

Author

Zijian Ge

About

Hardware (IPE servo motors) ) communicates with the ROS 2 control framework

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages