Main Content

universalrobot

Connection to simulated cobot from Universal Robots

    Description

    The universalrobot object represents a connection from the ROS enabled host computer to a simulated collaborative robot (cobot) from Universal Robots, either in the URSim offline simulator from Universal Robots or in the Gazebo simulator. The object connects to the ROS Master running on the host computer. 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, to the simulated cobot from Universal Robots, which is running on the same host computer. The simulated cobot is the ROS master in the ROS network.

    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 simulated cobot (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 simulated cobot (ROS master) at the specified IP address or host name, and the specified port.

    example

    ur = universalrobot(URI)creates a connection, ur, to the simulated cobot (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=ur5)

    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

    Examples

    Connect to a Simulated Cobot Using Auto-detection

    Connect to the 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 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 Simulated Cobot by Specifying the IP Address

    Connect to the 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 Simulated Cobot by Specifying the IP Address and Port Number

    Connect to the 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 Simulated Cobot by Specifying the URI

    Connect to the 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 Simulated Cobot by Specifying the Advertised Address and Other Optional Arguments

    Connect to the 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 Simulated Cobot by Specifying the RBT Object

    Connect to the 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'
    

    Version History

    Introduced in R2022a