This program is for an autonomous robot for the competition at the Hochschule Luzern. We are one of the 32 teams. <a href="http://cruisingcrepe.wordpress.com/">http://cruisingcrepe.wordpress.com/</a> 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: <a href="http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf">http://www.dis.uniroma1.it/~labrob/pub/papers/Ramsete01.pdf</a>

Dependencies:   mbed

Fork of autonomousRobotAndroid by Christian Burri

Files at this revision

API Documentation at this revision

Comitter:
chrigelburri
Date:
Mon May 20 17:40:08 2013 +0000
Parent:
31:abfaef28d16d
Child:
33:ac39982fd3b2
Commit message:
unn?tiges Gel?scht;

Changed in this revision

MicroBridge/androidADB.cpp Show annotated file Show diff for this revision Revisions of this file
MicroBridge/androidADB.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/MicroBridge/androidADB.cpp	Mon May 20 17:31:16 2013 +0000
+++ b/MicroBridge/androidADB.cpp	Mon May 20 17:40:08 2013 +0000
@@ -1,6 +1,5 @@
 #include "androidADB.h"
 
-
 Connection * connection;
 
 /** @brief Desired position in meters for x-coordinate, given by android */
@@ -35,7 +34,6 @@
     androidt = t;
 }
 
-
 void Tokenize(const string& str,
               vector<string>& tokens,
               const string& delimiters /*= " "*/)
@@ -60,10 +58,8 @@
 
     if (event == ADB_CONNECTION_OPEN) {
         androidConnected = true;
-        //pc.printf("Android Connected\n");
     } else if (event == ADB_CONNECTION_CLOSE) {
         androidConnected = false;
-        printf("Android Disonnected\n");
     }
 
     if (event == ADB_CONNECTION_RECEIVE) {
@@ -74,8 +70,6 @@
 
 void parseMessage(uint16_t length, uint8_t * data)
 {
-    //received = "[ADB RECV]";    printf("[ADB RECV]:%d   %d\r\n",data[0],data[1]);
-
     char str[32];
 
     // convert buffer (unsigned char) to char
@@ -94,30 +88,22 @@
         androidx = ::atof(tokens.at(0).c_str());
         androidy = ::atof(tokens.at(1).c_str());
         androidt = ::atof(tokens.at(2).c_str());
-       
 
-        printf("Android x(%d): %f\n\r\n",length,androidx);
-        printf("Android y(%d): %f\n\r\n",length,androidy);
-        printf("Android t(%d): %f\n\r\n",length,androidt);
-    } else {
-        //pc.printf("Android sayys(%d): %s\n\r\n",length,str);
-    }
+    } else {}
 
 }
 
 void connect()
 {
     ADB::poll();
-    printf("connecting...");
     char c = 'c';
     connection->write(sizeof(c), (unsigned char*)&c);
-    //wait(0.5);
 }
 
 void init()
 {
 
-// Initialise the ADB subsystem.
+    // Initialise the ADB subsystem.
     ADB::init();
 
     // Open an ADB stream on tcp port 4568. Auto-reconnect
@@ -130,6 +116,7 @@
     }
 
 }
+
 //////// Brachts dies noch?????????
 void write2Android(char str [32])
 {
@@ -145,7 +132,7 @@
     }
 
     char str[100];
-    
+
     //send to android
     sprintf( str, "%f;%f;%f;%i;%i;%i;%f;;", x,
              y,
@@ -157,39 +144,4 @@
 
     connection->write(sizeof(str),(unsigned char*)&str);
 
-}
-
-/*
-int main()
-{
-
-    pc.baud(460800);
-
-    pc.printf("********************* MicroBridge 4568 ********************************\n\r");
-
-
-
-    pc.printf("connection isOpen\n");
-
-    float flt = 0.0;
-    float flt2 = 0.2;
-    float flt3 = 1.2;
-
-    while(1) {
-
-        ADB::poll();
-
-        flt = flt - 0.1;
-        flt2 = flt2 + 0.2;
-        flt3 = flt3 - 0.05;
-
-        char str[32];
-        sprintf( str, "%f;%f;%f;", flt, flt2, flt3);
-
-        pc.printf("Sending: %s\n\r",str);
-        connection->write(sizeof(str),(unsigned char*)&str);
-        wait(1);
-
-    }
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file
--- a/MicroBridge/androidADB.h	Mon May 20 17:31:16 2013 +0000
+++ b/MicroBridge/androidADB.h	Mon May 20 17:40:08 2013 +0000
@@ -37,7 +37,7 @@
 
 /**
 * @brief Gets the desired &theta; value.
-* @return the desired &theta;, given in [°]  GRad oder rad??????????????????
+* @return the desired &theta;, given in [°]
 */
 float getDesiredTheta();
 
--- a/main.cpp	Mon May 20 17:31:16 2013 +0000
+++ b/main.cpp	Mon May 20 17:40:08 2013 +0000
@@ -106,9 +106,6 @@
 
 /*! @} */
 
-// @todo PC USB communications DAs wird danach gelöscht
-Serial pc(USBTX, USBRX);
-
 /**
 * @brief Main function. Start the Programm here.
 */
@@ -116,11 +113,12 @@
 {
 
     /**
-     * Check at first the Battery voltage. Starts when the voltages greater as the min is.
+     * Check at first the Battery voltage. Starts when the voltage is greater than the min is.
      * start the timer for the Logging to the file
      * and start the Task for logging
      **/
     state.start();
+    
     while(s.voltageBattery < BAT_MIN) {
         for (float f = 0.1f; f < 6.3f; f += 0.1f) {
             for(int i = 0; i <= 3; i  ++) {
@@ -155,19 +153,15 @@
     wait(0.1);
     robotControl.setEnable(false);
 
-    // Verbindung zum putty kann spöter gelöscht werden......
-    pc.baud(460800);
-    pc.printf("********************* MicroBridge 4568 ********************************\n\r");
-
     /**
     * Initialise the ADB subsystem.
+    * Set Theta for to go to Startloop.
     */
     init();
     setDesiredTheta(400.0f);
-    pc.printf("connection isOpen\n");
 
     while(getDesiredTheta() < (4 * PI)) {
-        ADB::poll();        
+        ADB::poll();
         if (getDesiredTheta() > (2 * PI)) {
             /**
             * Runs at first till the Startbutton has pressed
@@ -183,9 +177,7 @@
             state.savePlotFile(s);
             wait(PERIOD_ANDROID/2);
             state.savePlotFile(s);
-            //void writeActualPosition(float x, float y, float t, int state_u, int state_l, int state_r, float volt_b)
         }
-
         writeActualPosition(robotControl.getxActualPosition(),
                             robotControl.getyActualPosition(),
                             robotControl.getActualTheta(),
@@ -193,8 +185,6 @@
                             s.state&STATE_LEFT,
                             s.state&STATE_RIGHT,
                             s.voltageBattery);
-        //connection->write(sizeof(str),(unsigned char*)&str);
-
         wait(PERIOD_ANDROID/2);
 
     }
@@ -210,9 +200,6 @@
     state.savePlotFile(s);
     leftMotor.setVelocity(0.0f);
     rightMotor.setVelocity(0.0f);
-  //  while(!(s.millis >= 15000)) {
-  //      state.savePlotFile(s);
-  //  };
 
     /**
      * Close the File PLOTS.txt to read the file with the computer afterwards and draw a diagramm
@@ -242,5 +229,5 @@
         }
         wait(0.05);
     }
-
+    
 }