3.2. Robots in ROS¶
Note
The following examples use the ROS backend and the MoveI! planner for UR5 robots. Before running them, please make sure you have the ROS backend correctly configured and the UR5 Demo started.
Once ROS is running and MoveIt! planner has started with a robot, we can start interacting with the robot model. There are two basic ways to work with a robot model that is loaded in ROS.
3.2.1. Load model from ROS¶
This is the easiest and preferable way to load a robot model: request the full model to be loaded from ROS.
from compas_fab.backends import RosClient
with RosClient() as client:
robot = client.load_robot()
robot.info()
assert robot.name == 'ur5'
3.2.2. Load model from URDF¶
Alternatively, the URDF model can be loaded from URDF files (stored locally or remotely):
from compas.robots import RobotModel
import compas_fab
from compas_fab.backends import RosClient
from compas_fab.robots import Robot
with RosClient() as client:
urdf = compas_fab.get('universal_robot/ur_description/urdf/ur5.urdf')
model = RobotModel.from_urdf_file(urdf)
robot = Robot(model, client=client)
robot.info()
assert robot.name == 'ur5'