|
|
|
@ -4,8 +4,8 @@ from queue import Queue |
|
|
|
from ETController import send_Point, sendCMD, wait_stop |
|
|
|
from gpio import turn_off_relay, turn_on_relay |
|
|
|
# from program_config import ( |
|
|
|
# PRESET_PARAMS, turn_off_relay_end, turn_off_relay_start, |
|
|
|
# turn_on_relay_end, turn_on_relay_start |
|
|
|
# PRESET_PARAMS, turn_off_relay_start, |
|
|
|
# turn_on_relay_start |
|
|
|
# ) |
|
|
|
from serial_init import SerialSharedData |
|
|
|
from trajectory_data import ( |
|
|
|
@ -60,7 +60,7 @@ Interpolation_points = 20 |
|
|
|
# 第九段程序封装为函数 |
|
|
|
# 第十二段程序封装为函数 |
|
|
|
|
|
|
|
def program1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program1(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
turn_off_relay() |
|
|
|
@ -115,7 +115,7 @@ def program1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第一段程序执行完") |
|
|
|
|
|
|
|
def program1_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program1_1(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第1_1段程序开始执行") |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -181,7 +181,7 @@ def program1_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_star |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第1_1段程序执行完") |
|
|
|
|
|
|
|
def program2(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program2(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
global increments_x, increments_y, increments_z |
|
|
|
global Coordinate_compensation |
|
|
|
global sample_time |
|
|
|
@ -227,19 +227,19 @@ def program2(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
send_Point(sock, "tt_put_servo_joint_to_buf", {"targetPose": modified_list}) |
|
|
|
time.sleep(sleep_time) |
|
|
|
|
|
|
|
if(i >= turn_on_relay_start and i <= turn_on_relay_end): |
|
|
|
if(i >= turn_on_relay_start): |
|
|
|
turn_on_relay() |
|
|
|
print(f"打开喷枪2:{turn_on_relay_start} ~ {turn_on_relay_end}") |
|
|
|
if(i >= turn_off_relay_start and i <= turn_off_relay_end): |
|
|
|
print(f"打开喷枪2:{turn_on_relay_start}") |
|
|
|
if(i >= turn_off_relay_start): |
|
|
|
turn_off_relay() |
|
|
|
print(f"关闭喷枪2:{turn_off_relay_start} ~ {turn_off_relay_end}") |
|
|
|
print(f"关闭喷枪2:{turn_off_relay_start}") |
|
|
|
i = i + 1 |
|
|
|
|
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第二段程序执行完") |
|
|
|
|
|
|
|
|
|
|
|
def program3(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program3(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第三段程序开始执行") |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -293,7 +293,7 @@ def program3(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第三段程序执行完") |
|
|
|
|
|
|
|
def program3_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program3_1(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第3_1段程序开始执行") |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -359,7 +359,7 @@ def program3_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_star |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第3_1段程序执行完") |
|
|
|
|
|
|
|
def program4(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program4(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第四段程序开始执行") |
|
|
|
global increments_x, increments_y, increments_z |
|
|
|
global Coordinate_compensation |
|
|
|
@ -402,19 +402,19 @@ def program4(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
"lookahead": lookahead_time, "t": sample_time, "smoothness": 1, "response_enable": 0}) |
|
|
|
send_Point(sock, "tt_put_servo_joint_to_buf", {"targetPose": modified_list}) |
|
|
|
time.sleep(sleep_time) |
|
|
|
if(i >= ex_turn_on_relay_start and i <= ex_turn_on_relay_end): |
|
|
|
if(i >= ex_turn_on_relay_start): |
|
|
|
turn_on_relay() |
|
|
|
print(f"打开喷枪4:{ex_turn_on_relay_start} ~ {ex_turn_on_relay_end}") |
|
|
|
if(i >= ex_turn_off_relay_start and i <= ex_turn_off_relay_end): |
|
|
|
print(f"打开喷枪4:{ex_turn_on_relay_start}") |
|
|
|
if(i >= ex_turn_off_relay_start): |
|
|
|
turn_off_relay() |
|
|
|
print(f"关闭喷枪4:{ex_turn_off_relay_start} ~ {ex_turn_off_relay_end}") |
|
|
|
print(f"关闭喷枪4:{ex_turn_off_relay_start}") |
|
|
|
i = i + 1 |
|
|
|
|
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第四段程序执行完") |
|
|
|
|
|
|
|
|
|
|
|
def program5(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program5(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第五段程序开始执行") |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -470,7 +470,7 @@ def program5(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第五段程序执行完") |
|
|
|
|
|
|
|
def program5_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program5_1(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第5_1段程序开始执行") |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -536,7 +536,7 @@ def program5_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_star |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第5_1段程序执行完") |
|
|
|
|
|
|
|
def program6(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program6(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
global increments_x, increments_y, increments_z |
|
|
|
global Coordinate_compensation |
|
|
|
global sample_time |
|
|
|
@ -577,18 +577,18 @@ def program6(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
"lookahead": lookahead_time, "t": sample_time, "smoothness": 1, "response_enable": 0}) |
|
|
|
send_Point(sock, "tt_put_servo_joint_to_buf", {"targetPose": modified_list}) |
|
|
|
time.sleep(sleep_time) |
|
|
|
if(i >= turn_on_relay_start and i <= turn_on_relay_end): |
|
|
|
if(i >= turn_on_relay_start): |
|
|
|
turn_on_relay() |
|
|
|
print(f"打开喷枪6:{turn_on_relay_start} ~ {turn_on_relay_end}") |
|
|
|
if(i >= turn_off_relay_start and i <= turn_off_relay_end): |
|
|
|
print(f"打开喷枪6:{turn_on_relay_start}") |
|
|
|
if(i >= turn_off_relay_start): |
|
|
|
turn_off_relay() |
|
|
|
print(f"关闭喷枪6:{turn_off_relay_start} ~ {turn_off_relay_end}") |
|
|
|
print(f"关闭喷枪6:{turn_off_relay_start}") |
|
|
|
i = i + 1 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第六段程序执行完") |
|
|
|
|
|
|
|
|
|
|
|
def program7(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program7(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
turn_off_relay() |
|
|
|
@ -642,7 +642,7 @@ def program7(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第七段程序执行完") |
|
|
|
|
|
|
|
def program7_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program7_1(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
print("第7_1段程序开始执行") |
|
|
|
i = 0 |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -706,7 +706,7 @@ def program7_1(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_star |
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
print("第7_1段程序执行完") |
|
|
|
|
|
|
|
def program8(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, turn_off_relay_end, ex_turn_on_relay_start, ex_turn_on_relay_end, ex_turn_off_relay_start, ex_turn_off_relay_end): |
|
|
|
def program8(sock, turn_on_relay_start, turn_off_relay_start, ex_turn_on_relay_start, ex_turn_off_relay_start): |
|
|
|
global increments_x, increments_y, increments_z |
|
|
|
global Coordinate_compensation |
|
|
|
global sample_time |
|
|
|
@ -749,12 +749,12 @@ def program8(sock, turn_on_relay_start, turn_on_relay_end, turn_off_relay_start, |
|
|
|
"lookahead": lookahead_time, "t": sample_time, "smoothness": 1, "response_enable": 0}) |
|
|
|
send_Point(sock, "tt_put_servo_joint_to_buf", {"targetPose": modified_list}) |
|
|
|
time.sleep(sleep_time) |
|
|
|
if(i >= ex_turn_on_relay_start and i <= ex_turn_on_relay_end): |
|
|
|
if(i >= ex_turn_on_relay_start): |
|
|
|
turn_on_relay() |
|
|
|
print(f"打开喷枪8:{ex_turn_on_relay_start} ~ {ex_turn_on_relay_end}") |
|
|
|
if(i >= ex_turn_off_relay_start and i <= ex_turn_off_relay_end): |
|
|
|
print(f"打开喷枪8:{ex_turn_on_relay_start}") |
|
|
|
if(i >= ex_turn_off_relay_start): |
|
|
|
turn_off_relay() |
|
|
|
print(f"关闭喷枪8:{ex_turn_off_relay_start} ~ {ex_turn_off_relay_end}") |
|
|
|
print(f"关闭喷枪8:{ex_turn_off_relay_start}") |
|
|
|
i = i + 1 |
|
|
|
|
|
|
|
suc, result, id = sendCMD(sock, "tt_clear_servo_joint_buf") |
|
|
|
@ -1033,10 +1033,11 @@ def program100(sock, ser, stop_cmd_bytes, turn_on_relay_start, turn_off_relay_st |
|
|
|
# 第2道开枪时间在第15个点位(Pose_4_M的开枪点位 lookahead_time/sample_time+15),,关枪时间在第150点位示例(lookahead_time/sample_time+135,,,,如果数据>155,那么关枪就在Pose_4_3_M中) |
|
|
|
#队列,延时时间计算 |
|
|
|
off_set_Time=int(lookahead_time / sample_time) |
|
|
|
off_set_Time=0 |
|
|
|
# 1.喷枪1开关时间计算 |
|
|
|
OPEN_1=turn_on_relay_start |
|
|
|
CLOSE_1=turn_off_relay_start |
|
|
|
OPEN_1_M = off_set_Time+5 |
|
|
|
OPEN_1_M = off_set_Time+OPEN_1 |
|
|
|
CLOSE_1_M1S=off_set_Time+CLOSE_1 |
|
|
|
CLOSE_1_M1E = off_set_Time + CLOSE_1-155 |
|
|
|
#2.喷枪2开关时间计算 |
|
|
|
@ -1086,14 +1087,15 @@ def program100(sock, ser, stop_cmd_bytes, turn_on_relay_start, turn_off_relay_st |
|
|
|
for point in traj: |
|
|
|
send_Point(sock, "tt_put_servo_joint_to_buf", {"targetPose": point}) |
|
|
|
time.sleep(sleep_time) |
|
|
|
if stop_cmd_bytes is not None and stop_cmd_bytes == b'\xAA\x30': |
|
|
|
print("收到0xAA 0x30,停止循环") |
|
|
|
for i in range(3): |
|
|
|
ser.write(b'\x80\x80') |
|
|
|
ser.flush() |
|
|
|
time.sleep(0.01) |
|
|
|
time.sleep(0.5) |
|
|
|
return False |
|
|
|
print(f"停止轨迹,NUM = {NUM}, delay = {delay}") |
|
|
|
# if stop_cmd_bytes is not None and stop_cmd_bytes == b'\xAA\x30': |
|
|
|
# print("收到0xAA 0x30,停止循环") |
|
|
|
# for i in range(3): |
|
|
|
# ser.write(b'\x80\x80') |
|
|
|
# ser.flush() |
|
|
|
# time.sleep(0.01) |
|
|
|
# time.sleep(0.5) |
|
|
|
# return False |
|
|
|
print("轨迹执行完成") |
|
|
|
|
|
|
|
return False |
|
|
|
|