%% Compute Gravity Torque for Robot Configuration
% 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'. Set the Gravity property.

lbr.DataFormat = 'row'; 
lbr.Gravity = [0 0 -9.81];

%
% Get a random configuration for lbr.

q = randomConfiguration(lbr);

%
% Compute the gravity-compensating torques for each joint.

gtau = gravityTorque(lbr,q);

% Copyright 2012 The MathWorks, Inc.