Skip to content

Commit 213f0bb

Browse files
author
Gabriele
committed
updated and tested simulink-only simulator
1 parent 690723d commit 213f0bb

17 files changed

+19620
-26475
lines changed

controllers/simulink-balancing-simulator/app/robots/iCubGazeboV2_5/configRobot.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
% Frames list
4444
Frames.BASE = 'root_link';
45-
Frames.IMU = 'imu_frame';
45+
Frames.IMU = 'head_imu_0';
4646
Frames.LEFT_FOOT = 'l_sole';
4747
Frames.RIGHT_FOOT = 'r_sole';
4848
Frames.COM = 'com';
@@ -105,4 +105,4 @@
105105
Ports.NECK_POS_PORT_SIZE = 3;
106106
Ports.IMU_PORT_SIZE = 12;
107107
Ports.IMU_PORT_ORIENTATION_INDEX = [1,2,3];
108-
Ports.WRENCH_PORT_SIZE = 6;
108+
Ports.WRENCH_PORT_SIZE = 6;

controllers/simulink-balancing-simulator/app/robots/iCubGazeboV2_5/configStateMachine.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@
157157

158158
% Compute contact constraints (friction cone, unilateral constraints)
159159
[ConstraintsMatrix, bVectorConstraints] = wbc.computeRigidContactConstraints ...
160-
(forceFrictionCoefficient, numberOfPoints, torsionalFrictionCoefficient, feet_size, fZmin);
160+
(forceFrictionCoefficient, numberOfPoints, torsionalFrictionCoefficient, feet_size, fZmin);

controllers/simulink-balancing-simulator/app/robots/iCubGazeboV2_5/gainsAndReferences.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,4 @@
344344
Config.noOscillationTime = 0;
345345
Config.directionOfOscillation = [0;1;0];
346346
Config.amplitudeOfOscillation = 0.02; % [m]
347-
Config.frequencyOfOscillation = 0.2; % [Hz]
347+
Config.frequencyOfOscillation = 0.2; % [Hz]

controllers/simulink-balancing-simulator/initTorqueControlBalancingSim.m

+11-11
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
%
2929
% If you are simulating the robot with Gazebo, remember that it is required
3030
% to launch Gazebo as follows:
31-
%
31+
%
3232
% gazebo -slibgazebo_yarp_clock.so
33-
%
33+
%
3434
% and properly set the environmental variable YARP_ROBOT_NAME in the .bashrc.
3535

36-
% Simulation time in seconds. For long simulations, put an high number
36+
% Simulation time in seconds. For long simulations, put an high number
3737
% (not inf) for allowing automatic code generation
3838
Config.SIMULATION_TIME = 70;
3939

@@ -46,10 +46,10 @@
4646
%
4747
% 'YOGA': the robot will perform the YOGA++ demo (highly dynamic movements
4848
% while balancing on one foot and two feet)
49-
%
49+
%
5050
% 'COORDINATOR': the robot can either balance on two feet or move from left
5151
% to right follwing a desired center-of-mass trajectory.
52-
%
52+
%
5353
DEMO_TYPE = 'YOGA';
5454

5555
% Config.SCOPES: debugging scopes activation
@@ -68,16 +68,16 @@
6868
Config.PLOT_INTEGRATION_TIME = false;
6969

7070
% Run robot-specific configuration parameters
71-
run(strcat('app/robots/',getenv('YARP_ROBOT_NAME'),'/configRobot.m'));
72-
run(strcat('app/robots/',getenv('YARP_ROBOT_NAME'),'/configStateMachine.m'));
73-
run(strcat('app/robots/',getenv('YARP_ROBOT_NAME'),'/gainsAndReferences.m'));
71+
run(strcat('app/robots/',getenv('YARP_ROBOT_NAME'),'/configRobot.m'));
72+
run(strcat('app/robots/',getenv('YARP_ROBOT_NAME'),'/configStateMachine.m'));
73+
run(strcat('app/robots/',getenv('YARP_ROBOT_NAME'),'/gainsAndReferences.m'));
7474

7575
% Deactivate/activate the internal coordinator
7676
if strcmpi(DEMO_TYPE, 'COORDINATOR')
7777

7878
Config.COORDINATOR_DEMO = true;
79-
79+
8080
elseif strcmpi(DEMO_TYPE, 'YOGA')
81-
81+
8282
Config.COORDINATOR_DEMO = false;
83-
end
83+
end

controllers/simulink-balancing-simulator/src-static-gui/closeModel.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
rmpath('../../library/matlab-gui');
1818
rmpath('./src-static-gui');
1919

20-
disp('[closeModel]: done.')
20+
disp('[closeModel]: done.')

controllers/simulink-balancing-simulator/src-static-gui/compileModel.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
torqueControlBalancingSim([], [], [], 'term')
1313

1414
catch ME
15-
15+
1616
errorMessages = ME;
1717
end
1818

@@ -21,4 +21,4 @@
2121
disp('Compilation done.')
2222

2323
% warning about Simulink timing
24-
warning('The model will anyways start with FEW SECONDS OF DELAY after pressing the ''Start Model'' button.')
24+
warning('The model will anyways start with FEW SECONDS OF DELAY after pressing the ''Start Model'' button.')

controllers/simulink-balancing-simulator/src/computeBasePoseDerivative.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function pose_base_dot = computeBasePoseDerivative(nu_base_ikin, pose_base)
22

33
% COMPUTEBASEPOSEDERIVATIVE computes the base position and orientation
4-
% time derivative in terms of linear velocity
4+
% time derivative in terms of linear velocity
55
% + quaternion derivative.
6-
6+
77
%% --- Initialization ---
88

99
% angular velocity in body coordinates
@@ -17,4 +17,4 @@
1717

1818
% compute the base pose derivative
1919
pose_base_dot = [nu_base_ikin(1:3); dquat_base];
20-
end
20+
end
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
function f_dynamics = estimateContactForcesFromDynamics(tau, JL, JR, JDotL_nu, JDotR_nu, M, h, LEFT_RIGHT_FOOT_IN_CONTACT)
2-
2+
33
% try to estimate the contact forces using the joint torques, the
44
% dynamics model, the robot state and the contact constraints.
55
ndof = size(M,1)-6;
66
B = [zeros(6,ndof); eye(ndof)];
77
f_dynamics = zeros(12,1);
8-
8+
99
if sum(LEFT_RIGHT_FOOT_IN_CONTACT) > 1.5
10-
10+
1111
% two feet balancing
1212
Jc = [JL; JR];
1313
JcDot_nu = [JDotL_nu; JDotR_nu];
1414

1515
pinvDampJMJ = eye(12)/(Jc/M*Jc');
1616
f_dynamics = pinvDampJMJ*(Jc/M*(h-B*tau)-JcDot_nu);
17-
17+
1818
elseif LEFT_RIGHT_FOOT_IN_CONTACT(1) > 0.5 && LEFT_RIGHT_FOOT_IN_CONTACT(2) < 0.5
19-
19+
2020
% left foot balancing
2121
Jc_left = JL;
2222
Jc_leftDot_nu = JDotL_nu;
23-
23+
2424
pinvDampJMJ_left = eye(6)/(Jc_left/M*Jc_left');
2525
f_dynamics = [pinvDampJMJ_left*(Jc_left/M*(h-B*tau)-Jc_leftDot_nu); zeros(6,1)];
26-
26+
2727
elseif LEFT_RIGHT_FOOT_IN_CONTACT(2) > 0.5 && LEFT_RIGHT_FOOT_IN_CONTACT(1) < 0.5
28-
28+
2929
% right foot balancing
3030
Jc_right = JR;
3131
Jc_rightDot_nu = JDotR_nu;
32-
32+
3333
pinvDampJMJ_right = eye(6)/(Jc_right/M*Jc_right');
3434
f_dynamics = [zeros(6,1); pinvDampJMJ_right*(Jc_right/M*(h-B*tau)-Jc_rightDot_nu)];
3535
end
36-
end
36+
end
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function nuDot = forwardDynamics(tau, JL, JR, M, h, f, LEFT_RIGHT_FOOT_IN_CONTACT)
2-
2+
33
% get the robot accelerations using the joint torques, the
44
% dynamics model, the robot state and the contact constraints.
55
ndof = size(M,1)-6;
66
B = [zeros(6,ndof); eye(ndof)];
7-
7+
88
nuDot = M\(B*tau+LEFT_RIGHT_FOOT_IN_CONTACT(1)*JL'*f(1:6)+LEFT_RIGHT_FOOT_IN_CONTACT(2)*JR'*f(7:end)-h);
9-
10-
end
9+
10+
end

0 commit comments

Comments
 (0)