7. [APIs: btn_functions.py]: 重写了告警输出函数,从日志中拿数据
8. [APIs: aio.py]: 将日志框输出的内容,也保存至日志文件 9. [APIs: do_brake.py] - 修改获取初始速度的逻辑,只获取configs文件中配置的时间内的速度 - 新增 configs 参数 single_brake,可针对特定条件做测试
This commit is contained in:
@ -61,7 +61,7 @@ def gen_result_file(path, curve_data, axis, _reach, _load, _speed, count):
|
||||
_d2d_vel = {'hw_joint_vel_feedback': []}
|
||||
_d2d_trq = {'device_servo_trq_feedback': []}
|
||||
_d2d_stop = {'device_safety_estop': []}
|
||||
for data in curve_data[-240:]:
|
||||
for data in curve_data[-240:]: # 保留最后12s的数据
|
||||
dict_results = data['data']
|
||||
for item in dict_results:
|
||||
try:
|
||||
@ -85,6 +85,7 @@ def gen_result_file(path, curve_data, axis, _reach, _load, _speed, count):
|
||||
|
||||
def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
|
||||
_count = 0
|
||||
_total = 63
|
||||
display_pdo_params = [
|
||||
{"name": "hw_joint_vel_feedback", "channel": 0},
|
||||
{"name": "hw_joint_vel_feedback", "channel": 1},
|
||||
@ -104,6 +105,8 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
|
||||
ws = wb['Target']
|
||||
write_diagnosis = float(ws.cell(row=3, column=10).value)
|
||||
get_init_speed = float(ws.cell(row=4, column=10).value)
|
||||
single_brake = ws.cell(row=5, column=10).value
|
||||
|
||||
if ws.cell(row=1, column=1).value == 'positive':
|
||||
md.write_pon(1)
|
||||
elif ws.cell(row=1, column=1).value == 'negative':
|
||||
@ -118,7 +121,19 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
|
||||
_load = condition.split('_')[1].removeprefix('load')
|
||||
_speed = condition.split('_')[2].removeprefix('speed')
|
||||
|
||||
# for single condition test
|
||||
_single_axis = 0
|
||||
if single_brake != '0':
|
||||
_total = 3
|
||||
_single_axis = int(single_brake.split('-')[0])
|
||||
if _reach != single_brake.split('-')[1] or _load != single_brake.split('-')[2] or _speed != single_brake.split('-')[3]:
|
||||
continue
|
||||
|
||||
for axis in range(1, 4):
|
||||
# for single condition test
|
||||
if _single_axis != 0 and _single_axis != axis:
|
||||
continue
|
||||
|
||||
md.write_axis(axis)
|
||||
speed_max = 0
|
||||
if axis == 3 and _reach != '100':
|
||||
@ -130,7 +145,7 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
|
||||
_count += 1
|
||||
this_time = strftime("%Y-%m-%d %H:%M:%S", localtime(time()))
|
||||
prj_path = 'target/_build/target.prj'
|
||||
w2t(f"[{this_time} | {_count}/63] 正在执行 {axis} 轴 {condition} 的第 {count} 次制动测试...", 0, 0, 'purple', tab_name)
|
||||
w2t(f"[{this_time} | {_count}/{_total}] 正在执行 {axis} 轴 {condition} 的第 {count} 次制动测试...", 0, 0, 'purple', tab_name)
|
||||
|
||||
# 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
|
||||
md.trigger_estop()
|
||||
@ -180,13 +195,17 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
|
||||
w2t("20s内未收到机器人的运行信号,需要确认RL程序编写正确并正常执行...", 0, 111, 'red', tab_name)
|
||||
else:
|
||||
sleep(1)
|
||||
# 4. 打开诊断曲线,并执行采集,之后触发软急停,关闭曲线采集,找出最大速度,传递给RL程序,最后清除相关记录
|
||||
sleep(get_init_speed) # 获取实际最大速度,可通过configs.xlsx配置
|
||||
# 4. 找出最大速度,传递给RL程序,最后清除相关记录
|
||||
sleep(get_init_speed+5) # 冗余5s,指定时间后获取实际【正|负】方向的最大速度,可通过configs.xlsx配置
|
||||
clibs.execution('rl_task.stop', hr, w2t, tab_name, tasks=['brake'])
|
||||
# 找出最大速度
|
||||
_c_msg = hr.c_msg.copy()
|
||||
_number = 0
|
||||
for _msg in _c_msg:
|
||||
if _number > get_init_speed*20: # 最开始回零点的时候,二轴速度可以达到最大值,实际摆动时,某一方向可能达不到
|
||||
break
|
||||
if 'diagnosis.result' in _msg:
|
||||
_number += 1
|
||||
dict_results = loads(_msg)['data']
|
||||
for item in dict_results:
|
||||
if item.get('channel', None) == axis-1 and item.get('name', None) == 'hw_joint_vel_feedback':
|
||||
@ -195,7 +214,7 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t):
|
||||
speed_max = max(_, speed_max)
|
||||
elif ws.cell(row=1, column=1).value == 'negative':
|
||||
speed_max = min(_, speed_max)
|
||||
print(f"speed max = {speed_max}")
|
||||
logger.info(f"speed max = {speed_max}")
|
||||
speed_max = abs(speed_max)
|
||||
speed_target = float(ws.cell(row=3, column=axis+1).value) * float(_speed) / 100
|
||||
if speed_max < speed_target*0.95 or speed_max > speed_target*1.05:
|
||||
|
Reference in New Issue
Block a user