1
+ % CONFIGSTATEMACHINE configures the state machine (type of demo, velocity
2
+ % of the demo, repeat movements, and so on).
3
+
4
+ %% --- Initialization ---
5
+
6
+ % If true, the robot CoM will follow a desired reference trajectory (COORDINATOR DEMO ONLY)
7
+ Config.LEFT_RIGHT_MOVEMENTS = false ;
8
+
9
+ % If equal to one, the desired values of the center of mass are smoothed internally
10
+ Config.SMOOTH_COM_DES = true ;
11
+
12
+ % If equal to one, the desired values of the postural tasks are smoothed internally
13
+ Config.SMOOTH_JOINT_DES = true ;
14
+
15
+ % Joint torques saturation [Nm]
16
+ Sat.torque = 60 ;
17
+
18
+ % Joint torques rate of change saturation
19
+ Sat.uDotMax = 300 ;
20
+
21
+ % max unsigned difference between two consecutive (measured) joint positions,
22
+ % i.e. delta_qj = abs(qj(k) - qj(k-1))
23
+ Sat.maxJointsPositionDelta = 15 * pi / 180 ; % [rad]
24
+
25
+ %% Regularization parameters
26
+ Reg.pinvDamp_baseVel = 1e-7 ;
27
+ Reg.pinvDamp = 1 ;
28
+ Reg.pinvTol = 1e-5 ;
29
+ Reg.KP_postural = 0.1 ;
30
+ Reg.KD_postural = 0 ;
31
+ Reg.HessianQP = 1e-7 ;
32
+
33
+ %% State Machine configuration
34
+
35
+ % time between two yoga positions
36
+ StateMachine.joints_pauseBetweenYogaMoves = 5 ;
37
+
38
+ % contact forces threshold
39
+ StateMachine.wrench_thresholdContactOn = 50 ;
40
+ StateMachine.wrench_thresholdContactOff = 100 ;
41
+
42
+ % threshold on CoM and joints error
43
+ StateMachine.CoM_threshold = 0.01 ;
44
+ StateMachine.joints_thresholdNotInContact = 5 ;
45
+ StateMachine.joints_thresholdInContact = 50 ;
46
+
47
+ % initial state for state machine
48
+ StateMachine.initialState = 1 ;
49
+
50
+ % other configuration parameters for state machine
51
+ StateMachine.tBalancing = 1 ;
52
+ StateMachine.tBalancingBeforeYoga = 1 ;
53
+ StateMachine.yogaExtended = true ;
54
+ StateMachine.skipYoga = false ;
55
+ StateMachine.demoOnlyBalancing = false ;
56
+ StateMachine.demoStartsOnRightSupport = false ; % If false, the Yoga demo is performed on the left foot first
57
+ StateMachine.yogaAlsoOnRightFoot = false ; % TO DO: yoga on both feet starting from right foot (not available for now)
58
+
59
+ % %%% List of possible "Yoga in loop" %%%%
60
+
61
+ % the robot will repeat the FULL DEMO (two feet balancing, yoga on left
62
+ % foot, back on two feet, yoga right foot, back on two feet). The demo is
63
+ % repeated until the user stops the Simulink model. This option is ignored
64
+ % if Sm.demoStartsOnRightSupport = true.
65
+ StateMachine.twoFeetYogaInLoop = false ;
66
+
67
+ % the robot will repeat the ONE FOOT yoga for the number of times the user
68
+ % specifies in the Sm.yogaCounter option. The robot WILL NOT go back to two
69
+ % feet balancing in between to consecutive yoga. WARNING: if the option
70
+ % Sm.yogaAlsoOnRightFoot is true, then the robot will repeat first the yoga
71
+ % on left foot for the number of times the user specifies in the Sm.yogaCounter,
72
+ % and then it will repeat the yoga on the right foot for the same number of times.
73
+ StateMachine.oneFootYogaInLoop = false ;
74
+ StateMachine.yogaCounter = 5 ;
75
+
76
+ %% Parameters for motors reflected inertia
77
+
78
+ % transmission ratio (1/N)
79
+ Config.Gamma = 0.01 * eye(ROBOT_DOF );
80
+
81
+ % modify the value of the transmission ratio for the hip pitch.
82
+ % TODO: avoid to hard-code the joint numbering
83
+ Config .Gamma(end - 5 , end - 5 ) = 0.0067 ;
84
+ Config .Gamma(end - 11 ,end - 11 ) = 0.0067 ;
85
+
86
+ % motors inertia (Kg*m^2)
87
+ legsMotors_I_m = 0.0827 * 1e-4 ;
88
+ torsoPitchRollMotors_I_m = 0.0827 * 1e-4 ;
89
+ torsoYawMotors_I_m = 0.0585 * 1e-4 ;
90
+ armsMotors_I_m = 0.0585 * 1e-4 ;
91
+
92
+ % add harmonic drives reflected inertia
93
+ if Config .INCLUDE_HARMONIC_DRIVE_INERTIA
94
+
95
+ legsMotors_I_m = legsMotors_I_m + 0.054 * 1e-4 ;
96
+ torsoPitchRollMotors_I_m = torsoPitchRollMotors_I_m + 0.054 * 1e-4 ;
97
+ torsoYawMotors_I_m = torsoYawMotors_I_m + 0.021 * 1e-4 ;
98
+ armsMotors_I_m = armsMotors_I_m + 0.021 * 1e-4 ;
99
+ end
100
+
101
+ Config.I_m = diag([torsoPitchRollMotors_I_m * ones(2 ,1 );
102
+ torsoYawMotors_I_m ;
103
+ armsMotors_I_m * ones(8 ,1 );
104
+ legsMotors_I_m * ones(12 ,1 )]);
105
+
106
+ % parameters for coupling matrices. Updated according to the wiki:
107
+ %
108
+ % http://wiki.icub.org/wiki/ICub_coupled_joints
109
+ %
110
+ % and corrected according to https://github.com/robotology/robots-configuration/issues/39
111
+ t = 0.615 ;
112
+ r = 0.022 ;
113
+ R = 0.04 ;
114
+
115
+ % coupling matrices
116
+ T_LShoulder = [-1 0 0 ;
117
+ - 1 - t 0 ;
118
+ 0 t - t ];
119
+
120
+ T_RShoulder = [ 1 0 0 ;
121
+ 1 t 0 ;
122
+ 0 - t t ];
123
+
124
+ T_torso = [ 0.5 - 0.5 0 ;
125
+ 0.5 0.5 0 ;
126
+ r /(2 * R ) r /(2 * R ) r / R ];
127
+
128
+ if Config .INCLUDE_COUPLING
129
+
130
+ Config.T = blkdiag(T_torso ,T_LShoulder ,1 ,T_RShoulder ,1 ,eye(12 ));
131
+ else
132
+ Config.T = eye(ROBOT_DOF );
133
+ end
134
+
135
+ % gain for feedforward term in joint torques calculation. Valid range: a
136
+ % value between 0 and 1
137
+ Config.K_ff = 0 ;
138
+
139
+ % Config.USE_DES_JOINT_ACC_FOR_MOTORS_INERTIA if true, the desired joints
140
+ % accelerations are used for computing the feedforward term in joint
141
+ % torques calculations. Not effective if Config.K_ff = 0.
142
+ Config.USE_DES_JOINT_ACC_FOR_MOTORS_INERTIA = false ;
143
+
144
+ %% Constraints for QP for balancing
145
+
146
+ % The friction cone is approximated by using linear interpolation of the circle.
147
+ % So, numberOfPoints defines the number of points used to interpolate the circle
148
+ % in each cicle's quadrant
149
+ numberOfPoints = 4 ;
150
+ forceFrictionCoefficient = 1 / 3 ;
151
+ torsionalFrictionCoefficient = 1 / 75 ;
152
+ fZmin = 10 ;
153
+
154
+ % physical size of the foot
155
+ feet_size = [-0.12 0.12 ; % xMin, xMax
156
+ - 0.05 0.05 ]; % yMin, yMax
157
+
158
+ % Compute contact constraints (friction cone, unilateral constraints)
159
+ [ConstraintsMatrix , bVectorConstraints ] = wbc .computeRigidContactConstraints ...
160
+ (forceFrictionCoefficient , numberOfPoints , torsionalFrictionCoefficient , feet_size , fZmin );
0 commit comments