区域赛版本
This commit is contained in:
29
app.py
29
app.py
@@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, render_template
|
from flask import Flask, render_template, request
|
||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
import toml
|
import toml
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@@ -51,6 +51,8 @@ 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_args.toml','cfg_main.toml', 'cfg_subtask.toml']
|
fileOptions_list = ['cfg_args.toml','cfg_main.toml', 'cfg_subtask.toml']
|
||||||
|
cfg_args_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
@@ -58,11 +60,16 @@ def index():
|
|||||||
|
|
||||||
@app.route('/run')
|
@app.route('/run')
|
||||||
def run():
|
def run():
|
||||||
return render_template('index1.html')
|
mode_index = request.args.get('mode')
|
||||||
|
config_args = toml.load(cfg_args_path)
|
||||||
|
config_args['lane_mode']['mode_index'] = int(mode_index)
|
||||||
|
with open(cfg_args_path, 'w') as config_file:
|
||||||
|
toml.dump(config_args, config_file)
|
||||||
|
return render_template('index2.html')
|
||||||
|
|
||||||
@app.route('/csdn')
|
# @app.route('/csdn')
|
||||||
def csdn():
|
# def csdn():
|
||||||
return render_template('csdn.html')
|
# return render_template('csdn.html')
|
||||||
|
|
||||||
@socketio.on('operate')
|
@socketio.on('operate')
|
||||||
def operate_handle(data):
|
def operate_handle(data):
|
||||||
@@ -134,12 +141,12 @@ def operate_handle(data):
|
|||||||
elif data['type'] == 'skip_task':
|
elif data['type'] == 'skip_task':
|
||||||
logger.info(data)
|
logger.info(data)
|
||||||
skip_task_queue.put(1)
|
skip_task_queue.put(1)
|
||||||
elif data['type'] == 'save_target_person':
|
# elif data['type'] == 'save_target_person':
|
||||||
config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
# config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||||
config_args = toml.load(config_path)
|
# config_args = toml.load(config_path)
|
||||||
config_args['lane_mode']['mode_index'] = int(data['content'])
|
# config_args['lane_mode']['mode_index'] = int(data['content'])
|
||||||
with open(config_path, 'w') as config_file:
|
# with open(config_path, 'w') as config_file:
|
||||||
toml.dump(config_args, config_file)
|
# toml.dump(config_args, config_file)
|
||||||
|
|
||||||
@socketio.on('connect')
|
@socketio.on('connect')
|
||||||
def test_connect():
|
def test_connect():
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[lane_mode]
|
[lane_mode]
|
||||||
mode_index = 3
|
mode_index = 1
|
||||||
|
|
||||||
[task]
|
[task]
|
||||||
Subtask_enable = true
|
Subtask_enable = true
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ logger_format = "{time} {level} {message}"
|
|||||||
|
|
||||||
[find_counts]
|
[find_counts]
|
||||||
GetBlock_counts = 5
|
GetBlock_counts = 5
|
||||||
PutBlock_counts = 8
|
PutBlock_counts = 12
|
||||||
GetBBall_counts = 5
|
GetBBall_counts = 5
|
||||||
UpTower_counts = 3
|
UpTower_counts = 3
|
||||||
GetRBall_counts = 10
|
GetRBall_counts = 10
|
||||||
PutBBall_counts = 15
|
PutBBall_counts = 15
|
||||||
PutHanoi1_counts = 7
|
PutHanoi1_counts = 7
|
||||||
PutHanoi2_counts = 2
|
PutHanoi2_counts = 2
|
||||||
PutHanoi3_counts = 1
|
PutHanoi3_counts = 5
|
||||||
MoveArea1_counts = 6
|
MoveArea1_counts = 6
|
||||||
MoveArea2_counts = 1700
|
MoveArea2_counts = 1700
|
||||||
KickAss_counts = 10
|
KickAss_counts = 10
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[get_block]
|
[get_block]
|
||||||
pid_kp = 1.2
|
pid_kp = 1.0
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
first_block = "blue"
|
first_block = "blue"
|
||||||
@@ -15,17 +15,17 @@ pid_ki = 0
|
|||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[up_tower]
|
[up_tower]
|
||||||
pid_kp = 1.1
|
pid_kp = 1.0
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[get_rball]
|
[get_rball]
|
||||||
pid_kp = 0.8
|
pid_kp = 1.5
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[put_bball]
|
[put_bball]
|
||||||
pid_kp = 1.6
|
pid_kp = 2.0
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ pos_gap = 160
|
|||||||
first_target = "mp"
|
first_target = "mp"
|
||||||
|
|
||||||
[put_hanoi3]
|
[put_hanoi3]
|
||||||
pid_kp = 1.3
|
pid_kp = 1.7
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pid_ki = 0
|
|||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
|
|
||||||
[put_hanoi2]
|
[put_hanoi2]
|
||||||
pid_kp = 1.0
|
pid_kp = 2.0
|
||||||
pid_ki = 0
|
pid_ki = 0
|
||||||
pid_kd = 0
|
pid_kd = 0
|
||||||
pos_gap = 160
|
pos_gap = 160
|
||||||
|
|||||||
30
main.py
30
main.py
@@ -27,21 +27,21 @@ act.axis.exec()
|
|||||||
|
|
||||||
# 向任务队列添加任务
|
# 向任务队列添加任务
|
||||||
task_queue = queue.Queue()
|
task_queue = queue.Queue()
|
||||||
if cfg_main['task']['Subtask_enable'] is True:
|
# if cfg_main['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_main['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_main['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_main['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_main['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_main['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_main['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_main['task']['GetBBall_enable'] and cfg_main['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_main['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_main['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_main['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_main['task']['KickAss_enable']))
|
||||||
# 将任务队列传入调度模块中
|
# 将任务队列传入调度模块中
|
||||||
task_queuem_t = sb.task_queuem(task_queue)
|
task_queuem_t = sb.task_queuem(task_queue)
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ def main_func(_queue, _skip_queue):
|
|||||||
task_queue.put(sb.task("整装上阵", sb.get_bball, cfg_main['find_counts']['GetBBall_counts'], cfg_args['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_args['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_args['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_args['task']['GetBBall_enable'] and cfg_args['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_args['task']['PutHanoi_enable']))
|
task_queue.put(sb.task("物资盘点二阶段", sb.put_hanoi2, cfg_main['find_counts']['PutHanoi2_counts'], cfg_args['task']['PutHanoi_enable']))
|
||||||
|
|||||||
33
subtask.py
33
subtask.py
@@ -546,7 +546,7 @@ class put_block():
|
|||||||
ret, box = filter.get(tlabel.HOSPITAL)
|
ret, box = filter.get(tlabel.HOSPITAL)
|
||||||
if ret > 0:
|
if ret > 0:
|
||||||
width = box[0][2] - box[0][0]
|
width = box[0][2] - box[0][0]
|
||||||
if width > 130:
|
if width > 135:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
def exec(self):
|
def exec(self):
|
||||||
@@ -557,7 +557,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, 20)
|
by_cmd.send_position_axis_x(1, 50) # 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)
|
||||||
@@ -582,7 +582,7 @@ 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, 20)
|
by_cmd.send_position_axis_x(1, 50)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
by_cmd.send_angle_claw(45)
|
by_cmd.send_angle_claw(45)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -702,12 +702,12 @@ class up_tower():
|
|||||||
by_cmd.send_distance_x(-10, 120)
|
by_cmd.send_distance_x(-10, 120)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
# 上古參數
|
# 上古參數
|
||||||
# by_cmd.send_distance_y(-10, 50)
|
by_cmd.send_distance_y(-10, 80)
|
||||||
# 6_9 模型參數
|
# 6_9 模型參數
|
||||||
by_cmd.send_distance_y(-10, 40)
|
# by_cmd.send_distance_y(-10, 40)
|
||||||
# 7_12_3 模型參數
|
# 7_12_3 模型參數
|
||||||
# by_cmd.send_distance_y(-10, 50)
|
# by_cmd.send_distance_y(-10, 50)
|
||||||
# time.sleep(1)
|
time.sleep(2)
|
||||||
car_stop()
|
car_stop()
|
||||||
# FIXME 如果下發 distance 後直接 car_stop,則 distance 執行時間僅由指令間處理延時決定
|
# FIXME 如果下發 distance 後直接 car_stop,則 distance 執行時間僅由指令間處理延時決定
|
||||||
# time.sleep(3)
|
# time.sleep(3)
|
||||||
@@ -758,21 +758,23 @@ class get_rball():
|
|||||||
# 靠近塔
|
# 靠近塔
|
||||||
by_cmd.send_angle_scoop(20)
|
by_cmd.send_angle_scoop(20)
|
||||||
# 上古參數
|
# 上古參數
|
||||||
# by_cmd.send_distance_y(-15, 45) # 50
|
by_cmd.send_distance_y(-15, 70) # 50
|
||||||
# 6_9 參數
|
# 6_9 參數
|
||||||
by_cmd.send_distance_y(-15, 35)
|
# by_cmd.send_distance_y(-15, 35)
|
||||||
time.sleep(2)
|
# time.sleep(2)
|
||||||
# 7_12_3 參數
|
# 7_12_3 參數
|
||||||
# by_cmd.send_distance_y(-15, 45)
|
# by_cmd.send_distance_y(-15, 45)
|
||||||
# time.sleep(2)
|
time.sleep(2)
|
||||||
car_stop()
|
car_stop()
|
||||||
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
logger.info("抓红球")
|
logger.info("抓红球")
|
||||||
# by_cmd.send_angle_scoop(15)
|
# by_cmd.send_angle_scoop(12)
|
||||||
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(2.5)
|
time.sleep(2.5)
|
||||||
|
by_cmd.send_angle_scoop(12)
|
||||||
|
time.sleep(0.5)
|
||||||
by_cmd.send_angle_scoop(7)
|
by_cmd.send_angle_scoop(7)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_speed_y(15)
|
by_cmd.send_speed_y(15)
|
||||||
@@ -811,7 +813,7 @@ class put_bball():
|
|||||||
calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6)
|
calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6)
|
||||||
# by_cmd.send_distance_x(10, 10)
|
# by_cmd.send_distance_x(10, 10)
|
||||||
# 向左运动
|
# 向左运动
|
||||||
# by_cmd.send_distance_y(-10, 35)
|
by_cmd.send_distance_y(-10, 35)
|
||||||
# by_cmd.send_angle_storage(10)
|
# by_cmd.send_angle_storage(10)
|
||||||
# time.sleep(1)
|
# time.sleep(1)
|
||||||
|
|
||||||
@@ -944,7 +946,7 @@ class put_hanoi1():
|
|||||||
def after(self):
|
def after(self):
|
||||||
# var.switch_lane_model = True
|
# var.switch_lane_model = True
|
||||||
if utils.direction == tlabel.RMARK:
|
if utils.direction == tlabel.RMARK:
|
||||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"] - 0.3, cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"] - 0.2, cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
else:
|
else:
|
||||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
pass
|
pass
|
||||||
@@ -1184,7 +1186,7 @@ class put_hanoi2():
|
|||||||
# while True:
|
# while True:
|
||||||
# pass
|
# pass
|
||||||
by_cmd.send_speed_x(12)
|
by_cmd.send_speed_x(12)
|
||||||
time.sleep(1.5)
|
time.sleep(1.2)
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
def after(self):
|
def after(self):
|
||||||
@@ -1194,6 +1196,7 @@ class put_hanoi2():
|
|||||||
else:
|
else:
|
||||||
var.pid_turning.set(cfg["put_hanoi2"]["pid_kp"], cfg["put_hanoi2"]["pid_ki"], cfg["put_hanoi2"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi2"]["pid_kp"], cfg["put_hanoi2"]["pid_ki"], cfg["put_hanoi2"]["pid_kd"])
|
||||||
# time.sleep(2)
|
# time.sleep(2)
|
||||||
|
var.task_speed = 13
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class put_hanoi3():
|
class put_hanoi3():
|
||||||
@@ -1485,7 +1488,7 @@ class kick_ass():
|
|||||||
ret, box = filter.get(tlabel.BASE)
|
ret, box = filter.get(tlabel.BASE)
|
||||||
if ret:
|
if ret:
|
||||||
error = (box[0][2] + box[0][0] - 320) / 2
|
error = (box[0][2] + box[0][0] - 320) / 2
|
||||||
by_cmd.send_speed_omega(-error * 0.8)
|
by_cmd.send_speed_omega(-error * 0.8)
|
||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
# by_cmd.send_speed_x(25)
|
# by_cmd.send_speed_x(25)
|
||||||
# time.sleep(4)
|
# time.sleep(4)
|
||||||
|
|||||||
@@ -415,8 +415,8 @@ class task_queuem(task):
|
|||||||
class get_block1():
|
class get_block1():
|
||||||
def init(self):
|
def init(self):
|
||||||
var.task_speed = 15
|
var.task_speed = 15
|
||||||
act.cmd.camera(0)
|
while (by_cmd.send_angle_camera(0) == -1):
|
||||||
act.cmd.z2(20, 60, 0)
|
pass
|
||||||
filter.switch_camera(1)
|
filter.switch_camera(1)
|
||||||
# if cfg['get_block']['first_block'] == "blue":
|
# if cfg['get_block']['first_block'] == "blue":
|
||||||
# self.target_label = tlabel.BBLOCK
|
# self.target_label = tlabel.BBLOCK
|
||||||
@@ -439,8 +439,7 @@ class get_block1():
|
|||||||
if any(ret):
|
if any(ret):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def exec(self):
|
def exec(self):
|
||||||
car_stop()
|
car_stop()
|
||||||
if self.target_counts[0] > self.target_counts[1]:
|
if self.target_counts[0] > self.target_counts[1]:
|
||||||
@@ -771,8 +770,8 @@ class get_rball():
|
|||||||
logger.info("抓红球")
|
logger.info("抓红球")
|
||||||
# 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, 190) #170
|
||||||
time.sleep(2.5)
|
time.sleep(3.5)
|
||||||
by_cmd.send_angle_scoop(7)
|
by_cmd.send_angle_scoop(7)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
by_cmd.send_speed_y(15)
|
by_cmd.send_speed_y(15)
|
||||||
@@ -944,7 +943,7 @@ class put_hanoi1():
|
|||||||
def after(self):
|
def after(self):
|
||||||
# var.switch_lane_model = True
|
# var.switch_lane_model = True
|
||||||
if utils.direction == tlabel.RMARK:
|
if utils.direction == tlabel.RMARK:
|
||||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"] - 0.3, cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"] - 0.4, cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
else:
|
else:
|
||||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
pass
|
pass
|
||||||
@@ -1185,6 +1184,7 @@ class put_hanoi2():
|
|||||||
# pass
|
# pass
|
||||||
by_cmd.send_speed_x(12)
|
by_cmd.send_speed_x(12)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
|
var.task_speed = 10
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
def after(self):
|
def after(self):
|
||||||
@@ -1222,6 +1222,7 @@ class put_hanoi3():
|
|||||||
def nexec(self):
|
def nexec(self):
|
||||||
pass
|
pass
|
||||||
def after(self):
|
def after(self):
|
||||||
|
var.task_speed = 0
|
||||||
by_cmd.send_position_axis_x(1, 150)
|
by_cmd.send_position_axis_x(1, 150)
|
||||||
var.pid_turning.set(cfg["put_hanoi3"]["pid_kp"], cfg["put_hanoi3"]["pid_ki"], cfg["put_hanoi3"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi3"]["pid_kp"], cfg["put_hanoi3"]["pid_ki"], cfg["put_hanoi3"]["pid_kd"])
|
||||||
|
|
||||||
|
|||||||
@@ -557,7 +557,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, 20)
|
by_cmd.send_position_axis_x(1, 50) # 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)
|
||||||
@@ -582,7 +582,7 @@ 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, 20)
|
by_cmd.send_position_axis_x(1, 50)
|
||||||
time.sleep(1.5)
|
time.sleep(1.5)
|
||||||
by_cmd.send_angle_claw(45)
|
by_cmd.send_angle_claw(45)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -702,12 +702,12 @@ class up_tower():
|
|||||||
by_cmd.send_distance_x(-10, 120)
|
by_cmd.send_distance_x(-10, 120)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
# 上古參數
|
# 上古參數
|
||||||
# by_cmd.send_distance_y(-10, 50)
|
by_cmd.send_distance_y(-10, 60)
|
||||||
# 6_9 模型參數
|
# 6_9 模型參數
|
||||||
by_cmd.send_distance_y(-10, 40)
|
# by_cmd.send_distance_y(-10, 40)
|
||||||
# 7_12_3 模型參數
|
# 7_12_3 模型參數
|
||||||
# by_cmd.send_distance_y(-10, 50)
|
# by_cmd.send_distance_y(-10, 50)
|
||||||
# time.sleep(1)
|
time.sleep(1)
|
||||||
car_stop()
|
car_stop()
|
||||||
# FIXME 如果下發 distance 後直接 car_stop,則 distance 執行時間僅由指令間處理延時決定
|
# FIXME 如果下發 distance 後直接 car_stop,則 distance 執行時間僅由指令間處理延時決定
|
||||||
# time.sleep(3)
|
# time.sleep(3)
|
||||||
@@ -758,13 +758,13 @@ class get_rball():
|
|||||||
# 靠近塔
|
# 靠近塔
|
||||||
by_cmd.send_angle_scoop(20)
|
by_cmd.send_angle_scoop(20)
|
||||||
# 上古參數
|
# 上古參數
|
||||||
# by_cmd.send_distance_y(-15, 45) # 50
|
by_cmd.send_distance_y(-15, 50) # 50
|
||||||
# 6_9 參數
|
# 6_9 參數
|
||||||
by_cmd.send_distance_y(-15, 35)
|
# by_cmd.send_distance_y(-15, 35)
|
||||||
time.sleep(2)
|
# time.sleep(2)
|
||||||
# 7_12_3 參數
|
# 7_12_3 參數
|
||||||
# by_cmd.send_distance_y(-15, 45)
|
# by_cmd.send_distance_y(-15, 45)
|
||||||
# time.sleep(2)
|
time.sleep(2)
|
||||||
car_stop()
|
car_stop()
|
||||||
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -811,7 +811,7 @@ class put_bball():
|
|||||||
calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6)
|
calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6)
|
||||||
# by_cmd.send_distance_x(10, 10)
|
# by_cmd.send_distance_x(10, 10)
|
||||||
# 向左运动
|
# 向左运动
|
||||||
# by_cmd.send_distance_y(-10, 35)
|
by_cmd.send_distance_y(-10, 35)
|
||||||
# by_cmd.send_angle_storage(10)
|
# by_cmd.send_angle_storage(10)
|
||||||
# time.sleep(1)
|
# time.sleep(1)
|
||||||
|
|
||||||
@@ -944,7 +944,7 @@ class put_hanoi1():
|
|||||||
def after(self):
|
def after(self):
|
||||||
# var.switch_lane_model = True
|
# var.switch_lane_model = True
|
||||||
if utils.direction == tlabel.RMARK:
|
if utils.direction == tlabel.RMARK:
|
||||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"] - 0.1, cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"] - 0.2, cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
else:
|
else:
|
||||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||||
pass
|
pass
|
||||||
@@ -1194,6 +1194,7 @@ class put_hanoi2():
|
|||||||
else:
|
else:
|
||||||
var.pid_turning.set(cfg["put_hanoi2"]["pid_kp"], cfg["put_hanoi2"]["pid_ki"], cfg["put_hanoi2"]["pid_kd"])
|
var.pid_turning.set(cfg["put_hanoi2"]["pid_kp"], cfg["put_hanoi2"]["pid_ki"], cfg["put_hanoi2"]["pid_kd"])
|
||||||
# time.sleep(2)
|
# time.sleep(2)
|
||||||
|
var.task_speed = 10
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class put_hanoi3():
|
class put_hanoi3():
|
||||||
@@ -1485,7 +1486,7 @@ class kick_ass():
|
|||||||
ret, box = filter.get(tlabel.BASE)
|
ret, box = filter.get(tlabel.BASE)
|
||||||
if ret:
|
if ret:
|
||||||
error = (box[0][2] + box[0][0] - 320) / 2
|
error = (box[0][2] + box[0][0] - 320) / 2
|
||||||
by_cmd.send_speed_omega(-error * 0.8)
|
by_cmd.send_speed_omega(-error * 0.8)
|
||||||
time.sleep(0.02)
|
time.sleep(0.02)
|
||||||
# by_cmd.send_speed_x(25)
|
# by_cmd.send_speed_x(25)
|
||||||
# time.sleep(4)
|
# time.sleep(4)
|
||||||
|
|||||||
128
templates/index2.html
Normal file
128
templates/index2.html
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>btl143</title>
|
||||||
|
<link rel="stylesheet" href="static/index.css">
|
||||||
|
<script src="static/vue.js"></script>
|
||||||
|
<script src="static/index.js"></script>
|
||||||
|
<script src="static/socket.io.js"></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
}
|
||||||
|
.app-container {
|
||||||
|
padding: 20px;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-group {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.full-screen-background {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
position: fixed;
|
||||||
|
top: 60px; /* Adjust based on button height and margin */
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.counter-display {
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
position: fixed;
|
||||||
|
top: 80px; /* Adjust based on your requirements */
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<el-container class="app-container">
|
||||||
|
<el-main>
|
||||||
|
<h1 class="section-title">btl143 upper</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<el-row :gutter="20" class="button-group">
|
||||||
|
<el-col :xs="24" :sm="8">
|
||||||
|
<el-button
|
||||||
|
@click="toggleTask"
|
||||||
|
:type="taskActive ? 'success' : 'danger'"
|
||||||
|
style="width: 100%">
|
||||||
|
{{ taskActive ? `开启 task` : `关闭 task` }}
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
new Vue({
|
||||||
|
el: '#app',
|
||||||
|
data: {
|
||||||
|
taskActive: true,
|
||||||
|
counter: 1
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleTask() {
|
||||||
|
if (this.taskActive) {
|
||||||
|
this.socket.emit('operate', {type: 'operate_task', content: 'run'});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.socket.emit('operate', {type: 'operate_task', content: 'stop'});
|
||||||
|
}
|
||||||
|
this.taskActive = !this.taskActive;
|
||||||
|
},
|
||||||
|
startServer() {
|
||||||
|
this.socket.emit('operate', {type: 'operate_server', content: 'run'});
|
||||||
|
},
|
||||||
|
stopServer() {
|
||||||
|
this.socket.emit('operate', {type: 'operate_server', content: 'stop'});
|
||||||
|
},
|
||||||
|
restartServer() {
|
||||||
|
this.socket.emit('operate', {type: 'operate_server', content: 'restart'});
|
||||||
|
},
|
||||||
|
startTask() {
|
||||||
|
this.socket.emit('operate', {type: 'operate_task', content: 'run'});
|
||||||
|
},
|
||||||
|
stopTask() {
|
||||||
|
this.socket.emit('operate', {type: 'operate_task', content: 'stop'});
|
||||||
|
},
|
||||||
|
restartTask() {
|
||||||
|
this.socket.emit('operate', {type: 'operate_task', content: 'restart'});
|
||||||
|
},
|
||||||
|
skipTask() {
|
||||||
|
this.socket.emit('operate', { type: 'skip_task', content: '' });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.socket = io('http://' + document.domain + ':5001');
|
||||||
|
this.socket.on('connect', () => {
|
||||||
|
console.log('Connected to server');
|
||||||
|
});
|
||||||
|
this.socket.on('task_status', (data) => {
|
||||||
|
if (data.content == 0) {
|
||||||
|
this.taskActive = true
|
||||||
|
} else {
|
||||||
|
this.taskActive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user