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.
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.
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 each package before running it. For example, to build the differential drive controller:
cd ros2_control_hardware_differential_drive_controller
colcon build
Before running any demo, ensure the shell scripts have execute permissions:
chmod +x replace_with_your_sh_file.sh
This demo configures two motors in CSV (Cyclic Synchronous Velocity) mode to act as the wheels of a differential drive robot.
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
This demo configures two motors in CSP (Cyclic Synchronous Position) mode to act as joints for a robotic arm.
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
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
Zijian Ge