StopState implementation
Prevent hard Servo movements to Idle Position
This commit is contained in:
@@ -217,6 +217,9 @@ class Robot:
|
||||
return kin.ikpyForward(rads)
|
||||
|
||||
def transition_to(self, next_state_key: str) -> None:
|
||||
if next_state_key == "idle" and self.current_state_key not in ("idle", "stopping"):
|
||||
next_state_key = "stopping"
|
||||
|
||||
if next_state_key in STATE_REGISTRY and next_state_key != self.current_state_key:
|
||||
self.current_state.exit(self)
|
||||
self.current_state_key = next_state_key
|
||||
@@ -240,6 +243,18 @@ class Robot:
|
||||
self.apply_rl_action_delta(action)
|
||||
|
||||
else: # "kinematics" / standard State Machine execution
|
||||
has_motion_command = (
|
||||
abs(vx) > 0.01
|
||||
or abs(vy) > 0.01
|
||||
or abs(omega) > 0.01
|
||||
or self.robot_state in ("wave", "laola")
|
||||
)
|
||||
if (
|
||||
self.current_state_key not in ("idle", "stopping", "walking", "walking_four")
|
||||
and not has_motion_command
|
||||
):
|
||||
self.transition_to("stopping")
|
||||
|
||||
next_state_key = self.current_state.execute(self)
|
||||
if next_state_key:
|
||||
self.transition_to(next_state_key)
|
||||
|
||||
Reference in New Issue
Block a user