|
|
@ -8,42 +8,47 @@ from adafruit_servokit import ServoKit
|
|
|
|
from leg import Leg
|
|
|
|
from leg import Leg
|
|
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Hexapod:
|
|
|
|
class Hexapod:
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open('./config.json', 'r') as read_file:
|
|
|
|
|
|
|
|
self.config = json.load(read_file)
|
|
|
|
|
|
|
|
|
|
|
|
# Objects
|
|
|
|
# Objects
|
|
|
|
self.pca_right = ServoKit(channels=16, address=0x40, frequency=120)
|
|
|
|
self.pca_right = ServoKit(channels=16, address=0x40, frequency=120)
|
|
|
|
self.pca_left = ServoKit(channels=16, address=0x41, frequency=120)
|
|
|
|
self.pca_left = ServoKit(channels=16, address=0x41, frequency=120)
|
|
|
|
|
|
|
|
|
|
|
|
# rear right
|
|
|
|
# front right
|
|
|
|
self.leg_0 = Leg('rr',
|
|
|
|
self.leg_0 = Leg(0,
|
|
|
|
[self.pca_left.servo[15], self.pca_left.servo[2],
|
|
|
|
[self.pca_left.servo[15], self.pca_left.servo[2],
|
|
|
|
self.pca_left.servo[1]],
|
|
|
|
self.pca_left.servo[1]],
|
|
|
|
correction=[-6, 4, -6])
|
|
|
|
correction=[-6, 4, -6])
|
|
|
|
# center right
|
|
|
|
# center right
|
|
|
|
self.leg_1 = Leg('cr',
|
|
|
|
self.leg_1 = Leg(1,
|
|
|
|
[self.pca_left.servo[7], self.pca_left.servo[8],
|
|
|
|
[self.pca_left.servo[7], self.pca_left.servo[8],
|
|
|
|
self.pca_left.servo[6]],
|
|
|
|
self.pca_left.servo[6]],
|
|
|
|
correction=[3, -5, -6])
|
|
|
|
correction=[3, -5, -6])
|
|
|
|
# front right
|
|
|
|
# rear right
|
|
|
|
self.leg_2 = Leg('fr',
|
|
|
|
self.leg_2 = Leg(2,
|
|
|
|
[self.pca_left.servo[0], self.pca_left.servo[14],
|
|
|
|
[self.pca_left.servo[0], self.pca_left.servo[14],
|
|
|
|
self.pca_left.servo[13]],
|
|
|
|
self.pca_left.servo[13]],
|
|
|
|
correction=[3, -6, -5])
|
|
|
|
correction=[3, -6, -5])
|
|
|
|
# front left
|
|
|
|
# rear left
|
|
|
|
self.leg_3 = Leg('fl',
|
|
|
|
self.leg_3 = Leg(3,
|
|
|
|
[self.pca_right.servo[15], self.pca_right.servo[1],
|
|
|
|
[self.pca_right.servo[15], self.pca_right.servo[1],
|
|
|
|
self.pca_right.servo[2]],
|
|
|
|
self.pca_right.servo[2]],
|
|
|
|
correction=[-3, -4, 6])
|
|
|
|
correction=[-3, -4, 6])
|
|
|
|
# center left
|
|
|
|
# center left
|
|
|
|
self.leg_4 = Leg('cl',
|
|
|
|
self.leg_4 = Leg(4,
|
|
|
|
[self.pca_right.servo[7], self.pca_right.servo[6],
|
|
|
|
[self.pca_right.servo[7], self.pca_right.servo[6],
|
|
|
|
self.pca_right.servo[8]],
|
|
|
|
self.pca_right.servo[8]],
|
|
|
|
correction=[-6, 2, 0])
|
|
|
|
correction=[-6, 2, 0])
|
|
|
|
# rear left
|
|
|
|
# front left
|
|
|
|
self.leg_5 = Leg('rl',
|
|
|
|
self.leg_5 = Leg(5,
|
|
|
|
[self.pca_right.servo[0], self.pca_right.servo[13],
|
|
|
|
[self.pca_right.servo[0], self.pca_right.servo[13],
|
|
|
|
self.pca_right.servo[14]],
|
|
|
|
self.pca_right.servo[14]],
|
|
|
|
correction=[-6, 4, 0])
|
|
|
|
correction=[-6, 4, 0])
|
|
|
@ -56,7 +61,6 @@ class Hexapod:
|
|
|
|
self.leg_5.reset()
|
|
|
|
self.leg_5.reset()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
|
|
hexapod = Hexapod()
|
|
|
|
hexapod = Hexapod()
|
|
|
|