Documentation

inverseDynamics

Required joint torques for given motion

Description

jointTorq = inverseDynamics(robot) computes joint torques required for the robot to statically hold its home configuration with no external forces applied.

example

jointTorq = inverseDynamics(robot,configuration) computes joint torques to hold the specified robot configuration.

jointTorq = inverseDynamics(robot,configuration,jointVel) computes joint torques for the specified joint configuration and velocities with zero acceleration and no external forces.

jointTorq = inverseDynamics(robot,configuration,jointVel,jointAccel) computes joint torques for the specified joint configuration, velocities, and accelerations with no external forces. To specify the home configuration, zero joint velocities, or zero accelerations, use [] for that input argument.

jointTorq = inverseDynamics(robot,configuration,jointVel,jointAccel,fext) computes joint torques for the specified joint configuration, velocities, accelerations, and external forces. Use the externalForce function to generate fext.

Examples

collapse all

Use the inverseDynamics function to calculate the required joint torques to statically hold a specific robot configuration. You can also specify the joint velocities, joint accelerations, and external forces using other syntaxes.

Load a predefined KUKA LBR robot model, which is specified as a RigidBodyTree object.

Set the data format to 'row'. For all dynamics calculations, the data format must be either 'row' or 'column'.

lbr.DataFormat = 'row';

Set the Gravity property to give a specific gravitational acceleration.

lbr.Gravity = [0 0 -9.81];

Generate a random configuration for lbr.

q = randomConfiguration(lbr);

Compute the required joint torques for lbr to statically hold that configuration.

tau = inverseDynamics(lbr,q);

Use the externalForce function to generate force matrices to apply to a rigid body tree model. The force matrix is an m-by-6 vector that has a row for each joint on the robot to apply a six-element wrench. Use the externalForce function and specify the end effector to properly assign the wrench to the correct row of the matrix. You can add multiple force matrices together to apply multiple forces to one robot.

To calculate the joint torques that counter these external forces, use the inverseDynamics function.

Load a predefined KUKA LBR robot model, which is specified as a RigidBodyTree object.

Set the data format to 'row'. For all dynamics calculations, the data format must be either 'row' or 'column'.

lbr.DataFormat = 'row';

Set the Gravity property to give a specific gravitational acceleration.

lbr.Gravity = [0 0 -9.81];

Get the home configuration for lbr.

q = homeConfiguration(lbr);

Set external force on link1. The input wrench vector is expressed in the base frame.

fext1 = externalForce(lbr,'link_1',[0 0 0.0 0.1 0 0]);

Set external force on the end effector, tool0. The input wrench vector is expressed in the tool0 frame.

fext2 = externalForce(lbr,'tool0',[0 0 0.0 0.1 0 0],q);

Compute the joint torques required to balance the external forces. To combine the forces, add the force matrices together. Joint velocities and accelerations are assumed to be zero (input as []).

tau = inverseDynamics(lbr,q,[],[],fext1+fext2);

Input Arguments

collapse all

Robot model, specified as a rigidBodyTree object. To use the inverseDynamics function, set the DataFormat property to either 'row' or 'column'.

Robot configuration, specified as a vector with positions for all nonfixed joints in the robot model. You can generate a configuration using homeConfiguration(robot), randomConfiguration(robot), or by specifying your own joint positions. To use the vector form of configuration, set the DataFormat property for the robot to either 'row' or 'column' .

Joint velocities, specified as a vector. The number of joint velocities is equal to the velocity degrees of freedom of the robot. To use the vector form of jointVel, set the DataFormat property for the robot to either 'row' or 'column' .

Joint accelerations, returned as a vector. The dimension of the joint accelerations vector is equal to the velocity degrees of freedom of the robot. Each element corresponds to a specific joint on the robot. To use the vector form of jointAccel, set the DataFormat property for the robot to either 'row' or 'column' .

External force matrix, specified as either an n-by-6 or 6-by-n matrix, where n is the velocity degrees of freedom of the robot. The shape depends on the DataFormat property of robot. The 'row' data format uses an n-by-6 matrix. The 'column' data format uses a 6-by-n .

The matrix lists only values other than zero at the locations relevant to the body specified. You can add force matrices together to specify multiple forces on multiple bodies.

To create the matrix for a specified force or torque, see externalForce.

Output Arguments

collapse all

Joint torques, returned as a vector. Each element corresponds to a torque applied to a specific joint. 