Main Content


Center of mass position and Jacobian



com = centerOfMass(robot) computes the center of mass position of the robot model at its home configuration, relative to the base frame.

com = centerOfMass(robot,configuration) computes the center of mass position of the robot model at the specified joint configuration, relative to the base frame.

[com,comJac] = centerOfMass(robot,configuration) also returns the center of mass Jacobian, which relates the center of mass velocity to the joint velocities.


collapse all

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';

Compute the center of mass position and Jacobian at the home configuration of the robot.

[comLocation,comJac] = centerOfMass(lbr);

Input Arguments

collapse all

Robot model, specified as a rigidBodyTree object. To use the centerOfMass 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' .

Output Arguments

collapse all

Center of mass location, returned as an [x y z] vector. The vector describes the location of the center of mass for the specified configuration relative to the body frame, in meters.

Center of mass Jacobian, returned as a 3-by-n matrix, where n is the robot velocity degrees of freedom.


[1] Featherstone, Roy. Rigid Body Dynamics Algorithms. Springer US, 2008. (Crossref), doi:10.1007/978-1-4899-7560-7.

Extended Capabilities

Introduced in R2017a