comparison python/robot.py @ 3:8ed8f30b0568 draft

Update gaits
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 23 Jul 2017 20:23:29 +0200
parents cf2cd5a35d24
children
comparison
equal deleted inserted replaced
2:2f1609829f66 3:8ed8f30b0568
23 return math.sqrt(a ** 2 + b ** 2) 23 return math.sqrt(a ** 2 + b ** 2)
24 24
25 25
26 class Leg: 26 class Leg:
27 # Lengths of leg segments, in mm 27 # Lengths of leg segments, in mm
28 coxa = 36 # between the hip and the knee 28 coxa = 12.3 # between the hip and the knee
29 femur = 39 # between the knee and the ankle 29 femur = 39.0 # between the knee and the ankle
30 tibia = 55 # between the ankle and the foot 30 tibia = 55.0 # between the ankle and the foot
31 base = 21 # from the center of body 31 base = 21.0 # from the center of body
32 32
33 def __init__(self, joints, direction, servos): 33 def __init__(self, joints, direction, servos):
34 self.servos = servos 34 self.servos = servos
35 self.joints = joints 35 self.joints = joints
36 self.x_dir, self.y_dir = direction 36 self.x_dir, self.y_dir = direction
38 self.x = 0 38 self.x = 0
39 self.y = 0 39 self.y = 0
40 self.z = 0 40 self.z = 0
41 41
42 def move_to(self, x, y, z): 42 def move_to(self, x, y, z):
43 print("Moving leg %d, %d to %d, %d, %d" % (self.x_dir, self.y_dir, 43 print("Moving leg %d, %d to %d, %d, %d" %
44 x, y, z)) 44 (self.x_dir, self.y_dir, x, y, z))
45 x += self.home 45 x += self.home
46 y += self.home 46 y += self.home
47 z -= self.tibia 47 z -= self.tibia
48 f = _norm(x, y) - self.coxa 48 f = _norm(x, y) - self.coxa
49 d = _norm(f, z) 49 d = _norm(f, z)