Skip to content

Commit a5b875f

Browse files
committed
idek
1 parent bb5d7eb commit a5b875f

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

‎parol6/commands/cartesian_commands.py‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,28 @@ def do_setup(self, state: "ControllerState") -> None:
300300
logger.log(TRACE, " -> Trajectory prepared with %s steps.", len(self.trajectory_steps))
301301

302302
def execute_step(self, state: "ControllerState") -> ExecutionStatus:
303-
if self.command_step >= len(self.trajectory_steps):
303+
n = len(self.trajectory_steps)
304+
if self.command_step >= n:
304305
logger.info(f"{type(self).__name__} finished.")
305306
self.is_finished = True
306307
self.stop_and_idle(state)
307308
return ExecutionStatus.completed("MOVEPOSE complete")
308309
else:
309-
self.set_move_position(state, self.trajectory_steps[self.command_step])
310-
self.command_step += 1
310+
# Advance multiple trajectory steps per tick proportional to measured loop period
311+
dt_eff = float(getattr(state, "ema_period_s", 0.0)) if getattr(state, "ema_period_s", 0.0) > 0.0 else float(INTERVAL_S)
312+
steps_per_tick = max(1, int(round(dt_eff / float(INTERVAL_S))))
313+
next_idx = min(n - 1, self.command_step + steps_per_tick)
314+
self.set_move_position(state, self.trajectory_steps[next_idx])
315+
self.command_step = next_idx + 1
316+
if self.command_step >= n:
317+
logger.info("MovePoseCommand finished.")
318+
self.is_finished = True
319+
self.stop_and_idle(state)
320+
return ExecutionStatus.completed("MOVEPOSE complete")
311321
return ExecutionStatus.executing("MovePose")
312322

313323

324+
314325
@register_command("MOVECART")
315326
class MoveCartCommand(MotionCommand):
316327
"""
@@ -444,17 +455,18 @@ def execute_step(self, state: "ControllerState") -> ExecutionStatus:
444455
return ExecutionStatus.completed("MOVECART complete")
445456
# Wall-clock progress
446457
s_wall = float(self.progress01(dur))
447-
# Ensure bounded per-tick progress toward s_wall
448-
if self._s_step <= 0.0 and dur > 0.0:
449-
self._s_step = INTERVAL_S / dur
450-
s_next = self._s + self._s_step
458+
# Ensure bounded per-tick progress toward s_wall using measured loop period
459+
dt_eff = float(getattr(state, "ema_period_s", 0.0)) if getattr(state, "ema_period_s", 0.0) > 0.0 else float(INTERVAL_S)
460+
s_step = dt_eff / dur
461+
s_next = self._s + s_step
451462
if s_next > s_wall:
452463
s_next = s_wall
453464
if s_next > 1.0:
454465
s_next = 1.0
455466
s_scaled = quintic_scaling(float(s_next))
456467

457468

469+
458470
assert self.initial_pose is not None and self.target_pose is not None
459471
_ctp = cast(SE3, self.initial_pose).interp(cast(SE3, self.target_pose), s_scaled)
460472
if not isinstance(_ctp, SE3):

0 commit comments

Comments
 (0)