45
45
JTorso ;
46
46
SaturationMinJoints ;
47
47
SaturationMaxJoints ;
48
+ J_com ;
49
+
48
50
end
49
51
50
52
methods (Access = protected )
@@ -289,15 +291,16 @@ function setupImpl(obj,M,h,Jc,Jcmm,nu_k,Jc_dot_nu,C_friction,b_friction,H_star,s
289
291
obj.JTorso= obj .casadi_optimizer .parameter(6 ,NDOF + 6 );
290
292
obj.SaturationMaxJoints = obj .casadi_optimizer .parameter(NDOF );
291
293
obj.SaturationMinJoints = obj .casadi_optimizer .parameter(NDOF );
294
+ obj.J_com = obj .casadi_optimizer .parameter(6 ,NDOF + 6 );
292
295
293
296
% Weigth
294
297
Weigth.PosturalTask = 100 ;
295
298
Weigth.MomentumLinear = 2.0 ;
296
299
Weigth.MomentumAngular = 30.00 ;
297
300
Weigth.RegTorques = 0.001 ;
298
- Weigth.RegVelocities = 10 ;
301
+ Weigth.RegVelocities = 128 ;
299
302
Weigth.Wrenches = 0.01 ;
300
- Weigth.HolonomicConstraint = 0.0001 ;
303
+ Weigth.HolonomicConstraint = 10 ;
301
304
% Selector Matrix
302
305
303
306
B = [ zeros(6 ,NDOF ); ...
@@ -307,8 +310,8 @@ function setupImpl(obj,M,h,Jc,Jcmm,nu_k,Jc_dot_nu,C_friction,b_friction,H_star,s
307
310
obj .casadi_optimizer .minimize(Weigth .RegTorques * sumsqr(obj .tau_k - obj .tau_meas )+ ... % Torque Regularization
308
311
Weigth .RegVelocities * sumsqr(nu_k_1(1 : 6 ))+ ... % Base Velocity Regularization
309
312
Weigth .PosturalTask * sumsqr(obj .s_dot_k_1 - obj .s_dot_star )); ... % Postural Task
313
+ % Weigth.HolonomicConstraint*(1-obj.holonomicConstraintActivation)*sumsqr(obj.Jc*(nu_k_1))); ... %HolonomicCOnstraint
310
314
% Weigth.Wrenches*sumsqr(obj.f_k) + ... %Wrenches
311
- % Weigth.HolonomicConstraint*sumsqr(obj.Jc*(nu_k_1))); ... %HolonomicCOnstraint
312
315
% Weigth.MomentumAngular*sumsqr(obj.H_star(4:6)-obj.Jcmm(4:6,:)*nu_k_1)); ... % Angular Momentum
313
316
% Weigth.MomentumLinear*sumsqr(obj.H_star(1:3)-obj.Jcmm(1:3,:)*nu_k_1)); ... % Linear Momentum
314
317
@@ -325,20 +328,20 @@ function setupImpl(obj,M,h,Jc,Jcmm,nu_k,Jc_dot_nu,C_friction,b_friction,H_star,s
325
328
obj .casadi_optimizer .subject_to(obj .C_friction * obj .f_k < obj .b_friction );
326
329
327
330
%% Constraint on the CoM Velocity
328
- obj .casadi_optimizer .subject_to(obj .Jcmm (1 ,: )*nu_k_1 <(tanh(obj .epsilon_CoM *(obj .CoM_max(1 )-obj .CoM_measured(1 )))*obj .CoM_vel_max(1 )));
329
- obj .casadi_optimizer .subject_to(obj .Jcmm (1 ,: )*nu_k_1 >(tanh(obj .epsilon_CoM *(obj .CoM_measured(1 )-obj .CoM_min(1 )))*obj .CoM_vel_min(1 )));
330
- obj .casadi_optimizer .subject_to(obj .Jcmm (2 ,: )*nu_k_1 <(tanh(obj .epsilon_CoM *(obj .CoM_max(2 )-obj .CoM_measured(2 )))*obj .CoM_vel_max(2 )));
331
- obj .casadi_optimizer .subject_to(obj .Jcmm (2 ,: )*nu_k_1 >(tanh(obj .epsilon_CoM *(obj .CoM_measured(2 )-obj .CoM_min(2 )))*obj .CoM_vel_min(2 )));
331
+ obj .casadi_optimizer .subject_to(obj .J_com (1 ,: )*nu_k_1 <= (tanh(obj .epsilon_CoM *(obj .CoM_max(1 )-obj .CoM_measured(1 )))*obj .CoM_vel_max(1 )));
332
+ obj .casadi_optimizer .subject_to(obj .J_com (1 ,: )*nu_k_1 >= (tanh(obj .epsilon_CoM *(obj .CoM_measured(1 )-obj .CoM_min(1 )))*obj .CoM_vel_min(1 )));
333
+ obj .casadi_optimizer .subject_to(obj .J_com (2 ,: )*nu_k_1 <= (tanh(obj .epsilon_CoM *(obj .CoM_max(2 )-obj .CoM_measured(2 )))*obj .CoM_vel_max(2 )));
334
+ obj .casadi_optimizer .subject_to(obj .J_com (2 ,: )*nu_k_1 >= (tanh(obj .epsilon_CoM *(obj .CoM_measured(2 )-obj .CoM_min(2 )))*obj .CoM_vel_min(2 )));
332
335
333
336
% Constraint the Torso velocity on the z axis
334
- % obj.casadi_optimizer.subject_to(obj.ActivateComHeightConstraint*obj.Jcmm(3,: )*nu_k_1 >= obj.ActivateComHeightConstraint*obj.M(1,1)*obj.CoM_Z_reference_velocity);
337
+ % obj.casadi_optimizer.subject_to(obj.ActivateComHeightConstraint*obj.Jcmm(3,7:end )*nu_k_1(7:end) >= obj.ActivateComHeightConstraint*obj.M(1,1)*obj.CoM_Z_reference_velocity);
335
338
obj .casadi_optimizer .subject_to(obj .ActivateComHeightConstraint * obj .JTorso(3 ,: )*nu_k_1 >= obj .ActivateComHeightConstraint * obj .CoM_Z_reference_velocity );
336
-
339
+ %
337
340
% Angular Momentum
338
341
% With Control Law
339
342
% obj.casadi_optimizer.subject_to(obj.H_star(4:6,:)==obj.Jcmm(4:6,:)*nu_k_1);
340
343
% Setting to Zero
341
- obj .casadi_optimizer .subject_to(obj .Jcmm(4 : 6 ,: )*nu_k_1 == zeros(3 ,1 ));
344
+ % obj.casadi_optimizer.subject_to(obj.Jcmm(4:6,:)*nu_k_1 == zeros(3,1));
342
345
% THE BOUND FOR NOW ARE DE-ACTIVATED
343
346
% Setting upper and lower bound
344
347
% Lower and Upper Bound NOTE by using a casadi optimizer object, we loose the capability of interpreting the lower and
@@ -408,6 +411,7 @@ function setupImpl(obj,M,h,Jc,Jcmm,nu_k,Jc_dot_nu,C_friction,b_friction,H_star,s
408
411
obj .casadi_optimizer .set_value(obj .feet_correction , correctionFeet );
409
412
obj .casadi_optimizer .set_value(obj .holonomicConstraintActivation , activateHolonomicConstraint );
410
413
obj .casadi_optimizer .set_value(obj .JTorso ,JTorso );
414
+ obj .casadi_optimizer .set_value(obj .J_com ,J_com );
411
415
% obj.casadi_optimizer.set_value(obj.SaturationMaxJoints,jointsVelocitySat(:,2));
412
416
% obj.casadi_optimizer.set_value(obj.SaturationMinJoints, jointsVelocitySat(:,1));
413
417
0 commit comments