v0.2.0.0(2024/07/17)
1. [profile: aio.py] - 增加velocity相关逻辑 - 修改负载信息为曲线信息 2. [profile: factory_test.py] - 增加velocity相关逻辑 3. [profile: current.py] - 修正减速比获取的规则 4. [profile: openapi.py] - HmiRequest模块:日志取消记录move.monitor相关 - HmiRequest模块:增加了durable_lock变量,控制文件读写互斥
This commit is contained in:
@ -43,6 +43,8 @@ durable_data_velocity = {
|
||||
'axis5': [0 for _ in range(25)],
|
||||
'axis6': [0 for _ in range(25)],
|
||||
}
|
||||
data_all = [durable_data_current, durable_data_velocity]
|
||||
|
||||
|
||||
def traversal_files(path, w2t):
|
||||
if not exists(path):
|
||||
@ -118,6 +120,7 @@ def execution(cmd, hr, w2t, **kwargs):
|
||||
def run_rl(path, config_file, hr, md, w2t):
|
||||
# 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
|
||||
_response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
|
||||
_response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=[])
|
||||
md.trigger_estop()
|
||||
md.reset_estop()
|
||||
md.write_act(False)
|
||||
@ -170,9 +173,7 @@ def run_rl(path, config_file, hr, md, w2t):
|
||||
_response = execution('rl_task.stop', hr, w2t, tasks=['current'])
|
||||
sleep(1) # 保证所有数据均已返回
|
||||
# 7. 保留数据并处理输出
|
||||
data = get_durable_data(path, config_file, durable_data_current, scenario_time, hr, w2t)
|
||||
df = pd.DataFrame(data)
|
||||
df.to_excel(durable_data_current_xlsx, index=False)
|
||||
get_durable_data(path, config_file, data_all, scenario_time, hr, w2t)
|
||||
|
||||
# 8. 继续运行
|
||||
_response = execution('rl_task.run', hr, w2t, tasks=['current'])
|
||||
@ -185,9 +186,7 @@ def run_rl(path, config_file, hr, md, w2t):
|
||||
_response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
|
||||
_response = execution('diagnosis.set_params', hr, w2t, display_pdo_params=[])
|
||||
# 7. 保留数据并处理输出
|
||||
data = get_durable_data(path, config_file, durable_data_current, scenario_time, hr, w2t)
|
||||
df = pd.DataFrame(data)
|
||||
df.to_excel(durable_data_current_xlsx, index=False)
|
||||
get_durable_data(path, config_file, data_all, scenario_time, hr, w2t)
|
||||
|
||||
|
||||
def get_durable_data(path, config_file, data, scenario_time, hr, w2t):
|
||||
@ -218,19 +217,49 @@ def get_durable_data(path, config_file, data, scenario_time, hr, w2t):
|
||||
'device_servo_trq_feedback_0': [], 'device_servo_trq_feedback_1': [], 'device_servo_trq_feedback_2': [],
|
||||
'device_servo_trq_feedback_3': [], 'device_servo_trq_feedback_4': [], 'device_servo_trq_feedback_5': [],
|
||||
}
|
||||
_d2d_vel = {
|
||||
'hw_joint_vel_feedback_0': [], 'hw_joint_vel_feedback_1': [], 'hw_joint_vel_feedback_2': [],
|
||||
'hw_joint_vel_feedback_3': [], 'hw_joint_vel_feedback_4': [], 'hw_joint_vel_feedback_5': [],
|
||||
}
|
||||
for line in _data_list:
|
||||
for item in line['data']:
|
||||
for i in range(6):
|
||||
item['value'].reverse()
|
||||
if item.get('channel', None) == i and item.get('name', None) == 'device_servo_trq_feedback':
|
||||
_d2d_trq[f'device_servo_trq_feedback_{i}'].extend(item['value'])
|
||||
elif item.get('channel', None) == i and item.get('name', None) == 'hw_joint_vel_feedback':
|
||||
_d2d_vel[f'hw_joint_vel_feedback_{i}'].extend(item['value'])
|
||||
|
||||
if len(_d2d_trq['device_servo_trq_feedback_0']) / 1000 > scenario_time + 1:
|
||||
_df = pd.DataFrame(_d2d_trq)
|
||||
for i in range(6):
|
||||
_ = sqrt(_df[f'device_servo_trq_feedback_{i}'].apply(lambda x: (rcs[i]*x/1000)**2).sum()/len(_df[f'device_servo_trq_feedback_{i}']))
|
||||
del data[f"axis{i + 1}"][0]
|
||||
data[f"axis{i + 1}"].append(_)
|
||||
del data[0][f"axis{i + 1}"][0]
|
||||
data[0][f"axis{i + 1}"].append(_)
|
||||
_df = pd.DataFrame(data[0])
|
||||
while True:
|
||||
if not hr.durable_lock:
|
||||
hr.durable_lock = 1
|
||||
_df.to_excel(durable_data_current_xlsx, index=False)
|
||||
hr.durable_lock = 0
|
||||
break
|
||||
else:
|
||||
sleep(1)
|
||||
|
||||
_df = pd.DataFrame(_d2d_vel)
|
||||
for i in range(6):
|
||||
_ = sqrt(_df[f'hw_joint_vel_feedback_{i}'].apply(lambda x: (rcs[i]*x/1000)**2).sum()/len(_df[f'hw_joint_vel_feedback_{i}']))
|
||||
del data[1][f"axis{i + 1}"][0]
|
||||
data[1][f"axis{i + 1}"].append(_)
|
||||
_df = pd.DataFrame(data[1])
|
||||
while True:
|
||||
if not hr.durable_lock:
|
||||
hr.durable_lock = 1
|
||||
_df.to_excel(durable_data_velocity_xlsx, index=False)
|
||||
hr.durable_lock = 0
|
||||
break
|
||||
else:
|
||||
sleep(1)
|
||||
break
|
||||
else:
|
||||
with open(f'{path}\\device_servo_trq_feedback_0.txt', 'w', encoding='utf-8') as f_obj:
|
||||
@ -238,8 +267,6 @@ def get_durable_data(path, config_file, data, scenario_time, hr, w2t):
|
||||
f_obj.write(f"{_}\n")
|
||||
w2t("采集的数据时间长度不够,需要确认。", 0, 2, 'red', tab_name)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def main(path, hr, md, w2t):
|
||||
data_dirs, data_files = traversal_files(path, w2t)
|
||||
|
Reference in New Issue
Block a user