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:39:20 2013 +0000
Parent:
22:bfec16575c91
Commit message:
mit anzeige;

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
defines.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:39:20 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:39:20 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/defines.h	Sun May 19 07:35:16 2013 +0000
+++ b/defines.h	Sun May 19 14:39:20 2013 +0000
@@ -47,7 +47,7 @@
 /**
  * @brief Radius of the left wheel, given in [m] kleiner --> weiter
  */
-#define WHEEL_RADIUS_LEFT     0.040190f    //0.040190f             
+#define WHEEL_RADIUS_LEFT     0.040190f         
 
 /**
  * @brief Radius of the left wheel, given in [m]
@@ -131,12 +131,12 @@
 /**
  * @brief Main Gain for k1, k2 and k3
  */
-#define GAIN                  0.65f // 1.8f 0.65
+#define GAIN                  0.65f
 
 /**
  * @brief Gain k1 default 1.0f
  */
-#define K1                    1.45f * GAIN  //0.8 1.2
+#define K1                    1.45f * GAIN
 
 /**
  * @brief Gain k2 default 3.0f
--- a/main.cpp	Sun May 19 07:35:16 2013 +0000
+++ b/main.cpp	Sun May 19 14:39:20 2013 +0000
@@ -108,6 +108,9 @@
 // @todo PC USB communications DAs wird danach gelöscht
 Serial pc(USBTX, USBRX);
 
+PwmOut led[4] = { LED1, LED2, LED3, LED4 };
+
+
 /**
 * @brief Main function. Start the Programm here.
 */
@@ -123,12 +126,31 @@
      * Check at first the Battery voltage. Starts when the voltages greater as the min is.
      * start the timer for the Logging to the file
      * and start the Task for logging
+     *  Slow PWM sample for the end
      **/
     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);
+    }
     state.stop();
+    for(int i = 0; i <= 3; i  ++) {
+        led[i] = state.dim( 0, 0.0f );
+    }
     wait(0.5);
     state.start();
     state.initPlotFile();
@@ -195,9 +217,6 @@
     }
 
 
-
-
-
     /*
         pc.baud(460800);
         pc.printf("********************* MicroBridge 4568 ********************************\n\r");
@@ -241,5 +260,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);
+    }
 
 }