FSM 控制
set_fsm_state()
Python
set_fsm_state(state: int) -> bool
切换整机 FSM 状态。成功返回 True,超时或被拒绝返回 False。
| 参数 | 类型 | 说明 |
|---|---|---|
state | int | 目标状态的 DDS 映射值,见下表 |
可用状态参见 状态和任务概览。UserController_* 到实际算法的映射由机器人上的 user_runner_config.yaml 定义。
示例
Python
client.set_fsm_state(2) # 切换到 PdStand
time.sleep(1.0) # 等待新 task 加载稳定
get_fsm_state()
Python
get_fsm_state() -> int
返回当前整机 FSM 状态的 DDS 映射值。
get_fsm_name()
Python
get_fsm_name() -> str
返回当前整机 FSM 状态的名称字符串,例如 "PdStand"。
示例
Python
print(client.get_fsm_state()) # 2
print(client.get_fsm_name()) # "PdStand"
set_upper_fsm_state()
Python
set_upper_fsm_state(state: int) -> bool
切换上半身 FSM 状态。成功返回 True,超时或被拒绝返回 False。仅在整机处于支持上半身管理的状态(如 RL Locomotion)时有效。
| 值 | 状态 | 说明 |
|---|---|---|
| 0 | Default | 无上半身任务 |
| 1 | UpperBodyActState | 摆臂 |
| 2 | RemoteState | 上半身遥操作(关节控制) |
示例
Python
client.set_fsm_state(3) # 切换到 RL Locomotion
time.sleep(1.0)
client.set_upper_fsm_state(1) # 开启摆臂
get_upper_fsm_state()
Python
get_upper_fsm_state() -> int
返回当前上半身 FSM 状态的 DDS 映射值。
get_upper_fsm_name()
Python
get_upper_fsm_name() -> str
返回当前上半身 FSM 状态的名称字符串。