changeset 10:31340f7510b8

Add rotation to the arduino creeping.
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sat, 13 Sep 2014 13:10:50 +0200
parents 1bb40d59867c
children e934ad2bdc17
files katka/katka.ino
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/katka/katka.ino	Sat Sep 13 13:01:44 2014 +0200
+++ b/katka/katka.ino	Sat Sep 13 13:10:50 2014 +0200
@@ -53,6 +53,7 @@
 // Creep gain variables.
 double creep_tilt = 0.0;
 double creep_speed = 1.0;
+double creep_rotation = 0.0;
 bool creep_on_ground[4] = {true, true, true, true};
 char creep_current = 0;
 const char CREEP_ORDER[4] = {3, 0, 2, 1};
@@ -141,7 +142,8 @@
 void creep_frame() {
     for (char leg =0; leg < 4; ++leg) {
         if (creep_on_ground[leg]) {
-            move_leg(leg, legs_x[leg] - creep_speed,
+            move_leg(leg,
+                     legs_x[leg] - creep_speed + creep_rotation * LEGS[leg][2],
                      HOME_Y - 8 + creep_tilt * LEGS[leg][3]);
         }
     }
@@ -166,7 +168,10 @@
     move_leg_by(leg, 20, -20);
     creep_frame();
     creep_frame();
-    move_leg(leg, (HOME_X - 10) * LEGS[leg][2] + 25, legs_y[leg]);
+    move_leg(leg,
+             (HOME_X - 10) * LEGS[leg][2] +
+             (25 * creep_speed + creep_rotation * LEGS[leg][2]),
+             legs_y[leg]);
     creep_frame();
     creep_frame();
     move_leg_by(leg, 0, 20);