Zero+Moment+Point+Tutorial+3+-+Modify+SimMechanics+model

toc SimMechanics robot structure from tutorial 2:



SimMechanics model for Pole on Cart system:

Final SimMechanics model:

=Change Solver settings= The solver settings can be changed to get better simulation results. First, a fixed step discrete solver is selected because the model has no continuous states (no flexibilities). The fixed step size is then set to 0.01 seconds. To do this, open the Simulation dialog in the top of the SimMechanics window, select Model Configuration Parameters from there. The next figure shows the result of the changes:



=Add visuals to SimMechanics model= The results from the SimMechanics simulation can be plotted as a normal graph, but can also be visualized with a 3D simulation of the robot in Matlabs Mechanics Explorer.

First, a Rigid Transform block and a Solid block are added to the Cart and the Pole. The configuration for block Rigid Transform (Pole) is shown:

The configuration of the Solid1 block (Pole), it is very important to give visual elements a zero mass:

For the Cart the configurations can be found in the final model:

Make sure that the used parameters in these configurations (e.g. h2) are defined in the Matlab workspace: code format="matlab" %% Define Robot measurements L1 = 0.15;                 % Distance between rear wheel and CoM of Robot Platform L2 = 0.05;                 % Distance between CoM and joint of Robot Platform L3 = 0.1;                  % Distance between joint and fron twheel of Robot Platform h1 = 0.05;                 % Height above ground joint Robot Platform h2 = 0.5;                  % Length Pole m1 = 2;                    % Mass Robot Platform m2 = 6;                    % Mass Pole code

In the Matlab Mechanics Explorer a 3D model of the robot is shown:

=Simulating the model= The model is simulated and the results are plotted:

code format="matlab" %% Load SimMechanics robot structure load('Tut2_SM_Robot.mat') load_system('Pole_on_Cart_sim_v2') open_system('Pole_on_Cart_sim_v2')

SM_ZMP_Base = SM_ZMP_Robot.Base; SM_ZMP_Torso = SM_ZMP_Robot.Torso; SM_ZMP_Arms = SM_ZMP_Robot.Arms;

%% Run simulation tend = 2; sim('Pole_on_Cart_sim_v2',tend)

%% Retrieve data t = p_zmp_simu.time; x_zmp = p_zmp_simu.data(:,1); y_zmp = p_zmp_simu.data(:,2);

figure(1) plot(t,x_zmp) grid on xlabel('time [s]') ylabel('x-position of ZMP [m]') code



Link to tutorial part 4