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 Version History.
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
Syntax
Description
creates a connection,
ur
= universalrobotur
, 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.
creates a connection, ur
= universalrobot(hostname
)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.
creates a connection, ur
= universalrobot(URI
)ur
, to the ROS master at the specified URI (Uniform
Resource Identifier).
also specifies the IP address if the automatic detection fails (ur
= universalrobot(hostname
,Name=Value
)NodeHost
), or sets the
JointStateTopic,
FollowJointTrajectoryAction, and RigidBodyTree
properties using one or more optional name-value arguments.
Input Arguments
Properties
Object Functions
universalrobot | (Not recommended) Connection to simulated cobot or physical cobot from Universal Robots |
getJointConfiguration | Get current joint configuration from the robot |
getCartesianPose | Get current end-effector pose from the robot |
getEndEffectorVelocity | Get current end-effector velocities from the robot |
getJointVelocity | Get current joint velocities from the robot |
getMotionStatus | Get current motion status of the robot |
followTrajectory | Command robot to move along the desired joint space waypoints |
followWaypoints | Command robot to move along the desired task space waypoints |
sendCartesianPose | Command robot to move to desired Cartesian pose |
sendCartesianPoseAndWait | Command robot to move to desired Cartesian pose and wait for the motion to complete |
sendJointConfiguration | Command robot to move to desired joint configuration |
sendJointConfigurationAndWait | Command robot to move to joint configuration and wait for the motion to complete |
recordRobotState | Log the key robot state parameters during motion of robot |
executePrimaryURScriptCommand | Execute primary URScript command to control cobot over ROS interface |
executeSecondaryURScriptCommand | Execute secondary URScript command over ROS interface |
handBackControl | Get 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 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'