Main Content

urROS2Node

Connection to simulated cobot or physical cobot from Universal Robots over ROS 2

Since R2024a

    Description

    The urROS2Node object represents a connection from the ROS 2 enabled host computer to MATLAB. The ROS 2 enabled host computer is further connected to a simulated collaborative robot (cobot) from Universal Robots (either in the URSim offline simulator from Universal Robots) or to a physical cobot. To interact with the simulated cobot to read robot state data, send joint and cartesian control commands, and follow set of joint-space or task-space waypoints, use this object with the functions listed in Object Functions.

    Creation

    Description

    ur = urROS2Node creates a connection, ur, and tries to connect to the ROS 2 node, which is further connected to a simulated cobot or physical cobot from Universal Robots.

    ur = urROS2Node(Name=Value) sets the JointStateTopic, FollowJointTrajectoryAction, and RigidBodyTree properties using one or more optional name-value arguments.

    Input Arguments

    expand all

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Domain ID of the ROS 2 node to connect. By default the DomainID is maintained as 0.

    Example: ur = urROS2Node(DomainID = 2)

    Properties

    expand all

    Name of the ROS topic to read robot state, specified as a string scalar or character vector.

    Example: ur = urROS2Node(JointStateTopic='/joint_states')

    Data Types: char | string

    Name of the ROS action to move the robot, specified as a string scalar or character vector.

    Example: ur = urROS2Node(FollowJointTrajectoryAction='/arm_controller/follow_joint_trajectory')

    Data Types: char | string

    Rigid body tree robot model, specified as a rigidBodyTree object.

    Example: ur = urROS2Node(RigidBodyTree=ur5e), where ur5e is defined using the command ur5e = loadrobot('universalUR5e').

    This property is read-only.

    Number of joints in the robot, specified as a numeric scalar.

    Data Types: double

    This property is read-only.

    End effector body name for frame transformation, specified as a character vector.

    Data Types: char

    Object Functions

    getJointConfigurationGet current joint configuration from the robot
    getCartesianPoseGet current end-effector pose from the robot
    getEndEffectorVelocityGet current end-effector velocities from the robot
    getJointVelocityGet current joint velocities from the robot
    getMotionStatusGet current motion status of the robot
    followTrajectoryCommand robot to move along the desired joint space waypoints
    followWaypointsCommand robot to move along the desired task space waypoints
    sendCartesianPoseCommand robot to move to desired Cartesian pose
    sendCartesianPoseAndWaitCommand robot to move to desired Cartesian pose and wait for the motion to complete
    sendJointConfigurationCommand robot to move to desired joint configuration
    sendJointConfigurationAndWaitCommand robot to move to joint configuration and wait for the motion to complete
    recordRobotStateLog the key robot state parameters during motion of robot
    executePrimaryURScriptCommandExecute primary URScript command to control cobot over ROS interface
    executeSecondaryURScriptCommandExecute secondary URScript command over ROS interface
    handBackControlGet the control back from the External Control program node in the UR program tree

    Examples

    Connect to a Cobot Using Auto-detection

    Connect to the physical or simulated cobot (either in the URSim offline simulator from Universal Robots or in the Gazebo simulator), in the same host computer, over ROS2.

    ur = urROS2Node;

    Connect to a Cobot by Specifying Other Optional Arguments

    Connect to the physical or simulated cobot (either in the URSim offline simulator from Universal Robots or in the Gazebo simulator), in the host computer, over ROS 2.

    ur = urROS2Node;
    Connect to a Cobot by Specifying the RBT Object

    Connect to the physical or simulated cobot (either in the URSim offline simulator from Universal Robots or in the Gazebo simulator), in the host computer by mentioning the rigid body tree object.

    ur5e = loadrobot('universalUR5e')
    ur = urROS2Node(RigidBodyTree=ur5e);
    ur = 
      urROS2Node with properties:
    
                      RigidBodyTree: [1×1 rigidBodyTree]
                    JointStateTopic: '/joint_states'
        FollowJointTrajectoryAction: '/scaled_pos_joint_traj_controller/follow_joint_trajectory'
                     NumberOfJoints: 6
                    EndEffectorName: 'tool0'
    

    Extended Capabilities

    Version History

    Introduced in R2024a