暂存
fix: 修复task多次开启问题 feat: 新增 891 参数(医院停早,红球靠外) pref: 弃用 action 类
This commit is contained in:
26
action.py
26
action.py
@@ -13,15 +13,19 @@ move = None
|
||||
axis = None
|
||||
cmd = None
|
||||
|
||||
action_run_flag = None
|
||||
|
||||
cfg = toml.load('/home/evan/Workplace/project_main/cfg_action.toml')
|
||||
|
||||
def import_obj(_bycmd):
|
||||
def import_obj(_run_flag,_bycmd):
|
||||
global bycmd
|
||||
global move
|
||||
global axis
|
||||
global cmd
|
||||
global action_run_flag
|
||||
|
||||
bycmd = _bycmd
|
||||
action_run_flag = _run_flag
|
||||
move = move_cls()
|
||||
axis = axis_cls()
|
||||
cmd = cmd_cls()
|
||||
@@ -118,7 +122,7 @@ class cmd_cls():
|
||||
else:
|
||||
time_via = _time_via
|
||||
logger.info(f"z[{self.__axis_z_pos}] speed:{_speed:.2f}, dis:{_dis:.2f}, time_via:{time_via:.2f}")
|
||||
while bycmd.send_position_axis_z(_speed, self.__axis_z_pos) == -1:
|
||||
while bycmd.send_position_axis_z(_speed, self.__axis_z_pos) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(time_via)
|
||||
def z2(self, _speed, _pos, _time_via = -1):
|
||||
@@ -131,7 +135,7 @@ class cmd_cls():
|
||||
else:
|
||||
time_via = _time_via
|
||||
logger.info(f"z[{self.__axis_z_pos}] speed:{_speed:.2f}, pos:{_pos:.2f}, time_via:{time_via:.2f}")
|
||||
while bycmd.send_position_axis_z(_speed, self.__axis_z_pos) == -1:
|
||||
while bycmd.send_position_axis_z(_speed, self.__axis_z_pos) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(time_via)
|
||||
def x(self, _speed, _dis, _time_via = -1):
|
||||
@@ -143,7 +147,7 @@ class cmd_cls():
|
||||
else:
|
||||
time_via = _time_via
|
||||
logger.info(f"x[{self.__axis_x_pos}] speed:{_speed:.2f}, dis:{_dis:.2f}, time_via:{time_via:.2f}")
|
||||
while bycmd.send_position_axis_x(_speed, self.__axis_x_pos) == -1:
|
||||
while bycmd.send_position_axis_x(_speed, self.__axis_x_pos) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(time_via)
|
||||
def x2(self, _speed, _pos, _time_via = -1):
|
||||
@@ -156,30 +160,30 @@ class cmd_cls():
|
||||
else:
|
||||
time_via = _time_via
|
||||
logger.info(f"x[{self.__axis_x_pos}] speed:{_speed:.2f}, pos:{_pos:.2f}, time_via:{time_via:.2f}")
|
||||
while bycmd.send_position_axis_x(_speed, self.__axis_x_pos) == -1:
|
||||
while bycmd.send_position_axis_x(_speed, self.__axis_x_pos) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(time_via)
|
||||
def camera(self, angle):
|
||||
while bycmd.send_angle_camera(angle) == -1:
|
||||
while bycmd.send_angle_camera(angle) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
def claw(self, angle):
|
||||
while bycmd.send_angle_claw(angle) == -1:
|
||||
while bycmd.send_angle_claw(angle) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
def claw_arm(self, angle):
|
||||
while bycmd.send_angle_claw_arm(angle) == -1:
|
||||
while bycmd.send_angle_claw_arm(angle) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(1)
|
||||
def scoop(self, angle):
|
||||
while bycmd.send_angle_scoop(angle) == -1:
|
||||
while bycmd.send_angle_scoop(angle) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
def storage(self, angle):
|
||||
while bycmd.send_angle_storage(angle) == -1:
|
||||
while bycmd.send_angle_storage(angle) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
def zhuan(self, angle):
|
||||
while bycmd.send_angle_zhuan(angle) == -1:
|
||||
while bycmd.send_angle_zhuan(angle) == -1 and action_run_flag.isSet():
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
def wait(self, _time):
|
||||
|
||||
Reference in New Issue
Block a user