This program is for an autonomous robot for the competition at the Hochschule Luzern. http://cruisingcrepe.wordpress.com/ We are one of the 32 teams. http://cruisingcrepe.wordpress.com/ The postition control is based on this Documentation: Control of Wheeled Mobile Robots: An Experimental Overview from Alessandro De Luca, Giuseppe Oriolo, Marilena Vendittelli. For more information see here: http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf

Dependencies:   mbed

Fork of autonomous Robot Android by Christian Burri

Files at this revision

API Documentation at this revision

Comitter:
chrigelburri
Date:
Sun May 19 14:54:49 2013 +0000
Parent:
22:bfec16575c91
Child:
25:e16f96fd7d21
Commit message:
LED lauft :-) cool

Changed in this revision

State/State.cpp Show annotated file Show diff for this revision Revisions of this file
State/State.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/State/State.cpp	Sun May 19 07:35:16 2013 +0000
+++ b/State/State.cpp	Sun May 19 14:54:49 2013 +0000
@@ -141,6 +141,11 @@
     timer.start();
 }
 
+float State::dim( int idx, float f )
+{
+    return (sin(f + float(idx)* 1.0) + 1.0) / 2.0;   // transform value from -1.0 .. 1.0 to 0.0 .. 1.0
+}
+
 void State::run()
 {
     s->millis = timer.read_ms();
--- a/State/State.h	Sun May 19 07:35:16 2013 +0000
+++ b/State/State.h	Sun May 19 14:54:49 2013 +0000
@@ -82,6 +82,14 @@
      * @brief Save the new state to a new line.
      */
     void savePlotFile(state_t s);
+    
+    /**
+    * Returns the transform a  sinusvalue from -1.0 .. 1.0 to 0.0 .. 1.0
+    * @param idx number of LEDS
+    * @param f value till 2π
+    * @return sinus value from 0.0f 1.0f
+    */
+    float dim( int idx, float f );
 
     /**
      * @brief Run method actualize every period.
--- a/main.cpp	Sun May 19 07:35:16 2013 +0000
+++ b/main.cpp	Sun May 19 14:54:49 2013 +0000
@@ -40,6 +40,17 @@
 #include "androidADB.h"
 
 /**
+ * @name LED
+ * @{
+ */
+
+/**
+* @brief The Array of the four LED on the mbed board.
+*/
+PwmOut led[4] = { LED1, LED2, LED3, LED4 };
+/*! @} */
+
+/**
  * @name Hallsensor
  * @{
  */
@@ -127,7 +138,25 @@
     state.start();
     state.initPlotFile();
     state.closePlotFile();
-    while(s.voltageBattery < BAT_MIN) {}
+    while(s.voltageBattery < BAT_MIN) {
+        for (float f = 0.1f; f < 6.3f; f += 0.1f) {
+            for(int i = 0; i <= 3; i  ++) {
+                led[i] = state.dim( i, f );
+            }
+            wait_ms(20);
+        }
+        wait(0.05);
+        for (float f = 0.1f; f < 6.3f; f += 0.1f) {
+            for(int i = 0; i <= 3; i  ++) {
+                led[i] = state.dim( 3-i, f );
+            }
+            wait_ms(20);
+        }
+        wait(0.05);
+    }
+    for(int i = 0; i <= 3; i  ++) {
+        led[i] = state.dim( 0, 0.0f );
+    }
     state.stop();
     wait(0.5);
     state.start();
@@ -241,5 +270,26 @@
     state.closePlotFile();
     state.stop();
     robotControl.setEnable(false);
+    robotControl.stop();
+
+    /**
+    * Fast PWM sample for the end
+    */
+    while(1) {
+        for (float f = 0.1f; f < 6.3f; f += 0.1f) {
+            for(int i = 0; i <= 3; i  ++) {
+                led[i] = state.dim( i, f );
+            }
+            wait_ms(5);
+        }
+        wait(0.1);
+        for (float f = 0.1f; f < 6.3f; f += 0.1f) {
+            for(int i = 0; i <= 3; i  ++) {
+                led[i] = state.dim( 3-i, f );
+            }
+            wait_ms(5);
+        }
+        wait(0.05);
+    }
 
 }