Main Content

centerOfMass

Center of mass position and Jacobian

Description

example

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.

Examples

collapse all

Load a KUKA LBR iiwa robot model from the Robotics System Toolbox™ loadrobot. This is specified as a rigidBodyTree object.

lbr = loadrobot("kukaIiwa14")
lbr = 
  rigidBodyTree with properties:

     NumBodies: 10
        Bodies: {[1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]  [1x1 rigidBody]}
          Base: [1x1 rigidBody]
     BodyNames: {'iiwa_link_0'  'iiwa_link_1'  'iiwa_link_2'  'iiwa_link_3'  'iiwa_link_4'  'iiwa_link_5'  'iiwa_link_6'  'iiwa_link_7'  'iiwa_link_ee'  'iiwa_link_ee_kuka'}
      BaseName: 'world'
       Gravity: [0 0 0]
    DataFormat: 'struct'

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);
show(lbr);
hold all
plot3(comLocation(1),comLocation(2),comLocation(3),Marker="x",MarkerSize=30,LineWidth=5);

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.

References

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

Extended Capabilities

Version History

Introduced in R2017a

expand all