changeset 50:6f765bd70359

Folding up
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Fri, 22 Aug 2014 10:08:53 +0200
parents 6ec1356c03ae
children c3c959e09dc8
files fold.py servo/servo.ino
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fold.py	Fri Aug 22 10:08:53 2014 +0200
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import serial
+import kubik
+
+
+robot = kubik.Robot(serial.Serial('/dev/rfcomm0', 9600))
+for leg in robot.legs:
+    leg.hip.move_degrees(45 * leg.y_dir)
+    leg.knee.move_degrees(-90)
+    leg.ankle.move_degrees(90)
+    for joint in leg:
+        joint.update()
--- a/servo/servo.ino	Thu Aug 21 20:58:00 2014 +0200
+++ b/servo/servo.ino	Fri Aug 22 10:08:53 2014 +0200
@@ -1,8 +1,5 @@
 /*
-A very simple servo controller code. There is only one command, 0xff, followed
-by the number of servo (from 0 to 11) and the position to set it to, in degrees
-(from 0 to 180). The commands are received on the serial line as bytes, with
-speed 115200.
+A very simple servo controller code.
 */
 
 #include <Servo.h>
@@ -30,8 +27,9 @@
 }
 
 void loop() {
-    while (!(command = Serial.read()) & 0x80) {
-        /* Just keep trying. */
+    if (!(command = Serial.read()) & 0x80) {
+        /* Synchronize to the beginning of the command. */
+        return;
     };
     switch (command) {
         case 0xff: