Compare commits
2 Commits
de8012a590
...
v1
| Author | SHA1 | Date | |
|---|---|---|---|
| 34504d9ff9 | |||
| 211b4767c1 |
37
app.py
37
app.py
@@ -1,4 +1,4 @@
|
||||
from flask import Flask, render_template
|
||||
from flask import Flask, render_template, request
|
||||
from flask_socketio import SocketIO
|
||||
import toml
|
||||
from loguru import logger
|
||||
@@ -23,6 +23,8 @@ processes = []
|
||||
|
||||
time_record = None
|
||||
|
||||
task_run_flag = False
|
||||
|
||||
# 日志队列
|
||||
queue = Queue()
|
||||
# 跳过任务 干预任务调度
|
||||
@@ -49,14 +51,25 @@ logger.add(handler, format="{time:MM-DD HH:mm:ss} {message}", level="DEBUG")
|
||||
|
||||
fileOptions_path = '/home/evan/Workplace/project_main'
|
||||
fileOptions_list = ['cfg_args.toml','cfg_main.toml', 'cfg_subtask.toml']
|
||||
cfg_args_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/csdn')
|
||||
def csdn():
|
||||
return render_template('csdn.html')
|
||||
@app.route('/run')
|
||||
def run():
|
||||
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')
|
||||
# def csdn():
|
||||
# return render_template('csdn.html')
|
||||
|
||||
@socketio.on('operate')
|
||||
def operate_handle(data):
|
||||
@@ -64,6 +77,7 @@ def operate_handle(data):
|
||||
global task_process
|
||||
global processes
|
||||
global time_record
|
||||
global task_run_flag
|
||||
if data['type'] == 'save_config':
|
||||
f = open(os.path.join(fileOptions_path,data['file_name']), 'w')
|
||||
ret = toml.dump(data['content'], f)
|
||||
@@ -99,6 +113,7 @@ def operate_handle(data):
|
||||
elif data['type'] == 'operate_task':
|
||||
# 任务函数
|
||||
if data['content'] == 'run':
|
||||
task_run_flag = True
|
||||
if task_process != None:
|
||||
task_process.terminate()
|
||||
time_record = time.perf_counter()
|
||||
@@ -106,6 +121,7 @@ def operate_handle(data):
|
||||
task_process.start()
|
||||
logger.info("开启 task")
|
||||
elif data['content'] == 'stop':
|
||||
task_run_flag = False
|
||||
task_process.terminate()
|
||||
logger.info(f"任务结束 用时{time.perf_counter() - time_record}s")
|
||||
logger.info("关闭 task")
|
||||
@@ -125,6 +141,12 @@ def operate_handle(data):
|
||||
elif data['type'] == 'skip_task':
|
||||
logger.info(data)
|
||||
skip_task_queue.put(1)
|
||||
# elif data['type'] == 'save_target_person':
|
||||
# config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||
# config_args = toml.load(config_path)
|
||||
# config_args['lane_mode']['mode_index'] = int(data['content'])
|
||||
# with open(config_path, 'w') as config_file:
|
||||
# toml.dump(config_args, config_file)
|
||||
|
||||
@socketio.on('connect')
|
||||
def test_connect():
|
||||
@@ -134,6 +156,7 @@ def test_connect():
|
||||
for item in fileOptions_list:
|
||||
config_data[item] = toml.load(os.path.join(fileOptions_path,item))
|
||||
socketio.emit('config_data', {'type': 'config_data', 'content': config_data})
|
||||
socketio.emit('task_status', {'type': 'task_status', 'content': int(task_run_flag)})
|
||||
def thread_function():
|
||||
global queue
|
||||
while True:
|
||||
@@ -146,6 +169,12 @@ def thread_function():
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
config_path = os.path.join(fileOptions_path, 'cfg_args.toml')
|
||||
config_args = toml.load(config_path)
|
||||
config_args['lane_mode']['mode_index'] = 1
|
||||
with open(config_path, 'w') as config_file:
|
||||
toml.dump(config_args, config_file)
|
||||
|
||||
log_file = "server_processes.log"
|
||||
log = open(log_file, "w")
|
||||
time.sleep(2)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[lane_mode]
|
||||
mode_index = 3
|
||||
mode_index = 1
|
||||
|
||||
[task]
|
||||
Subtask_enable = true
|
||||
|
||||
@@ -6,14 +6,14 @@ logger_format = "{time} {level} {message}"
|
||||
|
||||
[find_counts]
|
||||
GetBlock_counts = 5
|
||||
PutBlock_counts = 8
|
||||
PutBlock_counts = 12
|
||||
GetBBall_counts = 5
|
||||
UpTower_counts = 3
|
||||
GetRBall_counts = 10
|
||||
PutBBall_counts = 15
|
||||
PutHanoi1_counts = 7
|
||||
PutHanoi2_counts = 2
|
||||
PutHanoi3_counts = 1
|
||||
PutHanoi3_counts = 5
|
||||
MoveArea1_counts = 6
|
||||
MoveArea2_counts = 1700
|
||||
KickAss_counts = 10
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[get_block]
|
||||
pid_kp = 1.2
|
||||
pid_kp = 1.0
|
||||
pid_ki = 0
|
||||
pid_kd = 0
|
||||
first_block = "blue"
|
||||
@@ -15,17 +15,17 @@ pid_ki = 0
|
||||
pid_kd = 0
|
||||
|
||||
[up_tower]
|
||||
pid_kp = 1.1
|
||||
pid_kp = 1.0
|
||||
pid_ki = 0
|
||||
pid_kd = 0
|
||||
|
||||
[get_rball]
|
||||
pid_kp = 0.8
|
||||
pid_kp = 1.5
|
||||
pid_ki = 0
|
||||
pid_kd = 0
|
||||
|
||||
[put_bball]
|
||||
pid_kp = 1.6
|
||||
pid_kp = 2.0
|
||||
pid_ki = 0
|
||||
pid_kd = 0
|
||||
|
||||
@@ -42,7 +42,7 @@ pos_gap = 160
|
||||
first_target = "mp"
|
||||
|
||||
[put_hanoi3]
|
||||
pid_kp = 1.3
|
||||
pid_kp = 1.7
|
||||
pid_ki = 0
|
||||
pid_kd = 0
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ pid_ki = 0
|
||||
pid_kd = 0
|
||||
|
||||
[put_hanoi2]
|
||||
pid_kp = 1.0
|
||||
pid_kp = 2.0
|
||||
pid_ki = 0
|
||||
pid_kd = 0
|
||||
pos_gap = 160
|
||||
|
||||
30
main.py
30
main.py
@@ -27,21 +27,21 @@ act.axis.exec()
|
||||
|
||||
# 向任务队列添加任务
|
||||
task_queue = queue.Queue()
|
||||
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_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.get_bball, cfg_main['find_counts']['GetBBall_counts'], cfg_main['task']['GetBBall_enable']))
|
||||
# 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.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_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_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_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']))
|
||||
# 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_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.get_bball, cfg_main['find_counts']['GetBBall_counts'], cfg_main['task']['GetBBall_enable']))
|
||||
# # 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.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_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_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_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_queuem_t = sb.task_queuem(task_queue)
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ def main_func(_queue, _skip_queue):
|
||||
|
||||
# 配置日志输出
|
||||
logger.add(cfg_main['debug']['logger_filename'], format=cfg_main['debug']['logger_format'], retention = 5, level="INFO")
|
||||
logger.info(cfg_args)
|
||||
|
||||
act.axis.camera(0)
|
||||
act.axis.x2(140)
|
||||
@@ -59,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']))
|
||||
# # 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.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_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']))
|
||||
|
||||
31
subtask.py
31
subtask.py
@@ -546,7 +546,7 @@ class put_block():
|
||||
ret, box = filter.get(tlabel.HOSPITAL)
|
||||
if ret > 0:
|
||||
width = box[0][2] - box[0][0]
|
||||
if width > 130:
|
||||
if width > 135:
|
||||
return True
|
||||
return False
|
||||
def exec(self):
|
||||
@@ -557,7 +557,7 @@ class put_block():
|
||||
by_cmd.send_distance_x(10, 100)
|
||||
by_cmd.send_position_axis_z(30, 0)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_position_axis_x(1, 20)
|
||||
by_cmd.send_position_axis_x(1, 50) # 20
|
||||
time.sleep(1)
|
||||
by_cmd.send_angle_claw(63)
|
||||
time.sleep(1)
|
||||
@@ -582,7 +582,7 @@ class put_block():
|
||||
time.sleep(1)
|
||||
by_cmd.send_position_axis_z(30, 0)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_position_axis_x(1, 20)
|
||||
by_cmd.send_position_axis_x(1, 50)
|
||||
time.sleep(1.5)
|
||||
by_cmd.send_angle_claw(45)
|
||||
time.sleep(1)
|
||||
@@ -702,12 +702,12 @@ class up_tower():
|
||||
by_cmd.send_distance_x(-10, 120)
|
||||
time.sleep(1)
|
||||
# 上古參數
|
||||
# by_cmd.send_distance_y(-10, 50)
|
||||
by_cmd.send_distance_y(-10, 80)
|
||||
# 6_9 模型參數
|
||||
by_cmd.send_distance_y(-10, 40)
|
||||
# by_cmd.send_distance_y(-10, 40)
|
||||
# 7_12_3 模型參數
|
||||
# by_cmd.send_distance_y(-10, 50)
|
||||
# time.sleep(1)
|
||||
time.sleep(2)
|
||||
car_stop()
|
||||
# FIXME 如果下發 distance 後直接 car_stop,則 distance 執行時間僅由指令間處理延時決定
|
||||
# time.sleep(3)
|
||||
@@ -758,21 +758,23 @@ class get_rball():
|
||||
# 靠近塔
|
||||
by_cmd.send_angle_scoop(20)
|
||||
# 上古參數
|
||||
# by_cmd.send_distance_y(-15, 45) # 50
|
||||
by_cmd.send_distance_y(-15, 70) # 50
|
||||
# 6_9 參數
|
||||
by_cmd.send_distance_y(-15, 35)
|
||||
time.sleep(2)
|
||||
# by_cmd.send_distance_y(-15, 35)
|
||||
# time.sleep(2)
|
||||
# 7_12_3 參數
|
||||
# by_cmd.send_distance_y(-15, 45)
|
||||
# time.sleep(2)
|
||||
time.sleep(2)
|
||||
car_stop()
|
||||
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
||||
time.sleep(1)
|
||||
logger.info("抓红球")
|
||||
# by_cmd.send_angle_scoop(15)
|
||||
# by_cmd.send_angle_scoop(12)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_position_axis_z(30, 170)
|
||||
time.sleep(2.5)
|
||||
by_cmd.send_angle_scoop(12)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_angle_scoop(7)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_speed_y(15)
|
||||
@@ -811,7 +813,7 @@ class put_bball():
|
||||
calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6)
|
||||
# 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)
|
||||
# time.sleep(1)
|
||||
|
||||
@@ -944,7 +946,7 @@ class put_hanoi1():
|
||||
def after(self):
|
||||
# var.switch_lane_model = True
|
||||
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:
|
||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||
pass
|
||||
@@ -1184,7 +1186,7 @@ class put_hanoi2():
|
||||
# while True:
|
||||
# pass
|
||||
by_cmd.send_speed_x(12)
|
||||
time.sleep(1.5)
|
||||
time.sleep(1.2)
|
||||
def nexec(self):
|
||||
pass
|
||||
def after(self):
|
||||
@@ -1194,6 +1196,7 @@ class put_hanoi2():
|
||||
else:
|
||||
var.pid_turning.set(cfg["put_hanoi2"]["pid_kp"], cfg["put_hanoi2"]["pid_ki"], cfg["put_hanoi2"]["pid_kd"])
|
||||
# time.sleep(2)
|
||||
var.task_speed = 13
|
||||
pass
|
||||
|
||||
class put_hanoi3():
|
||||
|
||||
@@ -415,8 +415,8 @@ class task_queuem(task):
|
||||
class get_block1():
|
||||
def init(self):
|
||||
var.task_speed = 15
|
||||
act.cmd.camera(0)
|
||||
act.cmd.z2(20, 60, 0)
|
||||
while (by_cmd.send_angle_camera(0) == -1):
|
||||
pass
|
||||
filter.switch_camera(1)
|
||||
# if cfg['get_block']['first_block'] == "blue":
|
||||
# self.target_label = tlabel.BBLOCK
|
||||
@@ -440,7 +440,6 @@ class get_block1():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def exec(self):
|
||||
car_stop()
|
||||
if self.target_counts[0] > self.target_counts[1]:
|
||||
@@ -771,8 +770,8 @@ class get_rball():
|
||||
logger.info("抓红球")
|
||||
# by_cmd.send_angle_scoop(15)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_position_axis_z(30, 170)
|
||||
time.sleep(2.5)
|
||||
by_cmd.send_position_axis_z(30, 190) #170
|
||||
time.sleep(3.5)
|
||||
by_cmd.send_angle_scoop(7)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_speed_y(15)
|
||||
@@ -944,7 +943,7 @@ class put_hanoi1():
|
||||
def after(self):
|
||||
# var.switch_lane_model = True
|
||||
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:
|
||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||
pass
|
||||
@@ -1185,6 +1184,7 @@ class put_hanoi2():
|
||||
# pass
|
||||
by_cmd.send_speed_x(12)
|
||||
time.sleep(1.5)
|
||||
var.task_speed = 10
|
||||
def nexec(self):
|
||||
pass
|
||||
def after(self):
|
||||
@@ -1222,6 +1222,7 @@ class put_hanoi3():
|
||||
def nexec(self):
|
||||
pass
|
||||
def after(self):
|
||||
var.task_speed = 0
|
||||
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"])
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ class put_block():
|
||||
by_cmd.send_distance_x(10, 100)
|
||||
by_cmd.send_position_axis_z(30, 0)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_position_axis_x(1, 20)
|
||||
by_cmd.send_position_axis_x(1, 50) # 20
|
||||
time.sleep(1)
|
||||
by_cmd.send_angle_claw(63)
|
||||
time.sleep(1)
|
||||
@@ -582,7 +582,7 @@ class put_block():
|
||||
time.sleep(1)
|
||||
by_cmd.send_position_axis_z(30, 0)
|
||||
time.sleep(0.5)
|
||||
by_cmd.send_position_axis_x(1, 20)
|
||||
by_cmd.send_position_axis_x(1, 50)
|
||||
time.sleep(1.5)
|
||||
by_cmd.send_angle_claw(45)
|
||||
time.sleep(1)
|
||||
@@ -702,12 +702,12 @@ class up_tower():
|
||||
by_cmd.send_distance_x(-10, 120)
|
||||
time.sleep(1)
|
||||
# 上古參數
|
||||
# by_cmd.send_distance_y(-10, 50)
|
||||
by_cmd.send_distance_y(-10, 60)
|
||||
# 6_9 模型參數
|
||||
by_cmd.send_distance_y(-10, 40)
|
||||
# by_cmd.send_distance_y(-10, 40)
|
||||
# 7_12_3 模型參數
|
||||
# by_cmd.send_distance_y(-10, 50)
|
||||
# time.sleep(1)
|
||||
time.sleep(1)
|
||||
car_stop()
|
||||
# FIXME 如果下發 distance 後直接 car_stop,則 distance 執行時間僅由指令間處理延時決定
|
||||
# time.sleep(3)
|
||||
@@ -758,13 +758,13 @@ class get_rball():
|
||||
# 靠近塔
|
||||
by_cmd.send_angle_scoop(20)
|
||||
# 上古參數
|
||||
# by_cmd.send_distance_y(-15, 45) # 50
|
||||
by_cmd.send_distance_y(-15, 50) # 50
|
||||
# 6_9 參數
|
||||
by_cmd.send_distance_y(-15, 35)
|
||||
time.sleep(2)
|
||||
# by_cmd.send_distance_y(-15, 35)
|
||||
# time.sleep(2)
|
||||
# 7_12_3 參數
|
||||
# by_cmd.send_distance_y(-15, 45)
|
||||
# time.sleep(2)
|
||||
time.sleep(2)
|
||||
car_stop()
|
||||
calibrate_new(tlabel.RBALL,offset = 44, run = True)
|
||||
time.sleep(1)
|
||||
@@ -811,7 +811,7 @@ class put_bball():
|
||||
calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6)
|
||||
# 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)
|
||||
# time.sleep(1)
|
||||
|
||||
@@ -944,7 +944,7 @@ class put_hanoi1():
|
||||
def after(self):
|
||||
# var.switch_lane_model = True
|
||||
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:
|
||||
var.pid_turning.set(cfg["put_hanoi1"]["pid_kp"], cfg["put_hanoi1"]["pid_ki"], cfg["put_hanoi1"]["pid_kd"])
|
||||
pass
|
||||
@@ -1194,6 +1194,7 @@ class put_hanoi2():
|
||||
else:
|
||||
var.pid_turning.set(cfg["put_hanoi2"]["pid_kp"], cfg["put_hanoi2"]["pid_ki"], cfg["put_hanoi2"]["pid_kd"])
|
||||
# time.sleep(2)
|
||||
var.task_speed = 10
|
||||
pass
|
||||
|
||||
class put_hanoi3():
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="8">
|
||||
<el-button @click="skipTask" type="success" style="width: 100%">
|
||||
强制跳转
|
||||
关闭
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -128,12 +128,16 @@
|
||||
</el-button> -->
|
||||
|
||||
<el-form v-if="showConfigForm && config" class="config-form">
|
||||
<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>
|
||||
<div v-for="(section, sectionName) in config" :key="sectionName">
|
||||
<h3>{{ sectionName }}</h3>
|
||||
<el-row :gutter="20">
|
||||
<el-col v-for="(value, key) in section" :key="key" :xs="24" :sm="12" :md="8" :lg="6">
|
||||
<el-form-item :label="key">
|
||||
<el-select v-if="sectionName === 'kick_ass'" v-model="config[sectionName][key]">
|
||||
<el-select v-if="sectionName === 'lane_mode'" v-model="config[sectionName][key]">
|
||||
<el-option
|
||||
v-for="item in target_person_options"
|
||||
:key="item.value"
|
||||
@@ -162,10 +166,7 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<h2 class="section-title">Log Display</h2>
|
||||
@@ -197,16 +198,16 @@
|
||||
timer: null,
|
||||
target_person_options: [{
|
||||
value: 1,
|
||||
label: '模式 1'
|
||||
label: '6_9'
|
||||
}, {
|
||||
value: 2,
|
||||
label: '模式 2'
|
||||
label: '7_10_2'
|
||||
}, {
|
||||
value: 3,
|
||||
label: '模式 3'
|
||||
label: '7_14_2'
|
||||
}, {
|
||||
value: 4,
|
||||
label: '模式 4'
|
||||
label: '7_15_4'
|
||||
}],
|
||||
},
|
||||
methods: {
|
||||
|
||||
139
templates/index1.html
Normal file
139
templates/index1.html
Normal file
@@ -0,0 +1,139 @@
|
||||
<!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 ${counter}` : `关闭 task ${counter}` }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div class="full-screen-background" @click="incrementCounter">
|
||||
<div class="counter-display">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</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;
|
||||
},
|
||||
incrementCounter() {
|
||||
this.counter += 1;
|
||||
if (this.counter == 5) {
|
||||
this.counter = 1;
|
||||
}
|
||||
this.socket.emit('operate', {type: 'save_target_person', content: this.counter});
|
||||
},
|
||||
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>
|
||||
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