Skip to content

Commit 2a06947

Browse files
author
Gabriele Nava
authored
Merge pull request #112 from CarlottaSartore/VelocityControllerPreparationForJumping
Velocity controller preparation for jumping
2 parents 32ba3a1 + ebb2aa4 commit 2a06947

File tree

5 files changed

+181
-55
lines changed

5 files changed

+181
-55
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
function [J_c, J_c_dot_nu] = ComputeContactJacobianWithFeetContactFCN(J_L, J_R, J_dot_nu_L, J_dot_nu_R, feet_contact_status)
1+
function [J_c, J_c_dot_nu, holonomicConstraintActivation] = ComputeContactJacobianWithFeetContactFCN(J_L, J_R, J_dot_nu_L, J_dot_nu_R, feet_contact_status)
22

33
NDOF = length(J_L(1,7:end));
44

55
J_c = zeros(12,6+NDOF);
66
J_c_dot_nu = zeros(12,1);
7-
7+
holonomicConstraintActivation = 0.0;
88
% if left foot in contact
99
if(feet_contact_status(1))
1010
J_c (1:6,:) = J_L;
1111
J_c_dot_nu(1:6) = J_dot_nu_L;
12+
holonomicConstraintActivation= 1.0;
1213
end
1314

1415
% if right foot in contact
1516
if(feet_contact_status(2))
1617
J_c(7:end,:) = J_R;
1718
J_c_dot_nu(7:end) = J_dot_nu_R;
19+
holonomicConstraintActivation = 1.0
1820
end
1921

2022
end
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
function [L_star, L_dot_star, s_dot_star_k_1] = ComputeReferences(x_com, x_d_com, L, L_dot_d, Ld, int_L_angular, s_dot_des_k_1, s_des_k, s_k, totalMass,Gains)
1+
function [L_star, L_dot_star, s_dot_star_k_1] = ComputeReferences(x_com, x_d_com, L, L_dot_d, Ld, int_L_angular, s_dot_des_k_1, s_des_k, s_k, totalMass, KpPostural,Gains)
22

33
L_int_lin = Gains.KP_CoM*totalMass*(x_com - x_d_com);
44
L_int_ang = Gains.KI_ang*(int_L_angular);
55
L_int = [L_int_lin; L_int_ang];
66
L_star = Ld-L_int;
77

8-
L_dot_star = L_dot_d -blkdiag(Gains.KD_CoM, Gains.KP_ang)*(L-Ld) -L_int;
9-
10-
s_dot_star_k_1 = s_dot_des_k_1 - Gains.KP_Postural*(s_k-s_des_k);
11-
8+
L_dot_star = L_dot_d -blkdiag(Gains.KD_CoM, Gains.KP_ang)*(L-Ld) -L_int;
9+
s_dot_star_k_1 = s_dot_des_k_1 - KpPostural*(s_k-s_des_k);
10+
%s_dot_star_k_1 = s_dot_des_k_1 - Gains.KP_Postural*(s_k-s_des_k);
1211
end
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,94 @@
1-
function [L_d_n, L_dot_d, int_L_ang, x_com_des, s_des_k, s_dot_des_k] = ComputeReferencesController(M,L,desired_pos_vel_COM, joint_pos, joint_pos_desired,joint_vel_desired, L_ang_des,L_d)
1+
% function [L_d_n, L_dot_d, int_L_ang, x_com_des, s_des_k, s_dot_des_k] = ComputeReferencesController(M,L,desired_pos_vel_COM, joint_pos, joint_pos_desired,joint_vel_desired, L_ang_des,L_d)
2+
3+
% persistent L_0;
4+
%
5+
% if(isempty(L_0))
6+
% L_0 = L;
7+
% end
8+
%
9+
% persistent joint_pos_0;
10+
%
11+
% if(isempty(joint_pos_0))
12+
% joint_pos_0 = joint_pos;
13+
% end
14+
%
15+
% L_d_n = zeros(6,1);
16+
% L_dot_d = zeros(6,1);
17+
% L_d_n(1:3) = M(1,1)*desired_pos_vel_COM(:,2)';
18+
% %L_d_n(4:6) = L_d(4:6);
19+
% int_L_ang = zeros(3,1);
20+
% x_com_des = desired_pos_vel_COM(:,1);
21+
% s_des_k = joint_pos_desired;
22+
% s_dot_des_k = joint_vel_desired;
23+
function [L_d_n, L_dot_d, int_L_ang, x_com_des, s_des_k, s_dot_des_k, vel_feet_correction] = ComputeReferencesController(M,L,desired_pos_vel_COM, joint_pos, joint_pos_desired,joint_vel_desired, L_ang_des,L_d, w_H_l, w_H_r,Cs, Gains)
224

325
persistent L_0;
426

27+
persistent w_H_l_0;
28+
29+
persistent w_H_r_0;
30+
31+
persistent z_0;
32+
33+
persistent joint_pos_0;
34+
35+
persistent Cs_old ;
36+
537
if(isempty(L_0))
638
L_0 = L;
739
end
840

9-
persistent joint_pos_0;
41+
if(isempty(Cs_old))
42+
Cs_old = Cs;
43+
end
1044

1145
if(isempty(joint_pos_0))
1246
joint_pos_0 = joint_pos;
1347
end
1448

49+
%%TODO could also check on the contact status,to update it each time the
50+
%%contact is restored.
51+
52+
53+
if (isempty(w_H_r_0))
54+
w_H_r_0 = w_H_r;
55+
end
56+
57+
if(isempty(w_H_l_0))
58+
w_H_l_0 = w_H_l;
59+
end
60+
61+
if(isempty(z_0))
62+
z_0 = w_H_l(3,4);
63+
end
64+
65+
% For now we are assuming that one foot is always in contact, we will
66+
% discard this assumption for performing the jump
67+
% Updating only the position, we want to keep the original orientation
68+
if(~Cs_old(1) && Cs(1))
69+
w_H_l_0(1,4) = w_H_l(1,4);
70+
w_H_l_0(2,4) = w_H_l(2,4);
71+
w_H_l_0(3,4) = z_0;
72+
end
73+
74+
% Updating only the position, we want to keep the original orientation
75+
if(~Cs_old(2) && Cs(2))
76+
w_H_r_0(1,4) = w_H_r(1,4);
77+
w_H_r_0(2,4) = w_H_r(2,4);
78+
w_H_r_0(1:3,1:3)
79+
w_H_r_0(3,4) = z_0;
80+
end
81+
82+
vel_feet_correction = zeros(12,1);
83+
if(Cs(1))
84+
vel_feet_correction(1:3) = diag(Gains.Kp_feet_correction)*(w_H_l(1:3,4)- w_H_l_0(1:3,4));
85+
vel_feet_correction(4:6) = Gains.Kp_feet_correction_angular* wbc.skewVee(w_H_l(1:3,1:3)*transpose(w_H_l_0(1:3,1:3)));
86+
end
87+
88+
if(Cs(2))
89+
vel_feet_correction(7:9) = diag(Gains.Kp_feet_correction)*(w_H_r(1:3,4)- w_H_r_0(1:3,4));
90+
vel_feet_correction(10:12) = Gains.Kp_feet_correction_angular* wbc.skewVee(w_H_r(1:3,1:3)*transpose(w_H_r_0(1:3,1:3)));
91+
end
1592
L_d_n = zeros(6,1);
1693
L_dot_d = zeros(6,1);
1794
L_d_n(1:3) = M(1,1)*desired_pos_vel_COM(:,2)';
@@ -21,5 +98,7 @@
2198
s_des_k = joint_pos_desired;
2299
s_dot_des_k = joint_vel_desired;
23100

101+
Cs_old = Cs;
24102

25103
end
104+

0 commit comments

Comments
 (0)