Refactor main.py and task_3.py to comment out unused code, adjust target coordinates, and implement y-coordinate adjustments for improved task execution and clarity.
This commit is contained in:
parent
41da8566a9
commit
9ce1a04fb4
2
main.py
2
main.py
@ -51,7 +51,7 @@ def main():
|
||||
Ctrl.base_msg.stop() # BUG 垃圾指令 for eat
|
||||
|
||||
# time.sleep(100) # TEST,
|
||||
run_task_1(Ctrl, msg, time_sleep=TIME_SLEEP)
|
||||
# run_task_1(Ctrl, msg, time_sleep=TIME_SLEEP)
|
||||
|
||||
arrow_direction = run_task_2(Ctrl, msg, xy_flag=False)
|
||||
# arrow_direction = 'right' # TEST
|
||||
|
@ -97,7 +97,8 @@ def pass_up_down(ctrl, msg):
|
||||
|
||||
climb_speed_threshold = 0.05 # 检测到开始爬坡的速度阈值
|
||||
max_iterations = 450 # 最大循环次数,作为安全保障
|
||||
y_target = 9.3 # 目标y坐标,达到此值时停止
|
||||
start_y = ctrl.odo_msg.xyz[1]
|
||||
y_target = 2 # 目标y坐标,达到此值时停止
|
||||
|
||||
# 阶段控制
|
||||
climbing_detected = False # 是否检测到正在爬坡
|
||||
@ -114,7 +115,7 @@ def pass_up_down(ctrl, msg):
|
||||
# 获取当前状态数据
|
||||
vz = ctrl.odo_msg.vxyz[2] # Z轴速度
|
||||
current_height = ctrl.odo_msg.xyz[2] # 当前高度
|
||||
current_y = ctrl.odo_msg.xyz[1] # 当前y坐标
|
||||
current_y = ctrl.odo_msg.xyz[1] - start_y # 当前y坐标
|
||||
current_pitch = ctrl.odo_msg.rpy[1] # 当前俯仰角
|
||||
|
||||
# 每10次迭代打印一次当前信息
|
||||
@ -204,8 +205,7 @@ def pass_up_down(ctrl, msg):
|
||||
descent_speed_threshold = -0.05 # 检测到开始下坡的速度阈值(负值表示下降)
|
||||
max_iterations = 200 # 最大循环次数,作为安全保障
|
||||
start_height = ctrl.odo_msg.xyz[2] # 记录起始高度
|
||||
start_y = ctrl.odo_msg.xyz[1] # 记录起始y坐标
|
||||
y_target = 11.6 # 目标y坐标,达到此值时停止
|
||||
y_target = 4 # 目标y坐标,达到此值时停止
|
||||
|
||||
# 阶段控制
|
||||
descending_detected = False # 是否检测到正在下坡
|
||||
@ -220,7 +220,7 @@ def pass_up_down(ctrl, msg):
|
||||
# 获取当前状态数据
|
||||
vz = ctrl.odo_msg.vxyz[2] # Z轴速度
|
||||
current_height = ctrl.odo_msg.xyz[2] # 当前高度
|
||||
current_y = ctrl.odo_msg.xyz[1] # 当前y坐标
|
||||
current_y = ctrl.odo_msg.xyz[1] - start_y # 当前y坐标
|
||||
current_pitch = ctrl.odo_msg.rpy[1] # 当前俯仰角
|
||||
|
||||
# 每10次迭代打印一次当前信息
|
||||
@ -414,9 +414,10 @@ def run_task_3(ctrl, msg, time_sleep=5000):
|
||||
info('开始执行任务3...', "启动")
|
||||
|
||||
turn_degree_v2(ctrl, msg, 90, absolute=True)
|
||||
go_straight(ctrl, msg, distance=0.1, speed=0.5, observe=True)
|
||||
# go_straight(ctrl, msg, distance=0.1, speed=0.5, observe=True)
|
||||
|
||||
section('任务3-1:up', "开始")
|
||||
ctrl.odo_reset()
|
||||
pass_up_down(ctrl, msg)
|
||||
|
||||
turn_degree_v2(ctrl, msg, 90, absolute=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user