Main Content

followWaypoints

Command robot to move along the desired task space waypoints

Since R2022a

Description

example

followWaypoints(ur,taskwaypoints,waypointtimes) commands the Universal Robots cobot connected through ROS interface to follow the desired Cartesian waypoints based on absolute time for each waypoint segment.

example

followWaypoints(ur,taskwaypoints,waypointtimes,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments in previous syntax. For example, set the InterpolationMethod to bsplinepolytraj.

Examples

collapse all

Connect to a physical or simulated cobot, using either urROSNode or urROS2Node object (based on the option for connectivity – ROS or ROS 2, which you selected in the Hardware Setup screen).

  • Connect to a physical or simulated cobot at IP address 192.168.2.112 on the ROS network.

    ur = urROSNode('192.168.2.112');
  • Connect to a physical or simulated cobot on the ROS 2 network.

    ur = urROS2Node;

Command the cobot to by providing the desired Cartesian waypoints and by specifying the absolute time for each waypoint segment.

taskwaypoints = [-pi/2    0  -pi/2 0.5     0  0.5;
                 -pi/4    0  -pi/2 0.5   0.3  0.6;
                 -pi/2    0  -pi/2 0.5     0  0.8;
                 -3*pi/4  0  -pi/2 0.5  -0.3  0.6;
                 -pi/2    0  -pi/2 0.5     0  0.5];

waypointTimes = [0 2 4 6 8];
followWaypoints(ur,taskwaypoints,waypointTimes);

Connect to a physical or simulated cobot, using either urROSNode or urROS2Node object (based on the option for connectivity – ROS or ROS 2, which you selected in the Hardware Setup screen).

  • Connect to a physical or simulated cobot at IP address 192.168.2.112 on the ROS network.

    ur = urROSNode('192.168.2.112');
  • Connect to a physical or simulated cobot on the ROS 2 network.

    ur = urROS2Node;

Command the cobot to by providing the desired Cartesian waypoints and by specifying the absolute time for each waypoint segment. Additionally, specify the InterpolationMethod as trapveltraj and specify the number of samples for trajectory generation as 100.

taskwaypoints = [-pi/2    0  -pi/2 0.5     0  0.5;
                 -pi/4    0  -pi/2 0.5   0.3  0.6;
                 -pi/2    0  -pi/2 0.5     0  0.8;
                 -3*pi/4  0  -pi/2 0.5  -0.3  0.6;
                 -pi/2    0  -pi/2 0.5     0  0.5];

waypointTimes = [0 2 4 6 8];
followWaypoints(ur,taskwaypoints,waypointTimes,InterpolationMethod='trapveltraj',NumberOfSamples=100);

Input Arguments

collapse all

Connection to physical or simulated cobot from Universal Robots, specified as a urROSNode object or a urROS2Node object.

Desired Cartesian pose in the form of waypoints of the simulated cobot, represented as a N-by-6 numeric vector, in the form of [thetaz thetay thetax x y z]. The units are radians and seconds respectively for the three axes, for N waypoints.

Data Types: numeric

Absolute time (time from start) for each waypoint segment to complete the motion, represented as a 1-by-N numeric vector, specified in seconds.

Data Types: double

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.

Example: followwaypoints(ur,taskwaypoints,waypointtimes,InterpolationMethod='trapveltraj') sets the Interpolation method.

Interpolation method to be considered to generate the motion commands using waypoints specified. In this case, only time is considered as the controlling factor for the shape of desired trajectory.

  • 'trapveltraj' — Generate a trajectory through a given set of input waypoints that follow a trapezoidal velocity profile.

  • 'bsplinepolytraj' — Generate a piecewise cubic B-spline trajectory that falls in the control polygon.

  • 'cubicpolytraj' — Generate a third-order polynomial that achieves a given set of input waypoints with corresponding time points.

  • 'quinticpolytraj' — Generate a fifth-order polynomial that achieves a given set of input waypoints with corresponding time points.

Example: followwaypoints(ur,taskwaypoints,waypointtimes,InterpolationMethod='bsplinepolytraj').

Number of samples used as data points to interpolate the trajectory, specified as a positive integer. Increasing the number of samples ensures a smooth tracking in the task space, but takes more time for the cobot to compute the trajectory.

Example: followwaypoints(ur,taskwaypoints,waypointtimes,InterpolationMethod='bsplinepolytraj',NumberofSamples=100).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2022a