@@ -149,7 +149,7 @@ def _contact_patch_summary(contact_points: np.ndarray) -> str:
149149 )
150150
151151
152- class TSIDFixedComController :
152+ class TSIDController :
153153 def __init__ (
154154 self ,
155155 urdf_path : Path ,
@@ -173,7 +173,7 @@ def __init__(
173173 self .left_foot_id = self ._get_frame_id (left_foot_frame )
174174 self .right_foot_id = self ._get_frame_id (right_foot_frame )
175175
176- self .invdyn = tsid .InverseDynamicsFormulationAccForce ("tsid-fixed-com " , self .robot , False )
176+ self .invdyn = tsid .InverseDynamicsFormulationAccForce ("tsid" , self .robot , False )
177177 self .invdyn .computeProblemData (0.0 , q0 , self .v0 )
178178
179179 self ._add_foot_contacts ()
@@ -192,11 +192,13 @@ def _get_frame_id(self, frame_name: str) -> int:
192192 def _add_foot_contacts (self ):
193193 mu = 0.5
194194 f_min = 1.0
195- f_max = 2000 .0
195+ f_max = 1000 .0
196196 contact_normal = np .array ([0.0 , 0.0 , 1.0 ])
197197
198- kp_contact = 50 .0
198+ kp_contact = 30 .0
199199 kd_contact = 2.0 * math .sqrt (kp_contact )
200+
201+ # Weight for contact force regularization in the cost
200202 w_force_reg = 1e-5
201203
202204 self .contact_left = tsid .Contact6d (
@@ -241,22 +243,30 @@ def _add_com_task(self):
241243 self .com_task = tsid .TaskComEquality ("task-com" , self .robot )
242244 self .com_task .setKp (kp_com * np .ones (3 ))
243245 self .com_task .setKd (kd_com * np .ones (3 ))
244- self .invdyn .addMotionTask (self .com_task , w_com , 1 , 0.0 )
246+ self .invdyn .addMotionTask (self .com_task , w_com , 0 , 0.0 )
245247
246248 def _add_waist_task (self ):
247249 kp_waist = 500.0
248- kd_waist = 2.0 * math .sqrt (kp_com )
250+ kd_waist = 2.0 * math .sqrt (kp_waist )
249251 w_waist = 1.0
250252
251253 self .waist_task = tsid .TaskSE3Equality ("task-waist" , self .robot , "root_joint" )
252254 self .waist_task .setKp (kp_waist * np .ones (6 ))
253255 self .waist_task .setKd (kd_waist * np .ones (3 ))
256+
257+ # Add a Mask to the task which will select the vector dimensions on which the task will act.
258+ # In this case the waist configuration is a vector 6d (position and orientation -> SE3)
259+ # Here we set a mask = [0 0 0 1 1 1] so the task on the waist will act on the orientation of the robot
260+ mask = np .ones (6 )
261+ mask [:3 ] = 0.0
262+ self .waist_task .setMask (mask )
263+ # Add the task to the HQP with weight = 1.0, priority level = 1 (in the cost function) and a transition duration = 0.0
254264 self .invdyn .addMotionTask (self .waist_task , w_waist , 1 , 0.0 )
255265
256266 def _add_posture_task (self , q0 : np .ndarray ):
257- kp_posture = 2 .0
267+ kp_posture = 1 .0
258268 kd_posture = 2.0 * math .sqrt (kp_posture )
259- w_posture = 0.05
269+ w_posture = 0.1
260270
261271 self .posture_task = tsid .TaskJointPosture ("task-posture" , self .robot )
262272 self .posture_task .setKp (kp_posture * np .ones (self .robot .nv - 6 ))
@@ -347,7 +357,7 @@ def main():
347357 print (f"Left TSID contact patch from URDF: { _contact_patch_summary (left_contact_points )} " )
348358 print (f"Right TSID contact patch from URDF: { _contact_patch_summary (right_contact_points )} " )
349359
350- controller = TSIDFixedComController (
360+ controller = TSIDController (
351361 urdf_path = urdf_path ,
352362 package_root = package_root ,
353363 q0 = q_init ,
0 commit comments