increase limitation

master
Zhengyu Peng 3 years ago
parent 5c26cd09ca
commit 9a2aa191ae

@ -88,10 +88,12 @@ class Hexapod:
self.standby() self.standby()
time.sleep(0.1) time.sleep(0.1)
full_path = forward_path() # self.leg_0.set_angle(1, 45)
for mm in range(0, 30): # full_path = forward_path()
self.move(full_path, 0.005)
# for mm in range(0, 30):
# self.move(full_path, 0.005)
full_path = backward_path() full_path = backward_path()
@ -104,11 +106,13 @@ class Hexapod:
angles = self.inverse_kinematics(dest) angles = self.inverse_kinematics(dest)
self.leg_0.move_junctions(angles[0, :]) self.leg_0.move_junctions(angles[0, :])
self.leg_5.move_junctions(angles[5, :])
self.leg_1.move_junctions(angles[1, :]) self.leg_1.move_junctions(angles[1, :])
self.leg_4.move_junctions(angles[4, :])
self.leg_2.move_junctions(angles[2, :]) self.leg_2.move_junctions(angles[2, :])
self.leg_3.move_junctions(angles[3, :]) self.leg_3.move_junctions(angles[3, :])
self.leg_4.move_junctions(angles[4, :])
self.leg_5.move_junctions(angles[5, :])
time.sleep(interval) time.sleep(interval)

@ -1,20 +1,23 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
class Leg: class Leg:
def __init__(self, def __init__(self,
id, id,
junction_servos, junction_servos,
correction=[0, 0, 0], correction=[0, 0, 0],
constraint=[[45, 135], [45, 165], [30, 150]]): constraint=[[35, 145], [30, 165], [30, 150]]):
self.id = id self.id = id
self.junction_servos = junction_servos self.junction_servos = junction_servos
self.correction = correction self.correction = correction
self.constraint = constraint self.constraint = constraint
def set_angle(self, junction, angle): def set_angle(self, junction, angle):
set_angle = min( set_angle = np.min(
angle+self.correction[junction], self.constraint[junction][1]) [angle+self.correction[junction], self.constraint[junction][1]+self.correction[junction], 180])
set_angle = max(set_angle, self.constraint[junction][0]) set_angle = np.max(
[set_angle, self.constraint[junction][0]+self.correction[junction], 0])
self.junction_servos[junction].angle = set_angle self.junction_servos[junction].angle = set_angle
def move_junctions(self, angles): def move_junctions(self, angles):

Loading…
Cancel
Save