Zero+Moment+Point+Tutorial+2+-+Robot+in+SimMechanics

toc Robot structure from Tutorial 1

Standard SimMechanics ZMP Robot

=Load Robot from file= Robot structure was saved as Tut1_Robot.mat. Loading this file will put the structure 'ZMP_Robot' in the Matlab workspace. code format="matlab" load('Tut1_Robot.mat') code

=Create SimMechanics Robot= First, open a standard robot model in SimMechanics. This model contains a robot base performing the movements of the entire robot, a ZMP calculation subsystem and some robot links. The simple Pole-on-Cart robot has only 2 links. There is no need for branching arms, so only the Torso subsystem in SimMechanics is needed. code format="matlab" open('Standard_Robot') code

=Adapt Standard Robot= Remove the two Robot_Arm subsystems from the SimMechanics model and also remove one link within the Robot_Torso subsystem.





=Generate SimMechanics Robot Structure= To make sure that all parameters for the SimMechanics Robot model are the same as defined in the Robot structure from tutorial 1, a function is available to automatically generate a usable structure for SimMechanics from the ZMP Robot Structure. The structures SM_ZMP_Base, SM_ZMP_Torso and SM_ZMP_Arms can be used in the standard SimMechanics robot model to define the robot parameters. The SM_ZMP_Base structure only contains the coordinates to move the entire robot. In this case the SM_ZMP_Arms structure is empty because there where no arms defined. The SM_ZMP_Torso structure contains two links which include the needed robot parameters.

code format="matlab" [SM_ZMP_Base, SM_ZMP_Torso, SM_ZMP_Arms] = CreateSMstruct(ZMP_Robot)

SM_ZMP_Torso.Link{:}

SM_ZMP_Base =

t: [229x1 double] q: [229x6 double] qd: [229x6 double] qdd: [229x6 double]

SM_ZMP_Torso =

Link: {[1x1 struct] [1x1 struct]} t: [229x1 double]

SM_ZMP_Arms =

{[]}

ans =

theta: 0 d: 0.0500 a: 0.0500 alpha: 1.5708 sigma: 'R'       r: [3x1 double] m: 2 I: [3x3 double] q: [229x1 double] qd: [229x1 double] qdd: [229x1 double]

ans =

theta: 0 d: 0 a: 0.5000 alpha: 0 sigma: 'R'       r: [3x1 double] m: 6 I: [3x3 double] q: [229x1 double] qd: [229x1 double] qdd: [229x1 double] code

=Combine Robot Structure with SimMechanics= The three components of the SM_ZMP Robot structure have to be assigned to the subsystem in SimMechanics.
 * Double click on the Base_Transform subsystem in SimMechanics and fill in the name of the SM_ZMP base structure: 'SM_ZMP_Base' in this case
 * Open the Robot_Torso subsystem from the main model. In Dual link 1 fill in the Torso structure name: 'SM_ZMP_Torso' and the link number: 1.
 * For Dual link 2 do the same, but give it link number 2.



=Simulating the model= The model is now ready to be simulated. The total time of the motion profile was less than 3 seconds, so we limit the simulation time to 3 seconds. The resulting computed ZMP will be logged in the Matlab workspace as 'p_zmp_simu', as a Matlab timeseries file.

code format="matlab" tend = 3; sim('Pole_on_Cart_sim',tend)

zmp_t = p_zmp_simu.time; zmp_x = p_zmp_simu.data(:,1); zmp_y = p_zmp_simu.data(:,2);

figure(1) plot(zmp_t,zmp_x) title('x-location of ZMP') grid on xlabel('time [s]') ylabel('position [m]') code



=Final model= The final model of the Pole on Cart system can be downloaded:



and also, the SimMechanics robot structure can be downloaded:

=Tutorial 3= Continue to tutorial 3