Example Universal Robots - cyberbotics/webots_ros2 GitHub Wiki
This package provides an interface between ROS 2 and the UR3e, UR5e, and UR10e simulation models of the Universal Robots running in Webots. It includes several simulations of these robots.
These examples are using the URDF spawning feature from the Ros2Supervisor node, thus there is a slight "freeze" at the beginning of the simulations as the Ros2Supervisor
has to spawn the UR5e robot.
The UR5e Simple Example
and the MoveIt2 Integration
examples require to use two launch files to start the simulation instead of one with the master
branch. The first one starts Webots with the chosen world while the second spawns the robot and starts the ROS 2 nodes.
All the others commands can be used as they are.
UR5e Simple Example
This simulation contains one UR5e robot in a very simple environment. The simulation can be started with the following launch file:
ros2 launch webots_ros2_universal_robot robot_world_launch.py
The robot can be spawned and the ROS 2 nodes started with:
ros2 launch webots_ros2_universal_robot robot_nodes_launch.py
Move the UR5e Robot
The /ur5e/ur_joint_trajectory_controller/follow_joint_trajectory
action server can be tested directly using the ROS2 action CLI interface to move the robot:
ros2 action send_goal /ur5e/ur_joint_trajectory_controller/follow_joint_trajectory control_msgs/action/FollowJointTrajectory "{
trajectory: {
joint_names: [shoulder_pan_joint, shoulder_lift_joint, elbow_joint, wrist_1_joint, wrist_2_joint, wrist_3_joint],
points: [
{ positions: [3.02, -1.63, -1.88, 1.01, 1.51, 1.13], time_from_start: { sec: 5, nanosec: 500 } },
{ positions: [-1.01, 0.38, -0.63, -0.88, 0.25, -1.63], time_from_start: { sec: 6, nanosec: 500 } },
{ positions: [-1.01, 0.38, -0.63, -0.88, 0.25, 6.2], time_from_start: { sec: 50, nanosec: 500 } }
]
},
goal_tolerance: [
{ name: shoulder_pan_joint, position: 0.01 },
{ name: shoulder_lift_joint, position: 0.01 },
{ name: elbow_joint, position: 0.01 },
{ name: wrist_1_joint, position: 0.01 },
{ name: wrist_2_joint, position: 0.01 },
{ name: wrist_3_joint, position: 0.01 }
]
}"
MoveIt2 Integration
This example shows how you can control the robotic arm by moving it in RViz with the help of MoveIt2
.
If it isn't installed yet, you can do so with the command:
sudo apt install ros-${ROS_DISTRO}-moveit
The simulation can be started with the following launch file:
ros2 launch webots_ros2_universal_robot robot_world_launch.py
The robot can be spawned and the ROS 2 nodes started with:
ros2 launch webots_ros2_universal_robot robot_moveit_nodes_launch.py
Then you will be able to move the robotic arm in RViz and press Plan & Execute
to see the same movement in the Webots simulation.
Multirobot Example
This example shows how you can make control multiple robots to collaborate in a single simulation.
Run the UR5e and IRB 4600 simulation in Webots using:
ros2 launch webots_ros2_universal_robot multirobot_launch.py