Mercurial > Kubik
changeset 159:132c727c0e26
merge
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Thu, 25 Dec 2014 19:45:20 +0100 |
| parents | e33e8a3c322a (current diff) 3114416ffaa3 (diff) |
| children | 80eee0d0ca74 |
| files | kubik.py |
| diffstat | 2 files changed, 13 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/joy.py Thu Dec 25 19:44:53 2014 +0100 +++ b/joy.py Thu Dec 25 19:45:20 2014 +0100 @@ -21,7 +21,9 @@ def joy_anim(self): """This animation is for reading user input.""" + dz = 0 while True: + self.robot.shift[2] = max(-12, min(12, self.robot.shift[2] + dz)) for event in pygame.event.get(): if event.type == pygame.QUIT: raise SystemExit() @@ -34,34 +36,26 @@ else: self.gait = 'rotate_right' elif event.button == 0: - serial = self.robot.legs[0].hip.serial - serial.write('0xfd') - sensor = ord(serial.read(1)) - print "Sensor value: %d" % sensor - else: print "Button %d" % event.button elif event.type == pygame.JOYBUTTONUP: if event.button in (10, 11): self.gait = '' elif event.type == pygame.JOYAXISMOTION: if event.axis == 0: - self.speed[0] = event.value - self.rotation = 0.0 + self.speed[0] = -event.value elif event.axis == 1: - self.speed[1] = -event.value - self.rotation = 0.0 + self.speed[1] = event.value elif event.axis == 2: - self.robot.shift[2] = event.value * 12 + dz = event.value elif event.axis == 3: self.rotation = event.value - self.speed = [0.0, 0.0] yield if __name__ == '__main__': # Initialize PyGame. - os.environ['SLD_VIDEODRIVER'] = 'dummy' + os.environ['SDL_VIDEODRIVER'] = 'dummy' pygame.display.init() pygame.joystick.init() for joy in range(pygame.joystick.get_count()):
--- a/kubik.py Thu Dec 25 19:44:53 2014 +0100 +++ b/kubik.py Thu Dec 25 19:45:20 2014 +0100 @@ -28,10 +28,10 @@ class Leg(leg.Leg): # Lengths of leg segments, in mm - coxa = 16.0 # between the hip and the knee + coxa = 16.7 # between the hip and the knee femur = 50.0 # between the knee and the ankle - tibia = 70.0 # between the ankle and the foot - base = 45.0, 45.0 # from the center of body + tibia = 62.5 # between the ankle and the foot + base = 47.6, 47.6 # from the center of body class Robot(robot.Robot): @@ -44,19 +44,19 @@ Leg(HipServo(m, 1, reverse=False, trim=0), KneeServo(m, 2, reverse=True, trim=0), AnkleServo1(m, 0, reverse=True, trim=0, center=1500 * 4), - (-1, -1)), + (1, -1)), Leg(HipServo(m, 4, reverse=False, trim=0), KneeServo(m, 5, reverse=False, trim=0), AnkleServo2(m, 3, reverse=False, trim=0, center=1500 * 4), - (-1, 1)), + (1, 1)), Leg(HipServo(m, 7, reverse=True, trim=0), KneeServo(m, 8, reverse=True, trim=0), AnkleServo1(m, 6, reverse=True, trim=0, center=1500 * 4), - (1, 1)), + (-1, 1)), Leg(HipServo(m, 10, reverse=True, trim=0), KneeServo(m, 11, reverse=False, trim=0), AnkleServo2(m, 9, reverse=False, trim=0, center=1500 * 4), - (1, -1)), + (-1, -1)), ) if __name__ == "__main__":
