Robotran Matlab Documentation

Inverse dynamics

Computation of the system inverse dynamics.
For more information, see Robotran theoritical framework.

Code sample

For running the inverse dynamics, insert the following code in your main script and adapt it to your need :

%% 6. Inverse dynamics [mbs_exe_invdyn]
%--------------------------------------------------------------------------
MBS_user.process = 'invdyn';
Joint_id = mbs_get_joint_id(mbs_info,{'joint1' 'joint2' 'joint3'});
mbs_data = mbs_set_qa(mbs_data,Joint_id); % Set variables [Joint_id] as actuated
opt.invdyn = {'motion','trajectory','framerate',1000,...
'save2file','yes','renamefile','no','verbose','yes'};
% other options : 'time', 'visualize', 'clearmbsglobal' % Help about options on www.robotran.be
[mbs_invdyn,mbs_data] = mbs_exe_invdyn(mbs_data,opt.invdyn); % Inverse dynamics process
% Graphical Results
mycolor = ['r' 'b' 'g' 'k']; % Vector of color
figure(1)
hold on
for i=1:mbs_data.nqa
plot(mbs_invdyn.tsim,mbs_invdyn.Qa(:,mbs_data.qa(i)),mycolor(i)); % Actuator force/torque time history
end
title('Force or torque XXX');
xlabel('tsim'); ylabel('force [N] or torque [Nm]');
pause;
close(1);

Use

The inverse dynamics is performed by the function mbs_exe_invdyn().

The user specifies the desired options of the inverse dynamics in MBS_invdyn_opt structure. The results are provided in the MBS_invdyn structure.

The function calls successively :

See diagram below for more details :

inverse dynamics function diagram
mbs_set_qa
function mbs_set_qa(in mbs_data, in qa)
MBS_dirdyn::tsim
MBS_dirdyn tsim
The time value.
Definition: mbs_new_dirdyn.m:182
MBS_data::qa
MBS_data qa
The index of the actuated articulations: those articulations are controlled by an actuator Qq=f(q)
Definition: Sdata_struct.m:90
MBS_dirdyn_opt::time
MBS_dirdyn opt time
Vector containing the initial time, the printing time interval and the final time of the simulation :...
Definition: mbs_new_dirdyn.m:72
mbs_get_joint_id
function mbs_get_joint_id(in mbs_info, in varargin)
MBS_dirdyn::opt
MBS_dirdyn opt
MBS_dirdyn_opt structure containing the direct dynamics options.
Definition: mbs_new_dirdyn.m:68
MBS_data::nqa
MBS_data nqa
Number of actuated articulations.
Definition: Sdata_struct.m:93
MBS_invdyn::Qa
MBS_invdyn Qa
Array with the current values of the generalized forces produced by the actuators.
Definition: mbs_new_invdyn.m:129
mbs_exe_invdyn
function mbs_exe_invdyn(in mymbs_data, in options, in t)
actuated
MBS_info oint actuated
Definition: mbs_set_data.m:98