Main Content


Update values of NaturalFrequency and DampingRatio properties given desired step response



updateErrorDynamicsFromStep(motionModel,settlingTime,overshoot) updates the values of the NaturalFrequency and DampingRatio properties of the given jointSpaceMotionModel object given the desired step response.

updateErrorDynamicsFromStep(motionModel,settlingTime,overshoot,jointIndex) updates the NaturalFrequency and DampingRatio properties for a specific joint. In this case, the values of SettlingTime and Overshoot must be provided as scalars because they apply to a single joint.


collapse all

This example shows how to create and use a jointSpaceMotionModel object for a manipulator robot in joint-space.

Create the Robot

robot = loadrobot("kinovaGen3","DataFormat","column","Gravity",[0 0 -9.81]);

Set Up the Simulation

Set the timespan to be 1 s with a timestep size of 0.01 s. Set the initial state to be the robots, home configuration with a velocity of zero.

tspan = 0:0.01:1;
initialState = [homeConfiguration(robot); zeros(7,1)];

Define the a reference state with a target position, zero velocity, and zero acceleration.

targetState = [pi/4; pi/3; pi/2; -pi/3; pi/4; -pi/4; 3*pi/4; zeros(7,1); zeros(7,1)];

Create the Motion Model

Model the system with computed torque control and error dynamics defined by a moderately fast step response with 5% overshoot.

motionModel = jointSpaceMotionModel("RigidBodyTree",robot);

Simulate the Robot

Use the derivative function of the model as the input to the ode45 solver to simulate the behavior over 1 second.

[t,robotState] = ode45(@(t,state)derivative(motionModel,state,targetState),tspan,initialState);

Plot the Response

Plot the positions of all the joints actuating to their target state. Joints with a higher displacement between the starting position and the target position actuate to the target at a faster rate than those with a lower displacement. This leads to an overshoot, but all of the joints have the same settling time.

hold all;
title("Joint Position (Solid) vs Reference (Dashed)");
xlabel("Time (s)")
ylabel("Position (rad)");

Figure contains an axes object. The axes object with title Joint Position (Solid) vs Reference (Dashed) contains 14 objects of type line.

Input Arguments

collapse all

The jointSpaceMotionModel object, which defines the properties of the motion model.

Settling time required to reach a 2% tolerance band in seconds, specified as a scalar or an n-element vector. n is the number of nonfixed joints in the rigidBodyTree of the jointSpaceMotionModel in the motionModel argument.

The overshoot relative to a unit step, specified as a scalar or an n-element vector. n is the number of nonfixed joints in the rigidBodyTree of the jointSpaceMotionModel in the motionModel argument.

The index of the joint for which NaturalFrequency and DampingRatio is updated given the unit-step error dynamics. In this case, settling time and overshoot must be specified as scalars.


[1] Ogata, Katsuhiko. Modern Control Engineering 4th ed. Englewood Cliffs, NJ: Prentice-Hall, 2002.

Extended Capabilities

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

Introduced in R2019b