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

Revision:
12:235e318a414f
Parent:
11:775ebb69d5e1
Child:
13:a7c30ee09bae
--- a/main.cpp	Fri Apr 05 10:58:42 2013 +0000
+++ b/main.cpp	Sun Apr 07 08:31:51 2013 +0000
@@ -33,18 +33,28 @@
 #include "RobotControl.h"
 //#include "android.h"
 
-//Android
+/**
+ * @name Communication
+ * @{
+ */
+
+/**
+ * @brief <code>adkTerm</code> object is for the communication with a smartphone.
+ * The operation system must be a android.
+ */
 //AdkTerm adkTerm;
+/*! @} */
 
 /**
  * @name Hallsensor
  * @{
  */
- 
- /**
- * @brief <code>hallsensorLeft</code> object with pin15, pin17 and pin16
- */
+
+/**
+* @brief <code>hallsensorLeft</code> object with pin15, pin17 and pin16
+*/
 Hallsensor hallLeft(p18, p17, p16);
+
 /**
  * @brief <code>hallsensorLeft</code> object with pin17, pin28 and pin29
  */
@@ -53,20 +63,24 @@
 
 /**
  * @name Motors and Robot Control
- * @{ 
+ * @{
  */
- 
- /**
- * @brief <code>leftMotor</code> object with pin26, pin25, pin24, pin19 and <code>hallsensorLeft</code> object
- */
+
+/**
+* @brief <code>leftMotor</code> object with pin26, pin25, pin24,
+* pin19 and <code>hallsensorLeft</code> object
+*/
 MaxonESCON leftMotor(p26, p25, p24, p19, &hallLeft);
+
 /**
- * @brief <code>rightMotor</code> object with pin23, pin22, pin21, pin20 and <code>hallsensorRight</code> object
+ * @brief <code>rightMotor</code> object with pin23, pin22, pin21,
+ * pin20 and <code>hallsensorRight</code> object
  */
 MaxonESCON rightMotor(p23, p22, p21, p20, &hallRight);
 
 /**
- * @brief <code>robotControl</code> object with <code>leftMotor</code>, <code>rightMotor</code> and the sampling rate for the run method
+ * @brief <code>robotControl</code> object with <code>leftMotor</code>,
+ * <code>rightMotor</code> and the sampling rate for the run method
  */
 RobotControl robotControl(&leftMotor, &rightMotor, PERIOD_ROBOTCONTROL);
 /*! @} */
@@ -75,31 +89,49 @@
  * @name Logging & State
  * @{
  */
- 
- /**
-  * @brief Define the struct for the State and the Logging
-  */
+
+/**
+ * @brief Define the struct for the State and the Logging
+ */
 state_t s;
+
 /**
- * @brief <code>state</code> object with <code>robotControl</code>, <code>rightMotor</code>, <code>leftMotor</code>, <code>battery</code>, and the sampling rate for the run method
+ * @brief <code>state</code> object with <code>robotControl</code>,
+ * <code>rightMotor</code>, <code>leftMotor</code>, <code>battery</code>
+ * and the sampling rate for the run method
  */
 State state(&s, &robotControl, &leftMotor, &rightMotor, p15, PERIOD_STATE);
 /*! @} */
 
-// PC USB communications DAs wird danach gelöscht
+// @todo PC USB communications DAs wird danach gelöscht
 //Serial pc(USBTX, USBRX);
 
+/**
+* @brief Main function. Start the Programm here.
+*/
 int main()
 {
-    
-        state.initPlotFile();
-        state.startTimerFromZero();
-        state.start();
-    
+
+    /**
+     * Initialze the filt PLOTS.txt,
+     * start the timer for the Logging to the file
+     * and start the Task for logging
+     **/
+    state.initPlotFile();
+    state.startTimerFromZero();
+    state.start();
+
+    /**
+     * Clear all Errors of the ESCON Module, with a disabled to enable event
+     */
     robotControl.setEnable(false);
     wait(0.1);
     robotControl.setEnable(true);
     wait(0.1);
+
+    /**
+     * Set the startposition and start the Task for controlling the roboter.
+     */
     robotControl.setAllToZero(0, 0, PI/2 );
 //   robotControl.setAllToZero(START_X_OFFSET, START_Y_OFFSET, PI/2 );
     robotControl.start();
@@ -110,32 +142,32 @@
     // wait(0.1);
 
     //////////////////////////////////////////
-    
-        robotControl.setDesiredPositionAndAngle(0.0f, 1.0f,  PI);
-        while(!(robotControl.getDistanceError() <= 0.1)) {
-            state.savePlotFile(s);
-        };
 
-        robotControl.setDesiredPositionAndAngle(-1.00f, 1.0f,  -PI/2);
-        while(!(robotControl.getDistanceError() <= 0.1)) {
-            state.savePlotFile(s);
-        };
+    robotControl.setDesiredPositionAndAngle(0.0f, 1.0f,  PI);
+    while(!(robotControl.getDistanceError() <= 0.1)) {
+        state.savePlotFile(s);
+    };
+
+    robotControl.setDesiredPositionAndAngle(-1.00f, 1.0f,  -PI/2);
+    while(!(robotControl.getDistanceError() <= 0.1)) {
+        state.savePlotFile(s);
+    };
 
-        robotControl.setDesiredPositionAndAngle(0.0f, -0.8f,  PI/2);
-        while(!(robotControl.getDistanceError() <= 0.05)) {
-            state.savePlotFile(s);
-        };
+    robotControl.setDesiredPositionAndAngle(0.0f, -0.8f,  PI/2);
+    while(!(robotControl.getDistanceError() <= 0.05)) {
+        state.savePlotFile(s);
+    };
 
-        robotControl.setDesiredPositionAndAngle(0.0f, -0.2f,  PI/2);
-        while(!(robotControl.getDistanceError() <= 0.05)) {
-            state.savePlotFile(s);
-        };
+    robotControl.setDesiredPositionAndAngle(0.0f, -0.2f,  PI/2);
+    while(!(robotControl.getDistanceError() <= 0.05)) {
+        state.savePlotFile(s);
+    };
 
-        robotControl.setDesiredPositionAndAngle(0.0, 0.0f,  PI/2);
-        while(!(s.millis >= 32000)) {
-            state.savePlotFile(s);
-        };
-    
+    robotControl.setDesiredPositionAndAngle(0.0, 0.0f,  PI/2);
+    while(!(s.millis >= 32000)) {
+        state.savePlotFile(s);
+    };
+
 
 
 
@@ -261,26 +293,29 @@
 
 
 
-/*
+    /*
 
-    pc.baud(460800);
-    pc.printf("Welcome to adkTerm\n\n\n\n\n\n\r");
-    pc.printf("here we go... \n");
-    adkTerm.setupDevice();
-    pc.printf("Android Development Kit: start\r\n");
-    USBInit();
-    while (1) {
-        USBLoop();
-        
-        pc.printf("Android x: %f ",adkTerm.getx());
-        pc.printf("Android y: %f ",adkTerm.gety());
-        pc.printf("Android t: %f\n",adkTerm.gett());
-        robotControl.setDesiredPositionAndAngle(adkTerm.getx(), adkTerm.gety(),  adkTerm.gett());
-    }
+        pc.baud(460800);
+        pc.printf("Welcome to adkTerm\n\n\n\n\n\n\r");
+        pc.printf("here we go... \n");
+        adkTerm.setupDevice();
+        pc.printf("Android Development Kit: start\r\n");
+        USBInit();
+        while (1) {
+            USBLoop();
+
+            pc.printf("Android x: %f ",adkTerm.getx());
+            pc.printf("Android y: %f ",adkTerm.gety());
+            pc.printf("Android t: %f\n",adkTerm.gett());
+            robotControl.setDesiredPositionAndAngle(adkTerm.getx(), adkTerm.gety(),  adkTerm.gett());
+        }
 
 
 
-
+    /**
+     * Close the File PLOTS.txt to read the file after with the computer and draw a diagramm
+     */
+     /*
     state.savePlotFile(s);
     state.closePlotFile();
     state.stop();