优化了制动和电机电流自动测试代码
This commit is contained in:
@@ -121,9 +121,14 @@ def gen_result_file(path, number, start_time, end_time, scenario_time):
|
||||
p.start()
|
||||
|
||||
|
||||
def change_curve_state(hr, stat_1, stat_2):
|
||||
display_pdo_params = [{"name": name, "channel": chl} for name in ["hw_joint_vel_feedback", "device_servo_trq_feedback", "hw_sensor_trq_feedback"] for chl in range(6)]
|
||||
hr.execution("diagnosis.open", open=stat_1, display_open=stat_2, overrun=True, turn_area=True, delay_motion=False)
|
||||
hr.execution("diagnosis.set_params", display_pdo_params=display_pdo_params, frequency=50, version="1.4.1")
|
||||
|
||||
|
||||
def run_rl(path, prj_file, hr, md, sub, w2t):
|
||||
prj_name = prj_file.split("/")[-1].split(".")[0]
|
||||
display_pdo_params = [{"name": name, "channel": chl} for name in ["hw_joint_vel_feedback", "device_servo_trq_feedback", "hw_sensor_trq_feedback"] for chl in range(6)]
|
||||
c_regular = [
|
||||
"scenario(0, j1_p, j1_n, p_speed, p_tool, i_tool)",
|
||||
"scenario(0, j2_p, j2_n, p_speed, p_tool, i_tool)",
|
||||
@@ -155,8 +160,6 @@ def run_rl(path, prj_file, hr, md, sub, w2t):
|
||||
conditions, disc = c_inertia, disc_inertia
|
||||
|
||||
# 打开诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来
|
||||
hr.execution("diagnosis.open", open=True, display_open=True, overrun=True, turn_area=True, delay_motion=False)
|
||||
hr.execution("diagnosis.set_params", display_pdo_params=display_pdo_params, frequency=50, version="1.4.1")
|
||||
md.r_soft_estop(0)
|
||||
md.r_soft_estop(1)
|
||||
md.r_clear_alarm()
|
||||
@@ -200,6 +203,7 @@ def run_rl(path, prj_file, hr, md, sub, w2t):
|
||||
|
||||
# 4. 执行采集
|
||||
time.sleep(10) # 消除前 10s 的不稳定数据
|
||||
change_curve_state(hr, True, True)
|
||||
start_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
single_time, stall_time, scenario_time = 40, 10, 0
|
||||
if number < 6: # 单轴
|
||||
@@ -222,15 +226,14 @@ def run_rl(path, prj_file, hr, md, sub, w2t):
|
||||
# 5.停止程序运行,保留数据并处理输出
|
||||
end_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
hr.execution("rl_task.stop", tasks=["current"])
|
||||
time.sleep(5) # 确保数据都拿到
|
||||
time.sleep(2) # 确保数据都拿到
|
||||
change_curve_state(hr, False, False)
|
||||
gen_result_file(path, number, start_time, end_time, scenario_time)
|
||||
else:
|
||||
if sub == "tool100":
|
||||
w2t("单轴和场景电机电流采集完毕,如需采集惯量负载,须切换负载类型,并更换惯量负载,重新执行。\n", "green")
|
||||
elif sub == "inertia":
|
||||
w2t("惯量负载电机电流采集完毕,如需采集单轴/场景/保持电机电流,须切换负载类型,并更换偏置负载,重新执行。\n", "green")
|
||||
hr.execution("diagnosis.open", open=False, display_open=False, overrun=True, turn_area=True, delay_motion=False)
|
||||
hr.execution("diagnosis.set_params", display_pdo_params=[], frequency=50, version="1.4.1")
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user