changeset 157:3114416ffaa3

small fixes in joy
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sat, 11 Oct 2014 18:21:50 +0200
parents 61e00a8f9255
children 132c727c0e26
files joy.py kubik.py
diffstat 2 files changed, 8 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/joy.py	Thu Aug 07 18:05:04 2014 +0200
+++ b/joy.py	Sat Oct 11 18:21:50 2014 +0200
@@ -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,27 +36,19 @@
                         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
 
 
--- a/kubik.py	Thu Aug 07 18:05:04 2014 +0200
+++ b/kubik.py	Sat Oct 11 18:21:50 2014 +0200
@@ -31,10 +31,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):