Main Content

universalrobot

(Not recommended) Connection to simulated cobot or physical cobot from Universal Robots

Since R2022a

    universalrobot is not recommended. Use urROS2Node or urROSNode instead. For more information, see Compatibility Considerations.

    Description

    The universalrobot object represents a connection from the ROS enabled host computer to MATLAB. The ROS master running inside the ROS 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 in the Gazebo simulator) 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

    example

    ur = universalrobot creates a connection, ur, and tries to connect to the ROS master at default URI: http://localhost:11311. The ROS master is further connected to a simulated cobot or physical cobot from Universal Robots.

    However, before initiating the connection, the command checks for the value of the standard ROS environmental variable, ROS_MASTER_URI, which defines the ROS master. Therefore, you can use the syntax ur = universalrobot to create connection to simulated cobot in a different host computer if you have already specified a different address for the ROS master using that variable.

    example

    ur = universalrobot(hostname) creates a connection, ur, to the ROS master at the specified IP address or host name. This syntax assumes that the ROS master is running on the ROS default port number, 11311.

    example

    ur = universalrobot(hostname,port) creates a connection, ur, to the ROS master at the specified IP address or host name, and the specified port.

    example

    ur = universalrobot(URI) creates a connection, ur, to the ROS master at the specified URI (Uniform Resource Identifier).

    example

    ur = universalrobot(hostname,Name=Value) also specifies the IP address if the automatic detection fails (NodeHost), or sets the JointStateTopic, FollowJointTrajectoryAction, and RigidBodyTree properties using one or more optional name-value arguments.

    Input Arguments

    expand all

    Host name or IP address, specified as a string scalar or character vector.

    Port number used to connect to the ROS master, specified as a numeric scalar.

    URI for ROS master, specified as a string scalar or character vector. Standard format for URIs is either http://ipaddress:port or http://hostname:port.

    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.

    Host name or IP address that the node uses to advertise itself to the ROS network, specified as the pair consisting of NodeHost and a character vector. This argument is useful if the automatic detection of ROS master fails.

    Example: ur = universalrobot('172.19.98.176',11311,NodeHost='172.20.224.1')

    Example: ur = universalrobot('172.19.98.176',11311,NodeHost='comp-home')

    Properties

    expand all

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

    Example: ur = universalrobot('172.19.98.176',11311,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 = universalrobot('http://172.19.98.176:11311',FollowJointTrajectoryAction='/arm_controller/follow_joint_trajectory')

    Data Types: char | string

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

    Example: ur = universalrobot('http://172.19.98.176:11311',RigidBodyTree=loadrobot('universalUR5e','DataFormat','row'))

    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

    universalrobot(Not recommended) Connection to simulated cobot or physical cobot from Universal Robots
    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.

    ur = universalrobot;

    Connect to the physical or simulated cobot (either in the URSim offline simulator from Universal Robots or in the Gazebo simulator), in a different host computer. Specify the address of the ROS master by using the ROS_MASTER_URI environmental variable.

    setenv('ROS_MASTER_URI',['http://192.168.58.128:11311']);
    ur = universalrobot;

    Connect to a Cobot by Specifying the IP Address

    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 identified by the IP address in the ROS network.

    ur = universalrobot('172.19.98.176');

    Connect to a Cobot by Specifying the IP Address and Port Number

    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 identified by the IP address in the ROS network and its port number.

    ur = universalrobot('172.19.98.176',11312);

    Connect to a Cobot by Specifying the URI

    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 identified by the URI in the ROS network.

    ur = universalrobot('http://172.19.98.176:11311');

    Connect to a Cobot by Specifying the Advertised Address and 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 by mentioning the advertised address (for example, 172.20.224.1) of the host computer in the ROS network.

    ur = universalrobot('172.19.98.176',NodeHost='172.20.224.1');
    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.

    ur = universalrobot('172.19.98.176',RigidBodyTree=ur5);
    ur = 
      universalrobot 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 R2022a

    expand all