refactor(base_move): adjust moving strategy and update task execution
- Set msg.duration to 0 in move_to_hori_line to wait for next command - Update task_1 execution flow based on QR code result - Modify BaseMsg.stop() to use gait_id 27 for stopping - Comment out smooth stop and use normal stop in move_to_hori_line
This commit is contained in:
parent
b02c2aea88
commit
214cc13c65
@ -285,7 +285,7 @@ def move_to_hori_line(ctrl, msg, target_distance=0.5, observe=False):
|
||||
|
||||
# 估算移动时间,但实际上会通过里程计控制
|
||||
move_time = abs(distance_to_move) / move_speed
|
||||
msg.duration = int((move_time + 2) * 1000) # 加一点余量,确保有足够时间移动
|
||||
msg.duration = 0 # wait next cmd
|
||||
msg.step_height = [0.06, 0.06] # 抬腿高度
|
||||
msg.life_count += 1
|
||||
|
||||
@ -311,7 +311,8 @@ def move_to_hori_line(ctrl, msg, target_distance=0.5, observe=False):
|
||||
time.sleep(0.05) # 小间隔检查位置
|
||||
|
||||
# 使用平滑停止
|
||||
ctrl.base_msg.stop_smooth()
|
||||
# ctrl.base_msg.stop_smooth()
|
||||
ctrl.base_msg.stop()
|
||||
|
||||
if observe:
|
||||
print(f"移动完成,平稳停止,通过里程计计算的移动距离: {distance_moved:.3f}米")
|
||||
|
@ -37,23 +37,16 @@ def run_task_1(ctrl, msg):
|
||||
move_to_hori_line(ctrl, msg, target_distance=1, observe=observe)
|
||||
|
||||
print('😺 task 1 - 3')
|
||||
# 在第二次旋转操作中也启用 QR 码扫描
|
||||
turn_success, qr_result = arc_turn_around_hori_line(
|
||||
direction = True if qr_result == 'A-2' else False
|
||||
turn_success = arc_turn_around_hori_line(
|
||||
ctrl=ctrl,
|
||||
msg=msg,
|
||||
angle_deg=180,
|
||||
target_distance=0.4,
|
||||
left=True,
|
||||
target_distance=0.5,
|
||||
left=direction,
|
||||
observe=observe,
|
||||
scan_qrcode=True,
|
||||
qr_check_interval=0.3
|
||||
)
|
||||
|
||||
if qr_result:
|
||||
print(f"🎯 在任务 1-3 中成功扫描到 QR 码: {qr_result}")
|
||||
else:
|
||||
print("⚠️ 任务 1-3 中未能扫描到任何 QR 码")
|
||||
|
||||
return
|
||||
|
||||
print('😺 task 1 - 4')
|
||||
|
@ -6,6 +6,9 @@ class BaseMsg:
|
||||
self.msg = msg
|
||||
|
||||
def stop_force(self):
|
||||
"""
|
||||
强制停止,但是大部分场景不好用,容易导致 robot 崩坏。
|
||||
"""
|
||||
self.msg.mode = 0
|
||||
self.msg.gait_id = 0
|
||||
self.msg.duration = 0
|
||||
@ -15,7 +18,7 @@ class BaseMsg:
|
||||
|
||||
def stop(self, wait_time=200):
|
||||
self.msg.mode = 11
|
||||
self.msg.gait_id = 26
|
||||
self.msg.gait_id = 27
|
||||
self.msg.vel_des = [0, 0, 0]
|
||||
self.msg.duration = wait_time
|
||||
self.msg.life_count += 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user