暫存版本
This commit is contained in:
22
app.py
22
app.py
@@ -47,12 +47,15 @@ handler = WebSocketHandler()
|
|||||||
logger.add(handler, format="{time:MM-DD HH:mm:ss} {message}", level="DEBUG")
|
logger.add(handler, format="{time:MM-DD HH:mm:ss} {message}", level="DEBUG")
|
||||||
|
|
||||||
fileOptions_path = '/home/evan/Workplace/project_main'
|
fileOptions_path = '/home/evan/Workplace/project_main'
|
||||||
fileOptions_list = ['cfg_main.toml', 'cfg_subtask.toml']
|
fileOptions_list = ['cfg_args.toml','cfg_main.toml', 'cfg_subtask.toml']
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
|
@app.route('/csdn')
|
||||||
|
def csdn():
|
||||||
|
return render_template('csdn.html')
|
||||||
|
|
||||||
@socketio.on('operate')
|
@socketio.on('operate')
|
||||||
def operate_handle(data):
|
def operate_handle(data):
|
||||||
@@ -141,6 +144,23 @@ def thread_function():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
log_file = "server_processes.log"
|
||||||
|
log = open(log_file, "w")
|
||||||
|
time.sleep(2)
|
||||||
|
# 启动所有脚本
|
||||||
|
for i, env_info in enumerate(server_command):
|
||||||
|
env_path = env_info["path"]
|
||||||
|
script = env_info["script"]
|
||||||
|
env = os.environ.copy()
|
||||||
|
if i == 0:
|
||||||
|
process = subprocess.Popen([script], cwd=env_path, env=env, stdout=log, stderr=subprocess.STDOUT)
|
||||||
|
processes.append(process)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
process = subprocess.Popen(['python', script], cwd=env_path, env=env, stdout=log, stderr=subprocess.STDOUT)
|
||||||
|
processes.append(process)
|
||||||
|
|
||||||
thread1 = threading.Thread(target=thread_function, daemon = True)
|
thread1 = threading.Thread(target=thread_function, daemon = True)
|
||||||
thread1.start()
|
thread1.start()
|
||||||
socketio.run(app, host='0.0.0.0', port=5001, allow_unsafe_werkzeug=True)
|
socketio.run(app, host='0.0.0.0', port=5001, allow_unsafe_werkzeug=True)
|
||||||
|
|||||||
14
cfg_args.toml
Normal file
14
cfg_args.toml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[kick_ass]
|
||||||
|
target_person = 3
|
||||||
|
|
||||||
|
[task]
|
||||||
|
Subtask_enable = true
|
||||||
|
GetBlock_enable = true
|
||||||
|
PutBlock_enable = true
|
||||||
|
GetBBall_enable = true
|
||||||
|
UpTower_enable = true
|
||||||
|
GetRBall_enable = true
|
||||||
|
PutBBall_enable = true
|
||||||
|
PutHanoi_enable = true
|
||||||
|
MoveArea_enable = false
|
||||||
|
KickAss_enable = true
|
||||||
@@ -2,27 +2,17 @@
|
|||||||
logger_filename = "log/file_{time}.log"
|
logger_filename = "log/file_{time}.log"
|
||||||
logger_format = "{time} {level} {message}"
|
logger_format = "{time} {level} {message}"
|
||||||
|
|
||||||
[task]
|
|
||||||
Subtask_enable = true
|
|
||||||
GetBlock_enable = true
|
|
||||||
PutBlock_enable = true
|
|
||||||
GetBBall_enable = true
|
|
||||||
UpTower_enable = true
|
|
||||||
GetRBall_enable = true
|
|
||||||
PutBBall_enable = true
|
|
||||||
PutHanoi_enable = true
|
|
||||||
MoveArea_enable = true
|
|
||||||
KickAss_enable = true
|
|
||||||
|
|
||||||
[find_counts]
|
[find_counts]
|
||||||
GetBlock_counts = 5
|
GetBlock_counts = 5
|
||||||
PutBlock_counts = 5
|
PutBlock_counts = 8
|
||||||
GetBBall_counts = 1
|
GetBBall_counts = 1
|
||||||
UpTower_counts = 3
|
UpTower_counts = 3
|
||||||
GetRBall_counts = 10
|
GetRBall_counts = 10
|
||||||
PutBBall_counts = 15
|
PutBBall_counts = 15
|
||||||
PutHanoi1_counts = 10
|
PutHanoi1_counts = 7
|
||||||
PutHanoi2_counts = 5
|
PutHanoi2_counts = 2
|
||||||
PutHanoi3_counts = 2
|
PutHanoi3_counts = 2
|
||||||
MoveArea1_counts = 6
|
MoveArea1_counts = 6
|
||||||
MoveArea2_counts = 1700
|
MoveArea2_counts = 1700
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[get_block]
|
[get_block]
|
||||||
pid_kp = 1
|
pid_kp = 0.9
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
first_block = "blue"
|
first_block = "blue"
|
||||||
@@ -20,42 +20,42 @@ pid_ki = 0
|
|||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[get_rball]
|
[get_rball]
|
||||||
pid_kp = 0.5
|
pid_kp = 0.6
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[put_bball]
|
[put_bball]
|
||||||
pid_kp = 0.7
|
pid_kp = 1.2
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[put_hanoi1]
|
[put_hanoi1]
|
||||||
pid_kp = 1
|
pid_kp = 0.7
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[put_hanoi2]
|
[put_hanoi2]
|
||||||
pid_kp = 0.7
|
pid_kp = 1.0
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
pos_gap = 160
|
pos_gap = 160
|
||||||
first_target = "mp"
|
first_target = "mp"
|
||||||
|
|
||||||
[put_hanoi3]
|
[put_hanoi3]
|
||||||
pid_kp = 1.2
|
pid_kp = 1.3
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[move_area]
|
[move_area]
|
||||||
pid_kp = 1.4
|
pid_kp = 1.2
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
llm_enable = true
|
llm_enable = false
|
||||||
|
|
||||||
[kick_ass]
|
[kick_ass]
|
||||||
pid_kp = 1.2
|
pid_kp = 0.8
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
pos_gap1 = 150
|
pos_gap1 = 150
|
||||||
pos_gap2 = 80
|
pos_gap2 = 80
|
||||||
target_person = 2
|
target_person = 1
|
||||||
|
|||||||
@@ -29,12 +29,13 @@ def main_func(_queue, _skip_queue):
|
|||||||
|
|
||||||
|
|
||||||
cmd_py_obj = by_cmd_py(_queue)
|
cmd_py_obj = by_cmd_py(_queue)
|
||||||
sb.import_obj(cmd_py_obj)
|
sb.import_obj(cmd_py_obj, _skip_queue)
|
||||||
act.import_obj(cmd_py_obj)
|
act.import_obj(cmd_py_obj)
|
||||||
|
|
||||||
# 读取配置
|
# 读取配置
|
||||||
cfg_main = toml.load('/home/evan/Workplace/project_main/cfg_main.toml')
|
cfg_main = toml.load('/home/evan/Workplace/project_main/cfg_main.toml')
|
||||||
logger.info(cfg_main)
|
cfg_args = toml.load('/home/evan/Workplace/project_main/cfg_args.toml')
|
||||||
|
# logger.info(cfg_main)
|
||||||
cfg_subtask = toml.load('/home/evan/Workplace/project_main/cfg_subtask.toml')
|
cfg_subtask = toml.load('/home/evan/Workplace/project_main/cfg_subtask.toml')
|
||||||
|
|
||||||
# 配置日志输出
|
# 配置日志输出
|
||||||
@@ -50,21 +51,21 @@ def main_func(_queue, _skip_queue):
|
|||||||
|
|
||||||
# 向任务队列添加任务
|
# 向任务队列添加任务
|
||||||
task_queue = queue.Queue()
|
task_queue = queue.Queue()
|
||||||
if cfg_main['task']['Subtask_enable'] is True:
|
if cfg_args['task']['Subtask_enable'] is True:
|
||||||
task_queue.put(sb.task("人员施救第一块", sb.get_block1, cfg_main['find_counts']['GetBlock_counts'], cfg_main['task']['GetBlock_enable']))
|
task_queue.put(sb.task("人员施救第一块", sb.get_block1, cfg_main['find_counts']['GetBlock_counts'], cfg_args['task']['GetBlock_enable']))
|
||||||
task_queue.put(sb.task("人员施救第二块", sb.get_block2, cfg_main['find_counts']['GetBlock_counts'], cfg_main['task']['GetBlock_enable']))
|
task_queue.put(sb.task("人员施救第二块", sb.get_block2, cfg_main['find_counts']['GetBlock_counts'], cfg_args['task']['GetBlock_enable']))
|
||||||
task_queue.put(sb.task("紧急转移", sb.put_block, cfg_main['find_counts']['PutBlock_counts'], cfg_main['task']['GetBlock_enable']))
|
task_queue.put(sb.task("紧急转移", sb.put_block, cfg_main['find_counts']['PutBlock_counts'], cfg_args['task']['GetBlock_enable']))
|
||||||
task_queue.put(sb.task("整装上阵", sb.get_bball, cfg_main['find_counts']['GetBBall_counts'], cfg_main['task']['GetBBall_enable']))
|
task_queue.put(sb.task("整装上阵", sb.get_bball, cfg_main['find_counts']['GetBBall_counts'], cfg_args['task']['GetBBall_enable']))
|
||||||
# # TODO 添加一个空任务用于提前降 z 轴
|
# # TODO 添加一个空任务用于提前降 z 轴
|
||||||
task_queue.put(sb.task("通信抢修", sb.up_tower, cfg_main['find_counts']['UpTower_counts'], cfg_main['task']['UpTower_enable']))
|
task_queue.put(sb.task("通信抢修", sb.up_tower, cfg_main['find_counts']['UpTower_counts'], cfg_args['task']['UpTower_enable']))
|
||||||
task_queue.put(sb.task("高控排险", sb.get_rball, cfg_main['find_counts']['GetRBall_counts'], cfg_main['task']['GetRBall_enable']))
|
task_queue.put(sb.task("高控排险", sb.get_rball, cfg_main['find_counts']['GetRBall_counts'], cfg_args['task']['GetRBall_enable']))
|
||||||
task_queue.put(sb.task("派发物资", sb.put_bball, cfg_main['find_counts']['PutBBall_counts'], cfg_main['task']['GetBBall_enable'] and cfg_main['task']['PutBBall_enable']))
|
task_queue.put(sb.task("派发物资", sb.put_bball, cfg_main['find_counts']['PutBBall_counts'], cfg_args['task']['GetBBall_enable'] and cfg_args['task']['PutBBall_enable']))
|
||||||
task_queue.put(sb.task("物资盘点一阶段", sb.put_hanoi1, cfg_main['find_counts']['PutHanoi1_counts'], enable = True)) # 无论是否进行任务,检测标识并转向都是必须进行的
|
task_queue.put(sb.task("物资盘点一阶段", sb.put_hanoi1, cfg_main['find_counts']['PutHanoi1_counts'], enable = True)) # 无论是否进行任务,检测标识并转向都是必须进行的
|
||||||
task_queue.put(sb.task("物资盘点二阶段", sb.put_hanoi2, cfg_main['find_counts']['PutHanoi2_counts'], cfg_main['task']['PutHanoi_enable']))
|
task_queue.put(sb.task("物资盘点二阶段", sb.put_hanoi2, cfg_main['find_counts']['PutHanoi2_counts'], cfg_args['task']['PutHanoi_enable']))
|
||||||
task_queue.put(sb.task("物资盘点三阶段", sb.put_hanoi3, cfg_main['find_counts']['PutHanoi3_counts'], enable = True))
|
task_queue.put(sb.task("物资盘点三阶段", sb.put_hanoi3, cfg_main['find_counts']['PutHanoi3_counts'], enable = True))
|
||||||
task_queue.put(sb.task("应急避险一阶段", sb.move_area1, cfg_main['find_counts']['MoveArea1_counts'], cfg_main['task']['MoveArea_enable']))
|
task_queue.put(sb.task("应急避险一阶段", sb.move_area1, cfg_main['find_counts']['MoveArea1_counts'], cfg_args['task']['MoveArea_enable']))
|
||||||
task_queue.put(sb.task("应急避险二阶段", sb.move_area2, cfg_main['find_counts']['MoveArea2_counts'], cfg_main['task']['MoveArea_enable']))
|
task_queue.put(sb.task("应急避险二阶段", sb.move_area2, cfg_main['find_counts']['MoveArea2_counts'], cfg_args['task']['MoveArea_enable']))
|
||||||
task_queue.put(sb.task("扫黑除暴", sb.kick_ass, cfg_main['find_counts']['KickAss_counts'], cfg_main['task']['KickAss_enable']))
|
task_queue.put(sb.task("扫黑除暴", sb.kick_ass, cfg_main['find_counts']['KickAss_counts'], cfg_args['task']['KickAss_enable']))
|
||||||
# 将任务队列传入调度模块中
|
# 将任务队列传入调度模块中
|
||||||
task_queuem_t = sb.task_queuem(task_queue)
|
task_queuem_t = sb.task_queuem(task_queue)
|
||||||
# 创建任务队列的工作线程
|
# 创建任务队列的工作线程
|
||||||
@@ -101,4 +102,6 @@ def main_func(_queue, _skip_queue):
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
logger.info("Main thread exit")
|
logger.info("Main thread exit")
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main_func(None)
|
from multiprocessing import Queue
|
||||||
|
temp = Queue()
|
||||||
|
main_func(None, temp)
|
||||||
14
majtask.py
14
majtask.py
@@ -62,17 +62,17 @@ class main_task():
|
|||||||
error_abs = abs(self.lane_error)
|
error_abs = abs(self.lane_error)
|
||||||
|
|
||||||
if error_abs > 50:
|
if error_abs > 50:
|
||||||
speed = 11
|
|
||||||
elif error_abs > 45:
|
|
||||||
speed = 13
|
speed = 13
|
||||||
|
elif error_abs > 45:
|
||||||
|
speed = 15
|
||||||
elif error_abs > 35:
|
elif error_abs > 35:
|
||||||
speed = 15
|
speed = 17
|
||||||
elif error_abs > 25:
|
elif error_abs > 25:
|
||||||
speed = 15
|
|
||||||
elif error_abs > 15:
|
|
||||||
speed = 15
|
|
||||||
else:
|
|
||||||
speed = 18
|
speed = 18
|
||||||
|
elif error_abs > 15:
|
||||||
|
speed = 19
|
||||||
|
else:
|
||||||
|
speed = 21
|
||||||
|
|
||||||
# lane_model initial
|
# lane_model initial
|
||||||
# if error_abs > 50:
|
# if error_abs > 50:
|
||||||
|
|||||||
BIN
static/csdn.png
Normal file
BIN
static/csdn.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 188 KiB |
288
subtask.py
288
subtask.py
@@ -1,7 +1,3 @@
|
|||||||
'''
|
|
||||||
待办事项:
|
|
||||||
- 第一二個方塊自動識別,hanoi2 識別到物塊即停車,不需手動輸入第一個物塊(修改 fliter 使其能一次請求過濾多個標籤)
|
|
||||||
'''
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from utils import label_filter
|
from utils import label_filter
|
||||||
@@ -18,7 +14,7 @@ import re
|
|||||||
import threading
|
import threading
|
||||||
import ctypes
|
import ctypes
|
||||||
cfg = None
|
cfg = None
|
||||||
|
cfg_args = None
|
||||||
by_cmd = None
|
by_cmd = None
|
||||||
filter = None
|
filter = None
|
||||||
llm_bot = None
|
llm_bot = None
|
||||||
@@ -30,12 +26,14 @@ socket = None
|
|||||||
context1 = None
|
context1 = None
|
||||||
ocr_socket = None
|
ocr_socket = None
|
||||||
|
|
||||||
|
global_skip_queue = None
|
||||||
|
|
||||||
'''
|
'''
|
||||||
description: main.py 里执行 引入全局变量
|
description: main.py 里执行 引入全局变量
|
||||||
param {*} _by_cmd 控制器对象
|
param {*} _by_cmd 控制器对象
|
||||||
return {*}
|
return {*}
|
||||||
'''
|
'''
|
||||||
def import_obj(_by_cmd):
|
def import_obj(_by_cmd, skip_queue):
|
||||||
|
|
||||||
global by_cmd
|
global by_cmd
|
||||||
global filter
|
global filter
|
||||||
@@ -48,9 +46,12 @@ def import_obj(_by_cmd):
|
|||||||
global ocr_socket
|
global ocr_socket
|
||||||
|
|
||||||
global cfg
|
global cfg
|
||||||
|
global cfg_args
|
||||||
|
global global_skip_queue
|
||||||
cfg = toml.load('/home/evan/Workplace/project_main/cfg_subtask.toml') # 加载任务配置
|
cfg = toml.load('/home/evan/Workplace/project_main/cfg_subtask.toml') # 加载任务配置
|
||||||
|
cfg_args = toml.load('/home/evan/Workplace/project_main/cfg_args.toml')
|
||||||
by_cmd = _by_cmd
|
by_cmd = _by_cmd
|
||||||
|
global_skip_queue = skip_queue
|
||||||
|
|
||||||
# 目标检测 socket 客户端
|
# 目标检测 socket 客户端
|
||||||
context = zmq.Context()
|
context = zmq.Context()
|
||||||
@@ -59,10 +60,10 @@ def import_obj(_by_cmd):
|
|||||||
logger.info("subtask yolo client init")
|
logger.info("subtask yolo client init")
|
||||||
|
|
||||||
# ocr socket 客户端
|
# ocr socket 客户端
|
||||||
context1 = zmq.Context()
|
# context1 = zmq.Context()
|
||||||
ocr_socket = context1.socket(zmq.REQ)
|
# ocr_socket = context1.socket(zmq.REQ)
|
||||||
ocr_socket.connect("tcp://localhost:6668")
|
# ocr_socket.connect("tcp://localhost:6668")
|
||||||
logger.info("subtask ocr client init")
|
# logger.info("subtask ocr client init")
|
||||||
|
|
||||||
filter = label_filter(socket)
|
filter = label_filter(socket)
|
||||||
if cfg['move_area']['llm_enable']:
|
if cfg['move_area']['llm_enable']:
|
||||||
@@ -192,25 +193,34 @@ def calibrate_new(label, offset, run = True, run_speed = 3.5):
|
|||||||
else:
|
else:
|
||||||
by_cmd.send_distance_x(10, int(-error))
|
by_cmd.send_distance_x(10, int(-error))
|
||||||
break
|
break
|
||||||
|
# 弃用 distance 校准
|
||||||
def explore_calibrate_new(label, offset, run_direc ,run_speed = 3.5):
|
def explore_calibrate_new(label, offset, run_direc ,run_speed = 3.5):
|
||||||
# run_direc == 1 向前
|
# run_direc == 1 向前
|
||||||
|
stop_error = 0
|
||||||
if run_direc == 1:
|
if run_direc == 1:
|
||||||
by_cmd.send_speed_x(run_speed)
|
by_cmd.send_speed_x(run_speed)
|
||||||
else:
|
else:
|
||||||
by_cmd.send_speed_x(-run_speed)
|
by_cmd.send_speed_x(-run_speed)
|
||||||
|
|
||||||
|
if label == tlabel.TPLATFORM:
|
||||||
|
stop_error = 10
|
||||||
|
else:
|
||||||
|
stop_error = 15
|
||||||
while True:
|
while True:
|
||||||
ret, box = filter.get(label)
|
ret, box = filter.get(label)
|
||||||
while not ret:
|
while not ret:
|
||||||
|
if not global_skip_queue.empty():
|
||||||
|
_ = global_skip_queue.get()
|
||||||
|
logger.error("跳过 explore_calibrate_new")
|
||||||
|
return False
|
||||||
ret, box = filter.get(label)
|
ret, box = filter.get(label)
|
||||||
|
|
||||||
error = (box[0][2] + box[0][0] - 320) / 2 + offset
|
error = (box[0][2] + box[0][0] - 320) / 2 + offset
|
||||||
if ret:
|
if ret:
|
||||||
# 校准速度越大 停车的条件越宽泛
|
# 校准速度越大 停车的条件越宽泛 20 15
|
||||||
if abs(error) <= 20:
|
if abs(error) <= stop_error:
|
||||||
car_stop()
|
car_stop()
|
||||||
logger.info("explore_calibrate_new:行进时 误差小于 10 直接停车")
|
logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车")
|
||||||
|
|
||||||
ret, box = filter.get(label)
|
ret, box = filter.get(label)
|
||||||
while not ret:
|
while not ret:
|
||||||
@@ -218,17 +228,18 @@ def explore_calibrate_new(label, offset, run_direc ,run_speed = 3.5):
|
|||||||
error = (box[0][2] + box[0][0] - 320) / 2 + offset
|
error = (box[0][2] + box[0][0] - 320) / 2 + offset
|
||||||
logger.info(f"停车后像素误差:{error}")
|
logger.info(f"停车后像素误差:{error}")
|
||||||
|
|
||||||
logger.info(f"explore_calibrate_new:停车后的误差大于 8 使用 distance 校准")
|
# logger.info(f"explore_calibrate_new:停车后的误差大于 8 使用 distance 校准")
|
||||||
if abs(error) < 8:
|
# if abs(error) < 8:
|
||||||
error = error * 3
|
# error = error * 3
|
||||||
else:
|
# else:
|
||||||
error = error * 2
|
# error = error * 2
|
||||||
if error > 0:
|
# if error > 0:
|
||||||
by_cmd.send_distance_x(-10, int(error))
|
# by_cmd.send_distance_x(-10, int(error))
|
||||||
else:
|
# else:
|
||||||
by_cmd.send_distance_x(10, int(-error))
|
# by_cmd.send_distance_x(10, int(-error))
|
||||||
|
|
||||||
break
|
break
|
||||||
|
return True
|
||||||
|
|
||||||
# 任务类
|
# 任务类
|
||||||
class task:
|
class task:
|
||||||
@@ -326,24 +337,24 @@ class task_queuem(task):
|
|||||||
elif self.status is task_queuem_status.EXECUTING:
|
elif self.status is task_queuem_status.EXECUTING:
|
||||||
if self.task_now.enable is True:
|
if self.task_now.enable is True:
|
||||||
logger.info(f"[TaskM]# Start execute task function")
|
logger.info(f"[TaskM]# Start execute task function")
|
||||||
self.exec_thread = threading.Thread(target=self.task_now.exec)
|
# self.exec_thread = threading.Thread(target=self.task_now.exec)
|
||||||
# 启动线程
|
# # 启动线程
|
||||||
self.exec_thread.start()
|
# self.exec_thread.start()
|
||||||
while True:
|
# while True:
|
||||||
if not self.exec_thread.is_alive():
|
# if not self.exec_thread.is_alive():
|
||||||
break
|
# break
|
||||||
else:
|
# else:
|
||||||
if not skip_queue.empty():
|
# if not skip_queue.empty():
|
||||||
car_stop()
|
# car_stop()
|
||||||
thread_id = self.exec_thread.ident
|
# thread_id = self.exec_thread.ident
|
||||||
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, ctypes.py_object(SystemExit))
|
# res = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, ctypes.py_object(SystemExit))
|
||||||
_ = skip_queue.get()
|
# _ = skip_queue.get()
|
||||||
logger.error(f"{self.task_now.name} 任务在 exec 中已经被手动跳过")
|
# logger.error(f"{self.task_now.name} 任务在 exec 中已经被手动跳过")
|
||||||
self.status = task_queuem_status.IDEL # 空动作不需要阻塞巡线,直接置位
|
# self.status = task_queuem_status.IDEL # 空动作不需要阻塞巡线,直接置位
|
||||||
self.task_now.after() # 执行任务后处理
|
# self.task_now.after() # 执行任务后处理
|
||||||
self.queue.task_done() # 弹出已执行的任务
|
# self.queue.task_done() # 弹出已执行的任务
|
||||||
return True
|
# return True
|
||||||
# self.task_now.exec() # 执行当前任务函数
|
self.task_now.exec() # 执行当前任务函数
|
||||||
self.status = task_queuem_status.IDEL # 执行完成后为退出巡线阻塞
|
self.status = task_queuem_status.IDEL # 执行完成后为退出巡线阻塞
|
||||||
self.task_now.after() # 执行任务后处理
|
self.task_now.after() # 执行任务后处理
|
||||||
self.queue.task_done() # 弹出已执行的任务
|
self.queue.task_done() # 弹出已执行的任务
|
||||||
@@ -405,12 +416,12 @@ class get_block1():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(25)
|
by_cmd.send_angle_claw(25)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_z(30, 80)
|
by_cmd.send_position_axis_z(30, 90)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
by_cmd.send_angle_claw_arm(175)
|
by_cmd.send_angle_claw_arm(175)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
by_cmd.send_position_axis_x(1, 110)
|
by_cmd.send_position_axis_x(1, 120)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_position_axis_z(30, 70)
|
by_cmd.send_position_axis_z(30, 70)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@@ -423,12 +434,14 @@ class get_block1():
|
|||||||
by_cmd.send_angle_claw_arm(220)
|
by_cmd.send_angle_claw_arm(220)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_angle_storage(55)
|
by_cmd.send_angle_storage(55)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
# TODO 完成不执行任务的空动作
|
# TODO 完成不执行任务的空动作
|
||||||
pass
|
pass
|
||||||
def after(self):
|
def after(self):
|
||||||
|
var.pid_turning.set(cfg["get_block"]["pid_kp"], cfg["get_block"]["pid_ki"], cfg["get_block"]["pid_kd"])
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class get_block2():
|
class get_block2():
|
||||||
@@ -460,9 +473,6 @@ class get_block2():
|
|||||||
by_cmd.send_position_axis_x(1, 20)
|
by_cmd.send_position_axis_x(1, 20)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(25)
|
by_cmd.send_angle_claw(25)
|
||||||
by_cmd.send_beep(1)
|
|
||||||
time.sleep(0.5)
|
|
||||||
by_cmd.send_beep(0)
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 100)
|
by_cmd.send_position_axis_x(1, 100)
|
||||||
|
|
||||||
@@ -503,7 +513,7 @@ class put_block():
|
|||||||
by_cmd.send_distance_x(10, 100)
|
by_cmd.send_distance_x(10, 100)
|
||||||
by_cmd.send_position_axis_z(30, 0)
|
by_cmd.send_position_axis_z(30, 0)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 40)
|
by_cmd.send_position_axis_x(1, 20)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(63)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -528,9 +538,10 @@ class put_block():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_position_axis_z(30, 0)
|
by_cmd.send_position_axis_z(30, 0)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 40)
|
by_cmd.send_position_axis_x(1, 20)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
by_cmd.send_angle_claw(45)
|
by_cmd.send_angle_claw(45)
|
||||||
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
@@ -590,14 +601,12 @@ class get_bball():
|
|||||||
by_cmd.send_angle_claw_arm(36)
|
by_cmd.send_angle_claw_arm(36)
|
||||||
by_cmd.send_angle_claw(54)
|
by_cmd.send_angle_claw(54)
|
||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1)
|
time.sleep(1.5)
|
||||||
by_cmd.send_angle_claw(60)
|
|
||||||
time.sleep(1)
|
|
||||||
by_cmd.send_angle_claw(25)
|
by_cmd.send_angle_claw(25)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_distance_axis_z(30, 20)
|
by_cmd.send_distance_axis_z(30, 20)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_position_axis_x(1, 30)
|
by_cmd.send_position_axis_x(1, 60)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_distance_axis_z(30, -40)
|
by_cmd.send_distance_axis_z(30, -40)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
@@ -650,9 +659,10 @@ class up_tower():
|
|||||||
by_cmd.send_distance_y(-10, 50)
|
by_cmd.send_distance_y(-10, 50)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
by_cmd.send_angle_zhuan(10)
|
by_cmd.send_angle_zhuan(10)
|
||||||
time.sleep(11)
|
time.sleep(12)
|
||||||
by_cmd.send_distance_y(10, 60)
|
by_cmd.send_distance_y(10, 60)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
car_stop()
|
||||||
by_cmd.send_angle_zhuan(0)
|
by_cmd.send_angle_zhuan(0)
|
||||||
# while True:
|
# while True:
|
||||||
# pass
|
# pass
|
||||||
@@ -691,7 +701,7 @@ class get_rball():
|
|||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
# 靠近塔
|
# 靠近塔
|
||||||
by_cmd.send_angle_scoop(20)
|
by_cmd.send_angle_scoop(20)
|
||||||
by_cmd.send_distance_y(-15, 50) # 50
|
by_cmd.send_distance_y(-15, 45) # 50
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -699,12 +709,13 @@ class get_rball():
|
|||||||
# by_cmd.send_angle_scoop(15)
|
# by_cmd.send_angle_scoop(15)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_z(30, 170)
|
by_cmd.send_position_axis_z(30, 170)
|
||||||
time.sleep(3)
|
time.sleep(2.5)
|
||||||
by_cmd.send_angle_scoop(7)
|
by_cmd.send_angle_scoop(7)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_distance_y(15, 70)
|
by_cmd.send_distance_y(15, 70)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_omega(-55,30)
|
car_stop()
|
||||||
|
# by_cmd.send_angle_omega(-55,30)
|
||||||
# while True:
|
# while True:
|
||||||
# pass
|
# pass
|
||||||
pass
|
pass
|
||||||
@@ -737,18 +748,18 @@ class put_bball():
|
|||||||
calibrate_new(tlabel.BASKET,offset = -21, run = True, run_speed = 6)
|
calibrate_new(tlabel.BASKET,offset = -21, run = True, run_speed = 6)
|
||||||
by_cmd.send_distance_x(10, 20)
|
by_cmd.send_distance_x(10, 20)
|
||||||
# 向左运动
|
# 向左运动
|
||||||
by_cmd.send_distance_y(-10, 35)
|
# by_cmd.send_distance_y(-10, 35)
|
||||||
by_cmd.send_angle_storage(15)
|
# by_cmd.send_angle_storage(10)
|
||||||
time.sleep(1)
|
# time.sleep(1)
|
||||||
|
|
||||||
by_cmd.send_angle_storage(55)
|
by_cmd.send_angle_storage(50)
|
||||||
logger.info("把球放篮筐里")
|
logger.info("把球放篮筐里")
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_distance_y(10, 55)
|
# by_cmd.send_distance_y(10, 55)
|
||||||
by_cmd.send_angle_storage(20)
|
by_cmd.send_angle_storage(20)
|
||||||
time.sleep(1)
|
# time.sleep(1)
|
||||||
car_stop()
|
# car_stop()
|
||||||
pass
|
pass
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
@@ -761,7 +772,6 @@ class put_bball():
|
|||||||
# 物资盘点
|
# 物资盘点
|
||||||
class put_hanoi1():
|
class put_hanoi1():
|
||||||
def init(self):
|
def init(self):
|
||||||
var.pid_turning.set(cfg["put_bball"]["pid_kp"], cfg["put_bball"]["pid_ki"], cfg["put_bball"]["pid_kd"])
|
|
||||||
logger.info("物资盘点 1 初始化")
|
logger.info("物资盘点 1 初始化")
|
||||||
filter.switch_camera(2)
|
filter.switch_camera(2)
|
||||||
def find(self):
|
def find(self):
|
||||||
@@ -805,17 +815,19 @@ class put_hanoi1():
|
|||||||
logger.info("应该向左转")
|
logger.info("应该向左转")
|
||||||
|
|
||||||
|
|
||||||
# 校准 omega
|
# # 校准 omega
|
||||||
if error > 0:
|
# if error > 0:
|
||||||
by_cmd.send_angle_omega(-20,abs(var.lane_error))
|
# by_cmd.send_angle_omega(-20,abs(var.lane_error))
|
||||||
else:
|
# else:
|
||||||
by_cmd.send_angle_omega(20,abs(var.lane_error))
|
# by_cmd.send_angle_omega(20,abs(var.lane_error))
|
||||||
time.sleep(0.5)
|
# time.sleep(0.5)
|
||||||
car_stop()
|
# car_stop()
|
||||||
time.sleep(0.5)
|
# time.sleep(0.5)
|
||||||
# by_cmd.send_distance_x(10, 200)
|
# by_cmd.send_distance_x(10, 200)
|
||||||
|
|
||||||
by_cmd.send_distance_x(10, 180)
|
by_cmd.send_distance_x(10, 180)
|
||||||
time.sleep(0.5)
|
time.sleep(1)
|
||||||
|
car_stop()
|
||||||
|
|
||||||
# 根据方向初始化执行器位置
|
# 根据方向初始化执行器位置
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
@@ -825,11 +837,11 @@ class put_hanoi1():
|
|||||||
by_cmd.send_angle_storage(0)
|
by_cmd.send_angle_storage(0)
|
||||||
else:
|
else:
|
||||||
by_cmd.send_position_axis_x(1, 150)
|
by_cmd.send_position_axis_x(1, 150)
|
||||||
by_cmd.send_angle_claw_arm(217)
|
by_cmd.send_angle_claw_arm(220)
|
||||||
by_cmd.send_angle_storage(55)
|
by_cmd.send_angle_storage(55)
|
||||||
time.sleep(1.5)
|
time.sleep(1)
|
||||||
|
|
||||||
by_cmd.send_position_axis_z(30, 0)
|
by_cmd.send_position_axis_z(30, 10)
|
||||||
|
|
||||||
if utils.direction_right > utils.direction_left:
|
if utils.direction_right > utils.direction_left:
|
||||||
utils.direction = tlabel.RMARK
|
utils.direction = tlabel.RMARK
|
||||||
@@ -852,7 +864,7 @@ class put_hanoi1():
|
|||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
def after(self):
|
def after(self):
|
||||||
var.pid_turning.set(0.8, 0, 0)
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class put_hanoi2():
|
class put_hanoi2():
|
||||||
@@ -866,11 +878,14 @@ class put_hanoi2():
|
|||||||
def init(self):
|
def init(self):
|
||||||
logger.info("物资盘点 2 初始化")
|
logger.info("物资盘点 2 初始化")
|
||||||
if utils.direction == tlabel.RMARK:
|
if utils.direction == tlabel.RMARK:
|
||||||
self.offset = 22
|
# 15
|
||||||
self.platform_offset = -29
|
self.offset = 19
|
||||||
|
# self.platform_offset = -25
|
||||||
|
self.platform_offset = -10
|
||||||
else:
|
else:
|
||||||
self.offset = 10
|
self.offset = 10
|
||||||
self.platform_offset = -39
|
#self.platform_offset = -30
|
||||||
|
self.platform_offset = -15
|
||||||
def find(self):
|
def find(self):
|
||||||
# ret, box = filter.get(self.target_label)
|
# ret, box = filter.get(self.target_label)
|
||||||
ret, box = filter.get(tlabel.TPLATFORM)
|
ret, box = filter.get(tlabel.TPLATFORM)
|
||||||
@@ -884,21 +899,29 @@ class put_hanoi2():
|
|||||||
logger.info(f"direction:{utils.direction.name}")
|
logger.info(f"direction:{utils.direction.name}")
|
||||||
var.task_speed = 0
|
var.task_speed = 0
|
||||||
car_stop()
|
car_stop()
|
||||||
time.sleep(0.5)
|
|
||||||
|
# if utils.direction is tlabel.RMARK:
|
||||||
|
# by_cmd.send_distance_y(10, 50)
|
||||||
|
# time.sleep(1)
|
||||||
|
|
||||||
|
# time.sleep(0.5)
|
||||||
# by_cmd.send_distance_x(-8, cfg['put_hanoi2']['pos_gap'] - 30)
|
# by_cmd.send_distance_x(-8, cfg['put_hanoi2']['pos_gap'] - 30)
|
||||||
time.sleep(1)
|
# time.sleep(1)
|
||||||
explore_calibrate_new(tlabel.LPILLER, offset = self.offset, run_direc = 1, run_speed = 5)
|
ret = explore_calibrate_new(tlabel.LPILLER, offset = self.offset, run_direc = 1, run_speed = 5)
|
||||||
time.sleep(1)
|
if not ret:
|
||||||
|
logger.error("跳过物资盘点 2 exec")
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
logger.info("抓大平台")
|
logger.info("抓大平台")
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
by_cmd.send_position_axis_z(30, 10)
|
by_cmd.send_position_axis_z(30, 10)
|
||||||
by_cmd.send_position_axis_x(1, 130)
|
by_cmd.send_position_axis_x(1, 130)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(63)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(81)
|
by_cmd.send_angle_claw(78)
|
||||||
time.sleep(1.5)
|
|
||||||
by_cmd.send_angle_claw(40)
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
by_cmd.send_angle_claw(40)
|
||||||
|
time.sleep(0.5)
|
||||||
by_cmd.send_distance_axis_z(30, 20)
|
by_cmd.send_distance_axis_z(30, 20)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 10)
|
by_cmd.send_position_axis_x(1, 10)
|
||||||
@@ -909,17 +932,20 @@ class put_hanoi2():
|
|||||||
by_cmd.send_position_axis_x(1, 40)
|
by_cmd.send_position_axis_x(1, 40)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(63)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(81)
|
by_cmd.send_angle_claw(78)
|
||||||
time.sleep(1.5)
|
|
||||||
by_cmd.send_angle_claw(40)
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
by_cmd.send_angle_claw(40)
|
||||||
|
time.sleep(0.5)
|
||||||
by_cmd.send_distance_axis_z(30, 20)
|
by_cmd.send_distance_axis_z(30, 20)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
explore_calibrate_new(tlabel.TPLATFORM, offset = self.offset, run_direc = -1, run_speed = 5)
|
ret = explore_calibrate_new(tlabel.TPLATFORM, offset = self.offset, run_direc = -1, run_speed = 5)
|
||||||
time.sleep(1)
|
if not ret:
|
||||||
|
logger.error("跳过物资盘点 2 exec")
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
logger.info("放大平台")
|
logger.info("放大平台")
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
by_cmd.send_position_axis_x(1, 130)
|
by_cmd.send_position_axis_x(1, 130)
|
||||||
@@ -945,18 +971,21 @@ class put_hanoi2():
|
|||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
explore_calibrate_new(tlabel.MPILLER, offset = self.offset, run_direc = 1, run_speed = 5)
|
ret = explore_calibrate_new(tlabel.MPILLER, offset = self.offset, run_direc = 1, run_speed = 5)
|
||||||
time.sleep(1)
|
if not ret:
|
||||||
|
logger.error("跳过物资盘点 2 exec")
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
logger.info("抓中平台")
|
logger.info("抓中平台")
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
by_cmd.send_position_axis_z(30, 10)
|
by_cmd.send_position_axis_z(30, 10)
|
||||||
by_cmd.send_position_axis_x(1, 130)
|
by_cmd.send_position_axis_x(1, 130)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(63)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(75)
|
by_cmd.send_angle_claw(70)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(35)
|
by_cmd.send_angle_claw(35)
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
by_cmd.send_distance_axis_z(30, 20)
|
by_cmd.send_distance_axis_z(30, 20)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 10)
|
by_cmd.send_position_axis_x(1, 10)
|
||||||
@@ -967,17 +996,20 @@ class put_hanoi2():
|
|||||||
by_cmd.send_position_axis_x(1, 40)
|
by_cmd.send_position_axis_x(1, 40)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(63)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(75)
|
by_cmd.send_angle_claw(70)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(35)
|
by_cmd.send_angle_claw(35)
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
by_cmd.send_distance_axis_z(30, 20)
|
by_cmd.send_distance_axis_z(30, 20)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
explore_calibrate_new(tlabel.LPILLER, offset = self.offset, run_direc = -1, run_speed = 5)
|
ret = explore_calibrate_new(tlabel.LPILLER, offset = self.offset, run_direc = -1, run_speed = 5)
|
||||||
time.sleep(1)
|
if not ret:
|
||||||
|
logger.error("跳过物资盘点 2 exec")
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
logger.info("放中平台")
|
logger.info("放中平台")
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
by_cmd.send_position_axis_z(30, 100)
|
by_cmd.send_position_axis_z(30, 100)
|
||||||
@@ -1003,15 +1035,18 @@ class put_hanoi2():
|
|||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
explore_calibrate_new(tlabel.SPILLER, offset = self.offset, run_direc = 1, run_speed = 5)
|
ret = explore_calibrate_new(tlabel.SPILLER, offset = self.offset, run_direc = 1, run_speed = 5)
|
||||||
time.sleep(1)
|
if not ret:
|
||||||
|
logger.error("跳过物资盘点 2 exec")
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
logger.info("抓小平台")
|
logger.info("抓小平台")
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
by_cmd.send_position_axis_z(30, 10)
|
by_cmd.send_position_axis_z(30, 10)
|
||||||
by_cmd.send_position_axis_x(1, 130)
|
by_cmd.send_position_axis_x(1, 130)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(50)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(70)
|
by_cmd.send_angle_claw(58)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(27)
|
by_cmd.send_angle_claw(27)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -1023,9 +1058,9 @@ class put_hanoi2():
|
|||||||
else:
|
else:
|
||||||
by_cmd.send_position_axis_z(30, 10)
|
by_cmd.send_position_axis_z(30, 10)
|
||||||
by_cmd.send_position_axis_x(1, 40)
|
by_cmd.send_position_axis_x(1, 40)
|
||||||
by_cmd.send_angle_claw(63)
|
by_cmd.send_angle_claw(50)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(70)
|
by_cmd.send_angle_claw(58)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
by_cmd.send_angle_claw(27)
|
by_cmd.send_angle_claw(27)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -1034,8 +1069,11 @@ class put_hanoi2():
|
|||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
explore_calibrate_new(tlabel.MPILLER, offset = self.offset, run_direc = -1, run_speed = 5)
|
ret = explore_calibrate_new(tlabel.MPILLER, offset = self.offset, run_direc = -1, run_speed = 5)
|
||||||
time.sleep(1)
|
if not ret:
|
||||||
|
logger.error("跳过物资盘点 2 exec")
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
logger.info("放小平台")
|
logger.info("放小平台")
|
||||||
if utils.direction is tlabel.RMARK:
|
if utils.direction is tlabel.RMARK:
|
||||||
by_cmd.send_position_axis_z(30, 170)
|
by_cmd.send_position_axis_z(30, 170)
|
||||||
@@ -1044,8 +1082,8 @@ class put_hanoi2():
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
by_cmd.send_distance_axis_z(30, -20)
|
by_cmd.send_distance_axis_z(30, -20)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_angle_claw(90)
|
by_cmd.send_angle_claw(80)
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 10)
|
by_cmd.send_position_axis_x(1, 10)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
pass
|
pass
|
||||||
@@ -1056,8 +1094,8 @@ class put_hanoi2():
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
by_cmd.send_distance_axis_z(30, -20)
|
by_cmd.send_distance_axis_z(30, -20)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_angle_claw(90)
|
by_cmd.send_angle_claw(80)
|
||||||
time.sleep(1)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
# while True:
|
# while True:
|
||||||
@@ -1294,6 +1332,8 @@ class move_area2():
|
|||||||
# by_cmd.send_distance_y(-15, 300)
|
# by_cmd.send_distance_y(-15, 300)
|
||||||
pass
|
pass
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
|
logger.warning("正在跳過大模型任務")
|
||||||
|
time.sleep(2)
|
||||||
pass
|
pass
|
||||||
def after(self):
|
def after(self):
|
||||||
var.pid_turning.set(cfg["move_area"]["pid_kp"], cfg["move_area"]["pid_ki"], cfg["move_area"]["pid_kd"])
|
var.pid_turning.set(cfg["move_area"]["pid_kp"], cfg["move_area"]["pid_ki"], cfg["move_area"]["pid_kd"])
|
||||||
@@ -1310,7 +1350,7 @@ class kick_ass():
|
|||||||
logger.info("扫黑除暴初始化")
|
logger.info("扫黑除暴初始化")
|
||||||
self.pos_gap1 = cfg['kick_ass']['pos_gap1']
|
self.pos_gap1 = cfg['kick_ass']['pos_gap1']
|
||||||
self.pos_gap2 = cfg['kick_ass']['pos_gap2']
|
self.pos_gap2 = cfg['kick_ass']['pos_gap2']
|
||||||
self.target_person = cfg['kick_ass']['target_person']
|
self.target_person = cfg_args['kick_ass']['target_person']
|
||||||
|
|
||||||
# by_cmd.send_angle_claw(15)
|
# by_cmd.send_angle_claw(15)
|
||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 160)
|
||||||
@@ -1328,25 +1368,23 @@ class kick_ass():
|
|||||||
calibrate_new(tlabel.SIGN, offset = 8, run = True)
|
calibrate_new(tlabel.SIGN, offset = 8, run = True)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_position_axis_z(30, 60)
|
by_cmd.send_position_axis_z(30, 60)
|
||||||
|
by_cmd.send_position_axis_x(1, 120)
|
||||||
|
|
||||||
if self.target_person == 1:
|
if self.target_person == 1:
|
||||||
target_distance = self.pos_gap1
|
target_distance = self.pos_gap1
|
||||||
else:
|
else:
|
||||||
target_distance = self.pos_gap1 + (self.target_person - 1) * self.pos_gap2 + (self.target_person - 1) * 10
|
target_distance = self.pos_gap1 + (self.target_person - 1) * self.pos_gap2 + (self.target_person - 1) * 10
|
||||||
by_cmd.send_distance_x(10, target_distance)
|
by_cmd.send_distance_x(10, target_distance)
|
||||||
time.sleep(4)
|
logger.info(f"target distance {target_distance}")
|
||||||
|
time.sleep(1.5 + (self.target_person - 1) * 0.7 )
|
||||||
|
car_stop()
|
||||||
|
|
||||||
while by_cmd.send_angle_claw_arm(220) == -1:
|
by_cmd.send_angle_claw_arm(220)
|
||||||
pass
|
by_cmd.send_angle_claw(15)
|
||||||
while by_cmd.send_angle_claw(15) == -1:
|
by_cmd.send_position_axis_x(1, 20)
|
||||||
pass
|
|
||||||
while by_cmd.send_position_axis_x(1, 160) == -1:
|
|
||||||
pass
|
|
||||||
time.sleep(2)
|
|
||||||
by_cmd.send_position_axis_x(1, 0)
|
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
by_cmd.send_position_axis_x(1, 160)
|
by_cmd.send_position_axis_x(1, 120)
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
112
templates/csdn.html
Normal file
112
templates/csdn.html
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>第十九届全国大学生智能汽车竞赛 百度智慧交通创意组 “风雨同舟”比赛规则_全国大学生智能汽车竞赛 智慧交通创意-CSDN博客</title>
|
||||||
|
<script src="/static/vue.js"></script>
|
||||||
|
<script src="static/socket.io.js"></script>
|
||||||
|
<style>
|
||||||
|
body, html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
#app {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.background-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
transition: background-position 0.1s ease-out;
|
||||||
|
}
|
||||||
|
.floating-buttons {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 20px;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
.floating-button {
|
||||||
|
width: 160px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 20px;
|
||||||
|
background-color: #fc5531;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
.floating-button:hover {
|
||||||
|
background-color: #fc5531;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<div class="background-container"
|
||||||
|
:style="backgroundStyle"
|
||||||
|
@mousemove="handleMouseMove"
|
||||||
|
ref="container">
|
||||||
|
</div>
|
||||||
|
<div class="floating-buttons">
|
||||||
|
<button class="floating-button" @click="handleButton1Click">打开 CSDN APP</button>
|
||||||
|
<button class="floating-button" @click="handleButton2Click">小程序看全文</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
new Vue({
|
||||||
|
el: '#app',
|
||||||
|
data: {
|
||||||
|
imageSrc: '/static/csdn.png', // 使用大尺寸占位图片
|
||||||
|
backgroundPosition: '0%'
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
backgroundStyle() {
|
||||||
|
return {
|
||||||
|
backgroundImage: `url(${this.imageSrc})`,
|
||||||
|
backgroundPosition: `center ${this.backgroundPosition}`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleMouseMove(event) {
|
||||||
|
const containerRect = this.$refs.container.getBoundingClientRect();
|
||||||
|
const mouseY = event.clientY - containerRect.top;
|
||||||
|
const scrollPercent = (mouseY / containerRect.height) * 100;
|
||||||
|
this.backgroundPosition = `${scrollPercent}%`;
|
||||||
|
},
|
||||||
|
handleButton1Click() {
|
||||||
|
// alert('按钮 1 被点击了');
|
||||||
|
},
|
||||||
|
handleButton2Click() {
|
||||||
|
this.socket.emit('operate', { type: 'skip_task', content: '' });
|
||||||
|
},
|
||||||
|
onImageLoad() {
|
||||||
|
console.log('背景图片加载完成');
|
||||||
|
// 这里可以添加图片加载完成后的额外操作
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
const img = new Image();
|
||||||
|
img.onload = this.onImageLoad;
|
||||||
|
img.src = this.imageSrc;
|
||||||
|
this.socket = io('http://' + document.domain + ':5001');
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -123,9 +123,9 @@
|
|||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
<el-button v-if="showConfigForm" @click="toggleConfigForm" type="primary" style="margin-bottom: 20px;">
|
<!-- <el-button v-if="showConfigForm" @click="toggleConfigForm" type="primary" style="margin-bottom: 20px;">
|
||||||
{{ showConfigForm ? '关闭' : '打开' }} 配置
|
{{ showConfigForm ? '关闭' : '打开' }} 配置
|
||||||
</el-button>
|
</el-button> -->
|
||||||
|
|
||||||
<el-form v-if="showConfigForm && config" class="config-form">
|
<el-form v-if="showConfigForm && config" class="config-form">
|
||||||
<div v-for="(section, sectionName) in config" :key="sectionName">
|
<div v-for="(section, sectionName) in config" :key="sectionName">
|
||||||
@@ -133,6 +133,14 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col v-for="(value, key) in section" :key="key" :xs="24" :sm="12" :md="8" :lg="6">
|
<el-col v-for="(value, key) in section" :key="key" :xs="24" :sm="12" :md="8" :lg="6">
|
||||||
<el-form-item :label="key">
|
<el-form-item :label="key">
|
||||||
|
<el-select v-if="sectionName === 'kick_ass'" v-model="config[sectionName][key]">
|
||||||
|
<el-option
|
||||||
|
v-for="item in target_person_options"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
<el-switch
|
<el-switch
|
||||||
v-if="typeof value === 'boolean'"
|
v-if="typeof value === 'boolean'"
|
||||||
v-model="config[sectionName][key]">
|
v-model="config[sectionName][key]">
|
||||||
@@ -155,6 +163,9 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<el-button @click="saveConfig" type="primary" style="margin-top: 20px;">保存配置</el-button>
|
<el-button @click="saveConfig" type="primary" style="margin-top: 20px;">保存配置</el-button>
|
||||||
|
<el-button v-if="showConfigForm" @click="toggleConfigForm" type="primary" style="margin-bottom: 20px;">
|
||||||
|
{{ showConfigForm ? '关闭' : '打开' }} 配置
|
||||||
|
</el-button>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<h2 class="section-title">Log Display</h2>
|
<h2 class="section-title">Log Display</h2>
|
||||||
@@ -183,7 +194,20 @@
|
|||||||
files: {},
|
files: {},
|
||||||
ServerLog: "",
|
ServerLog: "",
|
||||||
showServerLogFlag: false,
|
showServerLogFlag: false,
|
||||||
timer: null
|
timer: null,
|
||||||
|
target_person_options: [{
|
||||||
|
value: 1,
|
||||||
|
label: '模式 1'
|
||||||
|
}, {
|
||||||
|
value: 2,
|
||||||
|
label: '模式 2'
|
||||||
|
}, {
|
||||||
|
value: 3,
|
||||||
|
label: '模式 3'
|
||||||
|
}, {
|
||||||
|
value: 4,
|
||||||
|
label: '模式 4'
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadConfig() {
|
loadConfig() {
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ filter.switch_camera(1)
|
|||||||
|
|
||||||
|
|
||||||
find_counts = 0
|
find_counts = 0
|
||||||
offset = 22
|
offset = 19
|
||||||
label = [tlabel.LPILLER, tlabel.MPILLER, tlabel.SPILLER]
|
label = [tlabel.LPILLER, tlabel.MPILLER, tlabel.SPILLER]
|
||||||
|
label = tlabel.TPLATFORM
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
ret, box = filter.get(tlabel.TPLATFORM)
|
ret, box = filter.get(tlabel.TPLATFORM)
|
||||||
|
|||||||
Reference in New Issue
Block a user