This repository implements the use of different ROS2 packages to control a CANopen-based robot in a simulated environment.
- Docker (tested with version 24.0.6)
- Docker Compose (tested with version v2.21.0)
git clone --recurse-submodules git://github.com:lucasmluza/ros2_moveit_canopen_example.git
docker compose build
For creating and starting the container:
docker compose up
For executing commands in the container:
docker compose exec ros2_humble [command]
A simple approach is to run bash on the container, that will start interactively since the compose.yaml set the tty
and stdin_open
to true.
docker compose exec ros2_humble bash
First, install de dependencies with rosdep. In ~/ws_ros
:
1 - Update the apt repositories
sudo apt update
2 - Initialize rosdep
sudo rosdep init && rosdep update
3 - Install dependencies
rosdep install -i --from-paths src -y
In ~/ws_ros
:
colcon build
And, do not forget to source the install/setup.bash
after compiling.
In ~/ws_ros
:
source install/setup.bash
For visualize the robot and control the joints position with a GUI app:
ros2 launch panda_rviz_viewer view.launch.py
For controlling the robots joints with ROS2 services:
ros2 launch panda_canopen simulation.launch.py
Then, in a second bash instance of the container, the joints can be controlled by the exposed services. Examples:
- Initialize a joint:
ros2 service call /panda_joint1/init std_srvs/srv/Trigger
- Set the operation mode to
Profile Position Mode
:ros2 service call /panda_joint1/position_mode std_srvs/srv/Trigger
- Set a target position value:
ros2 service call /panda_joint1/target canopen_interfaces/srv/COTargetDouble "{ target: 10.0 }"
For visualizing the robot movement with Rviz2, in a third bash instance of the container:
ros2 launch panda_canopen rviz.launch.py
For visualize the robot, and plan and execute trajectories using the MoveIt2 plugin in Rviz2:
ros2 launch panda_moveit simulation.launch.py
This repository is based, and imported files from the following:
- From: https://github.com/ros-planning/moveit_resources/tree/ros2/panda_description
- Branch: humble
- Commit: #5cf047b
- License: Apache-2.0
- From: https://github.com/ros-industrial/ros2_canopen
- Branch: humble
- Commit: #e0b5706
- License: Apache-2.0
Added as a submodule.