main content

perform safe trajectory tracking control using robotics manipulator blocks -凯发k8网页登录

this example shows you how to use simulink® with manipulator algorithm blocks to achieve safe trajectory tracking control of a simulated robot.

both robotics system toolbox™ and simscape multibody™ are required to run this example.

introduction

this example provides a model that implements a computed-torque controller with joint position and velocity feedback using manipulator algorithm blocks. the controller receives joint position and velocity information from a simulated robot (implemented using simscape multibody) and sends torque commands to drive the robot along a given joint trajectory. a planar object is placed in front of the robot so the end effector of the robot arm will collide with it when the trajectory is executed. without any additional setup, the torque felt from colliding with the object can cause damage on the robot or the object. to achieve safe trajectory tracking, a trajectory scaling block is built to adjust the time stamp when assigning the desired motion to the controller. you may adjust some parameters and interact with the robot while the model is running and observe the effect on the simulated robot.

set up robot model

this example uses a model of the rethink sawyer, a seven degree-of-freedom robot manipulator. call importrobot to generate a model from a description stored in a unified robot description format (urdf) file. set the dataformat and gravity properties to be consistent with simscape. the simulink model accesses this robot model from the workspace in the simulation.

sawyer = importrobot('sawyer.urdf');
sawyer.removebody('head');
sawyer.dataformat = 'column';
sawyer.gravity = [0, 0, -9.80665];

trajectory generation

first, assign the start time and duration for the trajectory.

tstart = 0.5;
tduration = 3;

next, assign the initial and target configuration. q0 is the initial configuration and q1 is the target configuration.

q0 = [0; -1.18; 0; 2.18; 0; -1.0008; 3.3161];
q1 = zeros(7,1);

the following figures show the robot visualization of the initial configuration and the target configuration related to the location of the planar object. the planar object is placed so that the robot will collide to it during trajectory tracking.

in the simulink model, the block computes the robot's position, velocity, and acceleration at any instant in the trajectory using a fifth-order polynomial.

simulink model overview

next, open the simulink model. the variables generated above are already stored in simulink model workspace:

open_system('robotsafetrajectorytracking.slx');

the robotsafetrajectorytracking model implements a computed torque controller with trajectory scaling for safe trajectory tracking. there are three main subsystems in this model:

  • computed torque controller

  • trajectory scaling and desired motion

  • simscape multibody model with simple contact mechanics

on each time step, if the trajectory scaling switch is on, the modified time stamp is used for evaluating the desired joint position, velocity and acceleration. then, the computed torque controller uses the manipulator blocks associated with the rigidbodytree model to track the desired motion. the derived control input is fed into the sawyer model in simscape multibody, where the planar object for interacting with the robot is included.

build computed torque controller

for a manipulator with n non-fixed joints, the system dynamics can be expressed as:

m(q)q¨ c(q,q˙)q˙ g(q)=u

where q, q˙, q¨, rn are the position, velocity and acceleration of the generalized coordinate, urn is the control input (torque), m(q) is the joint space mass matrix, c(q,q˙)q˙ is the velocity product torque, g(q) is the gravity torque. to track along a desired joint trajectory with desired position qd, velocity q˙d and acceleration q¨d, the computed torque controller calculates the torque needed to obtain a given configuration and velocity, provided the robot dynamics variables m(q), c(q,q˙)q˙, and g(q). in simulink, these variables can be easily derived using robotics manipulator blocks from robotics system toolbox to design the following computed torque controller:

u=m(q)(q¨d-kdq˙e-kpqe) c(q,q˙)q˙ g(q)

where qe=q-qd is the position error and q˙e=q˙-q˙d is the velocity error. with this controller input, the system dynamics becomes a second-order ode:

q¨e kdq˙e kpqe=0

by choosing kd and kp properly, the tracking error qe will converge to zero when time approaches infinity.

the computed torque controller subsystem is built using three robotics manipulator blocks: , , and . note that the associated model, sawyer, is assigned in all those blocks, and the configuration and velocity need to be specified as column vectors.

open_system('robotsafetrajectorytracking/computed torque controller');

inside the computed torque controller, there are two tunable parameters (indicated by colored blocks):

  • gain kp: the proportional gain when correcting the robot configuration

  • gain kd: the derivative gain when correcting the robot configuration

a standard way to determine the kp and kd is to calculate them as:

kp=ωn2

kd=2ωnξ

where ωn and ξ are the natural frequency and damping ratio of the second-order ode. in this example, the default value of kp and kd are derived by setting the natural frequency and damping ratio as ωn=10 and ξ=1 to make the second-order ode a critical damped system.

trajectory scaling

there are two main blocks in this subsystem:

  • trajectory scaling

  • desired motion

trajectory scaling is the main block deployed for safe trajectory tracking in this example. at each time step ti, the original time stamp is calculated as ti=ti-1 δt. however, when the robot collides with an unexpected object, the increasing torque and deviance from the planned trajectory can be destructive for both the robot and the object. the main idea of trajectory scaling is to calculate the time stamp as ti=ti-1 fs(qd,q˙d,q¨d,τmea)δt by introducing fs(qd,q˙d,q¨d,τmea)[-1,1], which is a function of the desired motion and measured torque τmea. the function fs() controls the speed of the robot motion and is determined based on the interference felt by the robot. if the measured torques are greater than expected, fs() is decreased to make the robot slow down or even move backward until the desired torques are achieved. these values of fs() have the following effects on the robot's motion:

  • fs()>0, the robot moves forward (fs()=1 is the normal speed).

  • fs()=0, the robot stops.

  • fs()<0, the robot moves backward.

in the trajectory scaling block, it is required to estimate the external torque τˆext=τmea-τˆ to calculate fs(), where τmea is the measured torque from the simscape model, and τˆ is the expected torque of the desired motion on the previous time stamp. in the external torque observer section of the model, the block calculates the expected torque which is subtracted from the measure torque. expected torque is: τˆ=m(qd)(q¨d) c(qd,q˙d)q˙d g(qd).

in the desired motion area, the output of the trajectory scaling algorithm is fed as an input to a polynomial trajectory block. this block compute a quintic polynomial trajectory given the known values of q0 and q1 and their boundary conditions of zero velocity and acceleration. it outputs the position, velocity, and acceleration: qd(t), q˙d(t), and q¨d(t), which are fed to the computed torque controller subsystem.

simscape multibody robot model and simple contact mechanics

the simscape multibody robot model is imported from the same .urdf file using smimport, where a set of torque actuators and sensors for joint torque, joint position and velocity are added. a contact mechanism block simulates the reaction force between the end effector and the obstacle as a sphere and a plane, where a simple linear spring-damper model is used.

note: the contact mechanism has only been implemented between the end effector and the planar object. therefore, other parts of the robot arm may still pass through the obstacle.

run the model

run the model and observe the behavior of sawyer in the robot simulator and interact with it.

first, open the viewer by clicking on the scope icon shown below on the left of the simscape model block. the scope displays signals including the joint torques, reaction contact force between the end effector and the planar object, and the time stamp for calculating desired motion for trajectory tracking.

toggle the trajectory scaling switch to "off".

use the following command or click run to start the simulation.

sim('robotsafetrajectorytracking.slx','stoptime','5');

you should see the arm collide with the object yielding high torque inputs and a large reaction force. note in this case the original time stamp is used. stop the simulation afterwards.

now, toggle trajectory scaling switch to on and rerun the model.

notice the differences in the computed torques and the reduced reaction force after the collision.

while the simulation is running, adjust the slider to move the object towards or away from the robot. the robot should react to its position while still trying to execute the trajectory safely.

summary

this example showed how to use robotics manipulator blocks in simulink to design a computed torque controller, and integrate it with trajectory scaling and dynamic simulation in simscape multibody to achieve safe trajectory tracking. the resultant torque, reaction force, and time stamp demonstrated the capability of trajectory scaling for performing safe trajectory tracking.

网站地图