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
Diff: main.cpp
- Revision:
- 2:d8e1613dc38b
- Parent:
- 1:6cd533a712c6
- Child:
- 3:92ba0254af87
diff -r 6cd533a712c6 -r d8e1613dc38b main.cpp --- a/main.cpp Sat Mar 02 09:39:34 2013 +0000 +++ b/main.cpp Sun Mar 03 16:26:47 2013 +0000 @@ -1,12 +1,17 @@ -/* - * main.cpp - * Copyright (c) 2012, Pren Team1 HSLU T&A +/** + * @author Christian Burri + * + * @section LICENSE + * + * Copyright © 2013 HSLU Pren Team #1 Cruising Crêpe * All rights reserved. + * + * @section DESCRIPTION + * + * ????? + * */ -/////////////////////////////////////////////////////////////////////////////////////////////////////// -// INCLUDES -/////////////////////////////////////////////////////////////////////////////////////////////////////// #include "mbed.h" #include "math.h" #include "defines.h" @@ -16,8 +21,6 @@ #include "RobotControl.h" #include "Ping.h" #include "PowerControl/EthernetPowerControl.h" -#include "Android.h" - // LiPo Batterie AnalogIn battery(p15); // Battery check @@ -26,10 +29,6 @@ //HMC5883L compass(p9, p10, PERIOD_COMPASS); // sda, sdl (I2C) //HMC6352 compass(p9, p10, PERIOD_COMPASS); // sda, sdl (I2C) - -// ultrasonic sensor -//Ping ultrasonic(p30); - //Hallsensor //hall1, hall2, hall3 Hallsensor hallLeft(p18, p17, p16); @@ -49,10 +48,6 @@ state_t s; // stuct state State state(&s, &robotControl, &leftMotor, &rightMotor, /*&compass,*/ &battery, PERIOD_STATE); -// Communication - -//Android android(&s, &robotControl, &leftMotor, &rightMotor, PERIOD_ANDROID); - // PC USB communications Serial pc(USBTX, USBRX); @@ -65,7 +60,6 @@ int main() { - pc.printf("blabal"); /** Normal mbed power level for this setup is around 690mW * assuming 5V used on Vin pin * If you don't need networking... @@ -73,42 +67,48 @@ * Also need to unplug network cable - just a cable sucks power */ PHY_PowerDown(); - state.startTimerFromZero(); - state.initPlotFile(); - - // robotControl.start(); + + // robotControl.start(); // compass.setOpMode(HMC6352_CONTINUOUS, 1, 20); // compass.start(); + + state.initPlotFile(); + robotControl.start(); robotControl.setEnable(false); wait(0.01); robotControl.setEnable(true); wait(0.01); robotControl.setAllToZero(0, 0, PI/2 ); + leftMotor.setPulses(0); rightMotor.setPulses(0); + + state.startTimerFromZero(); state.start(); - pc.printf("start"); - - robotControl.setxPosition(-1.0); - robotControl.setyPosition(1.0); - robotControl.setTheta( PI); + + robotControl.setPositionAngle(0.0f, 1.0f, 17*PI/18); while(!(s.millis >= 15000)) { state.savePlotFile(s); - pc.printf("rhho: %f, gamma: %f, delta: %f thetaacutal: %f %f %f atan2: %f\n", robotControl.getDistanceError(), robotControl.getThetaErrorToGoal() * 180/PI, robotControl.getThetaGoal()*180/PI, robotControl.getActualTheta()*180/PI, robotControl.getyPositionError(), robotControl.getxPositionError(), atan2(robotControl.getyPositionError(),robotControl.getxPositionError()) * 180/PI); }; - pc.printf("nextpoint"); - robotControl.setxPosition(-2.0); - robotControl.setyPosition(3.0); - robotControl.setTheta( PI/2 ); + + robotControl.setPositionAngle(-1.0f, 1.0f, -PI/2); while(!(s.millis >= 30000)) { state.savePlotFile(s); - pc.printf("rho: %f, gamma: %f, delta: %f\n", robotControl.getDistanceError(), robotControl.getThetaErrorToGoal() * 180/PI, robotControl.getThetaGoal()*180/PI); + }; + + robotControl.setPositionAngle(-1.0f, 0.0f, 0.0f); + while(!(s.millis >= 45000)) { + state.savePlotFile(s); }; - state.savePlotFile(s); + + robotControl.setPositionAngle(0.0f, 1.0f, PI/2); + while(!(s.millis >= 63000)) { + state.savePlotFile(s); + }; + + state.savePlotFile(s); state.closePlotFile(); state.stop(); robotControl.setEnable(false); - pc.printf("\n"); - }