Skip to content

Commit 0645c2e

Browse files
committed
Reproduce same behavior
1 parent 2f62cc3 commit 0645c2e

3 files changed

Lines changed: 26 additions & 37 deletions

File tree

biped_walking_controller/foot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def compute_swing_foot_pose(
511511
"""
512512
t_ss = params.t_ss
513513

514-
if True: # t_state <= t_ss:
514+
if t_state <= t_ss:
515515
# Normal swing phase
516516
s = np.clip(t_state / t_ss, 0.0, 1.0)
517517

biped_walking_controller/state_machine.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ def _try_transition_to_ds_or_end(self, t: float, contact_force: float):
197197
Otherwise the state transitions to DS and the step index is incremented.
198198
"""
199199
if (
200-
t - self.t_start
201-
> self.params.t_ss
202-
# and contact_force > self.params.force_threshold
200+
t - self.t_start > 0.5 * self.params.t_ss
201+
and contact_force > self.params.force_threshold
203202
):
204203
self.t_start = t
205204
self.state = WalkingState.END if self._is_last_step() else WalkingState.DS

examples/example_5_walking_controller.py

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
WalkingStateMachineParams,
3737
WalkingStateMachine,
3838
WalkingState,
39+
Foot,
3940
)
4041

4142

@@ -55,7 +56,7 @@ def main():
5556
t_ds = 0.3 # Double support phase time window
5657
t_init = 2.0 # Initialization phase (transition from still position to first step)
5758
t_end = 0.4
58-
n_steps = 5 # Number of steps executed by the robot
59+
n_steps = 15 # Number of steps executed by the robot
5960
l_stride = 0.1 # Length of the stride
6061
max_height_foot = 0.01 # Maximal height of the swing foot
6162

@@ -267,8 +268,7 @@ def main():
267268
lf_start = steps_pose[step_idx - 1]
268269
lf_target = steps_pose[step_idx + 1]
269270

270-
rf_pose = oMf_rf_tgt.translation
271-
271+
rf_pose = steps_pose[step_idx]
272272
lf_pose = compute_swing_foot_pose(
273273
t_state=state_machine.get_elapsed_time_in_state(k * dt),
274274
params=params,
@@ -283,23 +283,11 @@ def main():
283283
q_des, dq = solve_inverse_kinematics(
284284
q_init,
285285
com_target,
286-
oMf_fixed_foot=oMf_rf_tgt,
286+
oMf_fixed_foot=pin.SE3(oMf_rf_tgt.rotation, rf_pose),
287287
oMf_moving_foot=oMf_lf,
288288
oMf_torso=oMf_torso,
289289
params=ik_sol_params,
290290
)
291-
292-
lf_next = compute_swing_foot_pose(
293-
t_state=state_machine.get_elapsed_time_in_state((k + 1) * dt),
294-
params=params,
295-
step_start=lf_start,
296-
step_target=lf_target,
297-
swing_height=max_height_foot,
298-
touchdown_extension_vel=touchdown_vel,
299-
path_generator=generator,
300-
)
301-
302-
oMf_lf_tgt = pin.SE3(oMf_lf_tgt.rotation, lf_next)
303291
elif state_machine.get_current_state() == WalkingState.SS_LEFT:
304292
if step_idx < 2:
305293
rf_start = rf_initial_pose
@@ -311,7 +299,7 @@ def main():
311299
ik_sol_params.fixed_foot_frame = talos.left_foot_id
312300
ik_sol_params.moving_foot_frame = talos.right_foot_id
313301

314-
lf_pose = oMf_lf_tgt.translation
302+
lf_pose = steps_pose[step_idx]
315303
rf_pose = compute_swing_foot_pose(
316304
t_state=state_machine.get_elapsed_time_in_state(k * dt),
317305
params=params,
@@ -326,35 +314,37 @@ def main():
326314
q_des, dq = solve_inverse_kinematics(
327315
q_init,
328316
com_target,
329-
oMf_fixed_foot=oMf_lf_tgt,
317+
oMf_fixed_foot=pin.SE3(oMf_lf_tgt.rotation, lf_pose),
330318
oMf_moving_foot=oMf_rf,
331319
oMf_torso=oMf_torso,
332320
params=ik_sol_params,
333321
)
322+
elif state_machine.get_current_state() == WalkingState.END:
334323

335-
rf_next = compute_swing_foot_pose(
336-
t_state=state_machine.get_elapsed_time_in_state((k + 1) * dt),
337-
params=params,
338-
step_start=rf_start,
339-
step_target=rf_target,
340-
swing_height=max_height_foot,
341-
touchdown_extension_vel=touchdown_vel,
342-
path_generator=generator,
343-
)
344-
345-
oMf_rf_tgt = pin.SE3(oMf_rf_tgt.rotation, rf_next)
346324
else:
347-
lf_pose = oMf_lf_tgt.translation
348-
rf_pose = oMf_rf_tgt.translation
325+
if steps_ids[step_idx] == Foot.RIGHT:
326+
if step_idx == 0:
327+
rf_pose = steps_pose[step_idx]
328+
lf_pose = lf_initial_pose
329+
else:
330+
rf_pose = steps_pose[step_idx]
331+
lf_pose = steps_pose[step_idx - 1]
332+
else:
333+
if step_idx == 0:
334+
rf_pose = rf_initial_pose
335+
lf_pose = steps_pose[step_idx]
336+
else:
337+
rf_pose = steps_pose[step_idx - 1]
338+
lf_pose = steps_pose[step_idx]
349339

350340
ik_sol_params.fixed_foot_frame = talos.left_foot_id
351341
ik_sol_params.moving_foot_frame = talos.right_foot_id
352342

353343
q_des, dq = solve_inverse_kinematics(
354344
q_init,
355345
com_target,
356-
oMf_fixed_foot=oMf_lf_tgt,
357-
oMf_moving_foot=oMf_rf_tgt,
346+
oMf_fixed_foot=pin.SE3(oMf_lf_tgt.rotation, lf_pose),
347+
oMf_moving_foot=pin.SE3(oMf_rf_tgt.rotation, rf_pose),
358348
oMf_torso=oMf_torso,
359349
params=ik_sol_params,
360350
)

0 commit comments

Comments
 (0)