Main Content

forwardDynamics

Joint accelerations given joint torques and states

Description

jointAccel = forwardDynamics(robot) computes joint accelerations due to gravity at the robot home configuration, with zero joint velocities and no external forces.

jointAccel = forwardDynamics(robot,configuration) also specifies the joint positions of the robot configuration.

To specify the home configuration, zero joint velocities, or zero torques, use [] for that input argument.

jointAccel = forwardDynamics(robot,configuration,jointVel) also specifies the joint velocities of the robot.

jointAccel = forwardDynamics(robot,configuration,jointVel,jointTorq) also specifies the joint torques applied to the robot.

example

jointAccel = forwardDynamics(robot,configuration,jointVel,jointTorq,fext) also specifies an external force matrix that contains forces applied to each joint.

Examples

collapse all

Calculate the resultant joint accelerations for a given robot configuration with applied external forces and forces due to gravity. A wrench is applied to a specific body with the gravity being specified for the whole robot.

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

load exampleRobots.mat lbr

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. By default, gravity is assumed to be zero.

lbr.Gravity = [0 0 -9.81];

Get the home configuration for the lbr robot.

q = homeConfiguration(lbr);

Specify the wrench vector that represents the external forces experienced by the robot. Use the externalForce function to generate the external force matrix. Specify the robot model, the end effector that experiences the wrench, the wrench vector, and the current robot configuration. wrench is given relative to the 'tool0' body frame, which requires you to specify the robot configuration, q.

wrench = [0 0 0.5 0 0 0.3];
fext = externalForce(lbr,'tool0',wrench,q);

Compute the resultant joint accelerations due to gravity, with the external force applied to the end-effector 'tool0' when lbr is at its home configuration. The joint velocities and joint torques are assumed to be zero (input as an empty vector []).

qddot = forwardDynamics(lbr,q,[],[],fext);

Input Arguments

collapse all

Robot model, specified as a rigidBodyTree object. To use the forwardDynamics 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 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 torques, specified as a vector. Each element corresponds to a torque applied to a specific joint. To use the vector form of jointTorq, 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 number of bodies 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 accelerations, returned as a vector. The dimension of the joint accelerations vector is equal to the degrees of freedom of the robot. Each element corresponds to a specific joint on the robot.

Extended Capabilities

Introduced in R2017a