Locomotion 控制完整示例
本示例演示站姿调整与速度控制的完整工作流程:切换到 PdStand 状态后发送站姿调整命令,切换到 RL Locomotion 状态后发送速度命令。
涉及状态: PdStand 状态、RL 行走状态
涉及接口: set_stand_pose、set_velocity、set_velocity_source
Python
from fourier_aurora_client import AuroraClient
import time
client = AuroraClient.get_instance(domain_id=123, robot_name='gr3')
print("Initializing motion control demo...")
# Step 1: Switch to PdStand
input("Press Enter to set FSM to PdStand State (state 2)...")
client.set_fsm_state(2)
time.sleep(1.0)
# Step 2: Stand pose adjustment
input("Press Enter to start crouching and stand up...")
print("Adjusting stand pose to 0.10 meter lower...")
client.set_stand_pose(-0.10, 0.0, 0.0)
time.sleep(2.0)
print(f"Current Stand pose: {client.get_stand_pose()}")
print("Returning to default pose...")
client.set_stand_pose(0.0, 0.0, 0.0)
time.sleep(2.0)
# Step 3: Switch to RL Locomotion
input("Press Enter to set FSM to RL Locomotion State (state 3)...")
client.set_fsm_state(3)
client.set_velocity_source(2)
time.sleep(0.5)
# Step 4: Velocity commands
input("Press Enter to send velocity commands...")
print("Moving forward at 0.2 m/s")
client.set_velocity(0.2, 0.0, 0.0, 5.0)
time.sleep(5.0)
print("Moving left at 0.2 m/s")
client.set_velocity(0.0, 0.2, 0.0, 5.0)
time.sleep(5.0)
print("Rotating anti-clockwise at 0.4 rad/s")
client.set_velocity(0.0, 0.0, 0.4, 5.0)
time.sleep(5.0)
print("Stopping")
client.set_velocity(0.0, 0.0, 0.0, 1.0)
time.sleep(1.0)
print("Motion command demonstration complete")
client.close()