|
|
@ -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,7 +303,14 @@ 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]
|
|
|
|
self.current_motion = self.cmd_dict.get(data, self.standby_posture)
|
|
|
|
|
|
|
|
|
|
|
|
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.cmd_queue.task_done()
|
|
|
|
self.cmd_queue.task_done()
|
|
|
|
|
|
|
|
|
|
|
@ -313,10 +325,11 @@ class Hexapod(Thread):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.cmd_handler(cmd_string)
|
|
|
|
self.cmd_handler(cmd_string)
|
|
|
|
|
|
|
|
|
|
|
|
if self.current_motion['type'] == 'motion':
|
|
|
|
if not self.calibration_mode:
|
|
|
|
self.motion(self.current_motion['coord'])
|
|
|
|
if self.current_motion['type'] == 'motion':
|
|
|
|
elif self.current_motion['type'] == 'posture':
|
|
|
|
self.motion(self.current_motion['coord'])
|
|
|
|
self.posture(self.current_motion['coord'])
|
|
|
|
elif self.current_motion['type'] == 'posture':
|
|
|
|
|
|
|
|
self.posture(self.current_motion['coord'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|