|
|
@ -81,12 +81,17 @@ class Hexapod(Thread):
|
|
|
|
|
|
|
|
|
|
|
|
CMD_TWIST = 'twist'
|
|
|
|
CMD_TWIST = 'twist'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CMD_CALIBRATION = 'calibration'
|
|
|
|
|
|
|
|
CMD_NORMAL = 'normal'
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, in_cmd_queue):
|
|
|
|
def __init__(self, in_cmd_queue):
|
|
|
|
Thread.__init__(self)
|
|
|
|
Thread.__init__(self)
|
|
|
|
|
|
|
|
|
|
|
|
self.cmd_queue = in_cmd_queue
|
|
|
|
self.cmd_queue = in_cmd_queue
|
|
|
|
self.interval = 0.005
|
|
|
|
self.interval = 0.005
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.calibration_mode = False
|
|
|
|
|
|
|
|
|
|
|
|
with open('/home/pi/hexapod/software/raspberry pi/config.json', 'r') as read_file:
|
|
|
|
with open('/home/pi/hexapod/software/raspberry pi/config.json', 'r') as read_file:
|
|
|
|
self.config = json.load(read_file)
|
|
|
|
self.config = json.load(read_file)
|
|
|
|
|
|
|
|
|
|
|
@ -298,6 +303,13 @@ class Hexapod(Thread):
|
|
|
|
|
|
|
|
|
|
|
|
def cmd_handler(self, cmd_string):
|
|
|
|
def cmd_handler(self, cmd_string):
|
|
|
|
data = cmd_string.split(':')[-2]
|
|
|
|
data = cmd_string.split(':')[-2]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data == self.CMD_CALIBRATION:
|
|
|
|
|
|
|
|
self.calibration_mode = True
|
|
|
|
|
|
|
|
elif data == self.CMD_NORMAL:
|
|
|
|
|
|
|
|
self.calibration_mode = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.calibration_mode:
|
|
|
|
self.current_motion = self.cmd_dict.get(data, self.standby_posture)
|
|
|
|
self.current_motion = self.cmd_dict.get(data, self.standby_posture)
|
|
|
|
|
|
|
|
|
|
|
|
self.cmd_queue.task_done()
|
|
|
|
self.cmd_queue.task_done()
|
|
|
@ -313,6 +325,7 @@ class Hexapod(Thread):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.cmd_handler(cmd_string)
|
|
|
|
self.cmd_handler(cmd_string)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.calibration_mode:
|
|
|
|
if self.current_motion['type'] == 'motion':
|
|
|
|
if self.current_motion['type'] == 'motion':
|
|
|
|
self.motion(self.current_motion['coord'])
|
|
|
|
self.motion(self.current_motion['coord'])
|
|
|
|
elif self.current_motion['type'] == 'posture':
|
|
|
|
elif self.current_motion['type'] == 'posture':
|
|
|
|