This page provides instruction on how to control the UR10 physical Robot with ROS2 and MoveIT.
If you are trying to connect a new computer to control the robot, please follow this section. If you are using a computer that is already set up for the robot, you could skip this section and start with the next Usage section.
Complete the setup following the official repository: Universal_Robots_ROS2_Driver. Note that the robot has already been set up properply following this instruction. You only need to set up your computer with the following steps.
sudo apt-get install ros-<YOUR_ROS_DISTRO>-ur
Start & Setup your computer with Robot Setup Guide. Note that you only need to set up your computer, since the robot has already been set up following this guide.
ping 192.168.1.102
where 192.168.1.102 is the robot's IP address.Start the driver by
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10 robot_ip:=192.168.1.102
Executing the above command will display the physical robot's exact position in RViz.
This UR Driver page provides multiple examples of controlling the ur10 robot. Here we provide two examples.
To control the robot, if you have not done so, you need to
To command the robot's end-effector motion, first launch the driver if it is not already running.
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10 robot_ip:=192.168.1.102
Execute the following ROS2 command to move the robot's end-effector to a desired pose with the urscript_interface:
ros2 topic pub --once /urscript_interface/script_command std_msgs/msg/String '{data:
"def my_prog():
set_digital_out(1, True)
movej(p[-0.6, -0.3, 0.4, 3.14, 0, 0], a=1.2, v=0.25, r=0)
textmsg(\"motion finished\")
end"}'
To use MoveIt to control the robot, you need to first set up external control host IP. You will need to go back to the home page of the robot's Teach Pendant and change it. However, if you followed the previous steps and keep the computer's IP 192.168.1.101, you can skip the following steps.
<empty>
and click on Structure > URCaps > External Control.After setting up the External Control Host IP address and the corresponding program, you can load the program in either of these two ways:
In Teach Pendant, navigate to File > Load program and load ExternalControlMoveit.urp
, which has already been written and ready to use. If you change it in the previous step, use yours. Click on the Play symbol to run the program.
Load the program remotely by
ros2 service call /dashboard_client/load_program ur_dashboard_msgs/srv/Load "filename: ExternalControlMoveit.urp"``
ros2 service call /dashboard_client/play std_srvs/srv/Trigger {}
If you encounter "connection refused" in the Teach Pendan, it means that your driver is not launched. Make sure the robot's driver is launched before running the External Control program.
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur10 robot_ip:=192.168.1.102 launch_rviz:=false
Now, run MoveIt by
ros2 launch ur_moveit_config ur_moveit.launch.py ur_type:=ur10 launch_rviz:=true