Skip to content

Commit db45191

Browse files
committed
Fix tsid
1 parent f60255f commit db45191

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

examples/example_5_tsid_com_shift.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ def __init__(
166166
self.model = self.robot.model()
167167
self.v0 = np.zeros(self.robot.nv)
168168

169-
self.left_foot_frame = left_foot_frame
170-
self.right_foot_frame = right_foot_frame
169+
self.left_foot_frame = "leg_left_6_joint"
170+
self.right_foot_frame = "leg_right_6_joint"
171171
self.left_contact_points = left_contact_points
172172
self.right_contact_points = right_contact_points
173173
self.left_foot_id = self._get_frame_id(left_foot_frame)
@@ -194,22 +194,33 @@ def _get_frame_id(self, frame_name: str) -> int:
194194
return frame_id
195195

196196
def _add_foot_contacts(self):
197-
mu = 0.5
197+
mu = 0.3
198198
f_min = 1.0
199199
f_max = 1000.0
200200
contact_normal = np.array([0.0, 0.0, 1.0])
201201

202+
lxp = 0.1 # foot length in positive x direction
203+
lxn = 0.11 # foot length in negative x direction
204+
lyp = 0.069 # foot length in positive y direction
205+
lyn = 0.069 # foot length in negative y direction
206+
lz = 0.107 # foot sole height with respect to ankle joint
207+
208+
contact_point = np.ones((3, 4)) * lz
209+
contact_point[0, :] = [-lxn, -lxn, lxp, lxp]
210+
contact_point[1, :] = [-lyn, lyp, -lyn, lyp]
211+
202212
kp_contact = 30.0
203213
kd_contact = 2.0 * math.sqrt(kp_contact)
204214

205215
# Weight for contact force regularization in the cost
206216
w_force_reg = 1e-5
207217

218+
# Left foot
208219
self.contact_left = tsid.Contact6d(
209220
"contact-left",
210221
self.robot,
211222
self.left_foot_frame,
212-
self.left_contact_points,
223+
contact_point,
213224
contact_normal,
214225
mu,
215226
f_min,
@@ -218,15 +229,15 @@ def _add_foot_contacts(self):
218229
self.contact_left.setKp(kp_contact * np.ones(6))
219230
self.contact_left.setKd(kd_contact * np.ones(6))
220231
self.contact_left.setReference(
221-
self.robot.framePosition(self.invdyn.data(), self.left_foot_id)
232+
self.robot.position(self.data, self.model.getJointId(self.left_foot_frame))
222233
)
223-
self.invdyn.addRigidContact(self.contact_left, w_force_reg, 1.0, 1)
234+
self.invdyn.addRigidContact(self.contact_left, w_force_reg, 1.0, 0)
224235

225236
self.contact_right = tsid.Contact6d(
226237
"contact-right",
227238
self.robot,
228239
self.right_foot_frame,
229-
self.right_contact_points,
240+
contact_point,
230241
contact_normal,
231242
mu,
232243
f_min,
@@ -235,9 +246,9 @@ def _add_foot_contacts(self):
235246
self.contact_right.setKp(kp_contact * np.ones(6))
236247
self.contact_right.setKd(kd_contact * np.ones(6))
237248
self.contact_right.setReference(
238-
self.robot.framePosition(self.invdyn.data(), self.right_foot_id)
249+
self.robot.position(self.data, self.model.getJointId(self.right_foot_frame))
239250
)
240-
self.invdyn.addRigidContact(self.contact_right, w_force_reg, 1.0, 1)
251+
self.invdyn.addRigidContact(self.contact_right, w_force_reg, 1.0, 0)
241252

242253
def _add_com_task(self):
243254
kp_com = 20.0

0 commit comments

Comments
 (0)