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>
Fork of autonomousRobotAndroid by
Revision 21:48248c5b8992, committed 2013-05-17
- Comitter:
- chrigelburri
- Date:
- Fri May 17 06:39:44 2013 +0000
- Parent:
- 20:01b233b0e606
- Child:
- 22:bfec16575c91
- Commit message:
- vor dem einstellen des gr?nen kaktus :-)
Changed in this revision
--- a/MicroBridge/androidADB.cpp Fri May 03 14:39:24 2013 +0000 +++ b/MicroBridge/androidADB.cpp Fri May 17 06:39:44 2013 +0000 @@ -10,7 +10,7 @@ float androidy; /** @brief Desired position in degrees for theta, given by android */ -float androidt; +float androidt /*= (2 * PI) + 1*/; /** @brief Indicates if a ADB connection to a android phone is established */ boolean androidConnected; @@ -87,6 +87,7 @@ 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); @@ -122,7 +123,7 @@ } } - +//////// Brachts dies noch????????? void write2Android(char str [32]) { connection->write(sizeof(str),(unsigned char*)&str);
--- a/MicroBridge/androidADB.h Fri May 03 14:39:24 2013 +0000 +++ b/MicroBridge/androidADB.h Fri May 17 06:39:44 2013 +0000 @@ -13,27 +13,66 @@ #include <stdlib.h> /** - * @brief Takes an string, a vector of strings for the delimited tokens, and a with the - * @param str - * @param tokens - * @param delimiters - */ +* @brief Takes an string, a vector of strings for the delimited tokens, and a with the +* @param str +* @param tokens +* @param delimiters +*/ void Tokenize(const string& str, vector<string>& tokens, const string& delimiters = " "); - - void parseMessage(uint16_t length, uint8_t * data); - + +/** +* @brief @todo +* @param length +* @param data +*/ +void parseMessage(uint16_t length, uint8_t * data); + +/** +* @brief @todo +* Connecting to android. +*/ void connect(); +/** +* @brief Gets the desired θ value. +* @return the desired θ, given in [°] GRad oder rad?????????????????? +*/ float getDesiredTheta(); + +/** +* @brief Gets the desired X-postition. +* @return the desired X-postition, given in [m] +*/ float getDesiredX(); + +/** +* @brief Gets the desired Y-postition. +* @return the desired Y-postition, given in [m] +*/ float getDesiredY(); +/** +* @brief Initialise the ADB subsystem. Open an ADB stream on tcp port 4568. +*/ void init(); +/** +* @brief @todo +* @param str +*/ void write2Android(char str [32]); +/** +* @brief Write the Parameterlist to the android smartphone. +* @param x +* @param y +* @param t +* @param state_u +* @param state_r +* @param volt_b +*/ void writeActualPosition(float x, float y, float t, int state_u, int state_l, int state_r, float volt_b); #endif \ No newline at end of file
--- a/defines.h Fri May 03 14:39:24 2013 +0000 +++ b/defines.h Fri May 17 06:39:44 2013 +0000 @@ -105,12 +105,12 @@ /** * @brief Speed Factor how set in the ESCON Studio */ -#define ESCON_SET_FACTOR 1500.0f +#define ESCON_SET_FACTOR 2400.0f /** * @brief Speed Factor how get in the ESCON Studio */ -#define ESCON_GET_FACTOR 1600.4f +#define ESCON_GET_FACTOR 2452.4f /** * @brief Error patch of the drift of Analog input and pwn output for set speed
--- a/main.cpp Fri May 03 14:39:24 2013 +0000 +++ b/main.cpp Fri May 17 06:39:44 2013 +0000 @@ -23,9 +23,9 @@ * 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> * - * The connection to an android smartphone is realise with the library AndroidAccessory from Rich Bayliss. - * For more information see here: <a href="https://mbed.org/users/richbayliss/code/AndroidAccessory/docs/tip/">https://mbed.org/users/richbayliss/code/AndroidAccessory/docs/tip/</a> - * + * The connection to an android smartphone is realise with the library MicroBridge(Android ADB) from Junichi Katsu. + * For more information see here: <a href="http://mbed.org/users/jksoft/code/MicroBridge/">http://mbed.org/users/jksoft/code/MicroBridge/</a> + * * The rest of the classes are only based on standard library from mbed. * For more information see here: <a href="http://mbed.org/users/mbed_official/code/mbed/">http://mbed.org/users/mbed_official/code/mbed/</a> */ @@ -38,7 +38,6 @@ #include "State.h" #include "RobotControl.h" #include "androidADB.h" -//#include "android.h" /** * @name Hallsensor @@ -103,11 +102,6 @@ * @{ */ -/** - * @brief <code>adkTerm</code> object is for the communication with a smartphone. - * The operation system must be a android. - */ -//AdkTerm adkTerm(&robotControl, &s, PERIOD_ANDROID); /*! @} */ @@ -143,121 +137,102 @@ robotControl.setAllToZero(0, 0, PI/2 ); //robotControl.setAllToZero(START_X_OFFSET, START_Y_OFFSET, PI/2 ); robotControl.start(); - /* - 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(); - - //wait(3); - - adkTerm.start(); - - */ // Epä Parkour fahrä - /* - robotControl.setDesiredPositionAndAngle(START_X_OFFSET, START_Y_OFFSET, PI/2); - wait(0.1); + /* + robotControl.setDesiredPositionAndAngle(START_X_OFFSET, START_Y_OFFSET, PI/2); + wait(0.1); - robotControl.setDesiredPositionAndAngle(-1.50f, 1.50f, 3*PI/4); - while(!(robotControl.getDistanceError() <= 0.9)) { - state.savePlotFile(s); - }; + robotControl.setDesiredPositionAndAngle(-1.50f, 1.50f, 3*PI/4); + while(!(robotControl.getDistanceError() <= 0.9)) { + state.savePlotFile(s); + }; - robotControl.setDesiredPositionAndAngle(-1.20f, 2.1f, PI/4); - while(!(robotControl.getDistanceError() <= 0.7)) { - state.savePlotFile(s); - }; + robotControl.setDesiredPositionAndAngle(-1.20f, 2.1f, PI/4); + while(!(robotControl.getDistanceError() <= 0.7)) { + state.savePlotFile(s); + }; - robotControl.setDesiredPositionAndAngle(-0.5f, 3.0f, PI/2); //0.75 - while(!(robotControl.getDistanceError() <= 0.7)) { - state.savePlotFile(s); - }; + robotControl.setDesiredPositionAndAngle(-0.5f, 3.0f, PI/2); //0.75 + while(!(robotControl.getDistanceError() <= 0.7)) { + state.savePlotFile(s); + }; - robotControl.setDesiredPositionAndAngle(-1.0f, 3.75f, 3*PI/4); - while(!(robotControl.getDistanceError() <= 0.55)) { - state.savePlotFile(s); - }; + robotControl.setDesiredPositionAndAngle(-1.0f, 3.75f, 3*PI/4); + while(!(robotControl.getDistanceError() <= 0.55)) { + state.savePlotFile(s); + }; - robotControl.setDesiredPositionAndAngle(-1.5f, 3.6f, PI); - while(!(robotControl.getDistanceError() <= 0.05)) { - state.savePlotFile(s); - }; + robotControl.setDesiredPositionAndAngle(-1.5f, 3.6f, PI); + while(!(robotControl.getDistanceError() <= 0.05)) { + state.savePlotFile(s); + }; - robotControl.setDesiredPositionAndAngle(-2.6f, 3.0f, -PI/2); - while(!(robotControl.getDistanceError() <= 1.0)) { - state.savePlotFile(s); - }; - - robotControl.setDesiredPositionAndAngle(-2.0f, 2.0f, -PI/2); - while(!(robotControl.getDistanceError() <= 1.0)) { - state.savePlotFile(s); - }; + robotControl.setDesiredPositionAndAngle(-2.6f, 3.0f, -PI/2); + while(!(robotControl.getDistanceError() <= 1.0)) { + state.savePlotFile(s); + }; - robotControl.setDesiredPositionAndAngle(-2.65f, 1.30f, -PI/2); - while(!(robotControl.getDistanceError() <= 0.4)) { - state.savePlotFile(s); - }; - robotControl.setDesiredPositionAndAngle(-2.65f, 0.80f, -PI/2); - while(!(s.millis >= 32000)) { - state.savePlotFile(s); - } -*/ - - /* - while (1) { - USBLoop(); - - robotControl.setDesiredPositionAndAngle(adkTerm.getDesiredX(), adkTerm.getDesiredY(), adkTerm.getDesiredTheta()); - - //pc.printf("."); + robotControl.setDesiredPositionAndAngle(-2.0f, 2.0f, -PI/2); + while(!(robotControl.getDistanceError() <= 1.0)) { + state.savePlotFile(s); + }; - /*pc.printf("From Android x: %f y: %f t: %f",adkTerm.getDesiredX(), adkTerm.getDesiredY(),adkTerm.getDesiredTheta()); - - - pc.printf( "To Android: x: %f y: %f t: %f; \n \n", robotControl.getxActualPosition(), - robotControl.getyActualPosition(), - robotControl.getActualTheta()); - }*/ + robotControl.setDesiredPositionAndAngle(-2.65f, 1.30f, -PI/2); + while(!(robotControl.getDistanceError() <= 0.4)) { + state.savePlotFile(s); + }; + robotControl.setDesiredPositionAndAngle(-2.65f, 0.80f, -PI/2); + while(!(s.millis >= 32000)) { + state.savePlotFile(s); + } + */ - /** - * Close the File PLOTS.txt to read the file after with the computer and draw a diagramm - */ - - + pc.baud(460800); + pc.printf("********************* MicroBridge 4568 ********************************\n\r"); - pc.printf("********************* MicroBridge 4568 ********************************\n\r"); - init(); - + // Initialise the ADB subsystem. - + pc.printf("connection isOpen\n"); - while(1) { + while(getDesiredTheta() < (4 * PI)) { ADB::poll(); - + + if (getDesiredTheta() > (2 * PI)) { + //robotControl.setAllToZero(0, 0, PI/2 ); + robotControl.setAllToZero(START_X_OFFSET, START_Y_OFFSET, PI/2 ); + robotControl.setDesiredPositionAndAngle(START_X_OFFSET, START_Y_OFFSET, PI/2); + } + else + { robotControl.setDesiredPositionAndAngle(getDesiredX(), getDesiredY(), getDesiredTheta()); - - //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(), s.state&STATE_UNDER, s.state&STATE_LEFT, s.state&STATE_RIGHT, s.voltageBattery); + + 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(), s.state&STATE_UNDER, s.state&STATE_LEFT, s.state&STATE_RIGHT, s.voltageBattery); //connection->write(sizeof(str),(unsigned char*)&str); - wait(1); + + wait(0.25); - } - + } + + + /** + * Close the File PLOTS.txt to read the file with the computer afterwards and draw a diagramm + */ state.savePlotFile(s); state.closePlotFile(); state.stop(); robotControl.setEnable(false); - + }