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

Committer:
chrigelburri
Date:
Thu Mar 07 09:47:07 2013 +0000
Revision:
3:92ba0254af87
Parent:
2:d8e1613dc38b
Child:
6:48eeb41188dd
bitte kommentare korriegieren;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chrigelburri 0:31f7be68e52d 1 #ifndef _STATE_H_
chrigelburri 0:31f7be68e52d 2 #define _STATE_H_
chrigelburri 0:31f7be68e52d 3
chrigelburri 0:31f7be68e52d 4 #include <cmath>
chrigelburri 0:31f7be68e52d 5 #include "mbed.h"
chrigelburri 0:31f7be68e52d 6 #include "MaxonESCON.h"
chrigelburri 0:31f7be68e52d 7 #include "RobotControl.h"
chrigelburri 0:31f7be68e52d 8 #include "Task.h"
chrigelburri 0:31f7be68e52d 9 #include "HMC5883L.h"
chrigelburri 0:31f7be68e52d 10 #include "HMC6352.h"
chrigelburri 0:31f7be68e52d 11 #include "defines.h"
chrigelburri 0:31f7be68e52d 12
chrigelburri 0:31f7be68e52d 13 /**
chrigelburri 0:31f7be68e52d 14 * @author Christian Burri
chrigelburri 0:31f7be68e52d 15 *
chrigelburri 0:31f7be68e52d 16 * @section LICENSE
chrigelburri 0:31f7be68e52d 17 *
chrigelburri 1:6cd533a712c6 18 * Copyright &copy; 2013 HSLU Pren Team #1 Cruising Crêpe
chrigelburri 0:31f7be68e52d 19 * All rights reserved.
chrigelburri 0:31f7be68e52d 20 *
chrigelburri 0:31f7be68e52d 21 * @section DESCRIPTION
chrigelburri 0:31f7be68e52d 22 *
chrigelburri 0:31f7be68e52d 23 * State is the main mechanism for communicating current realtime system state to
chrigelburri 0:31f7be68e52d 24 * the rest of the system for logging etc.
chrigelburri 3:92ba0254af87 25 *
chrigelburri 0:31f7be68e52d 26 */
chrigelburri 0:31f7be68e52d 27
chrigelburri 0:31f7be68e52d 28 class State : public Task
chrigelburri 0:31f7be68e52d 29 {
chrigelburri 0:31f7be68e52d 30
chrigelburri 0:31f7be68e52d 31 private:
chrigelburri 0:31f7be68e52d 32
chrigelburri 0:31f7be68e52d 33 state_t* s;
chrigelburri 0:31f7be68e52d 34 RobotControl* robotControl;
chrigelburri 0:31f7be68e52d 35 MaxonESCON* motorControllerLeft;
chrigelburri 0:31f7be68e52d 36 MaxonESCON* motorControllerRight;
chrigelburri 1:6cd533a712c6 37 // HMC6352* compass;
chrigelburri 0:31f7be68e52d 38 AnalogIn* battery;
chrigelburri 0:31f7be68e52d 39 Timer timer;
chrigelburri 0:31f7be68e52d 40 float period;
chrigelburri 0:31f7be68e52d 41
chrigelburri 0:31f7be68e52d 42 float magout[3];
chrigelburri 0:31f7be68e52d 43
chrigelburri 0:31f7be68e52d 44 public:
chrigelburri 0:31f7be68e52d 45
chrigelburri 0:31f7be68e52d 46 /**
chrigelburri 1:6cd533a712c6 47 * Creates a robot control object and initializes all private state variables.
chrigelburri 3:92ba0254af87 48 * @param s struct to read and write the state
chrigelburri 3:92ba0254af87 49 * @param robotControl Object to read the state
chrigelburri 3:92ba0254af87 50 * @param motorControllerLeft a reference to the servo drive for the left motor
chrigelburri 3:92ba0254af87 51 * @param motorControllerRight a reference to the servo drive for the right motor
chrigelburri 0:31f7be68e52d 52 * @param compass Modul HMC5883L
chrigelburri 1:6cd533a712c6 53 * @param battery Analog Input Battery Voltage input
chrigelburri 3:92ba0254af87 54 * @param period the sampling period of the run loop of this controller, given in [s]
chrigelburri 0:31f7be68e52d 55 */
chrigelburri 1:6cd533a712c6 56 State(state_t* s, RobotControl* robotControl, MaxonESCON* motorControllerLeft, MaxonESCON* motorControllerRight, /*HMC6352* compass,*/ AnalogIn* battery, float period);
chrigelburri 0:31f7be68e52d 57
chrigelburri 0:31f7be68e52d 58 /**
chrigelburri 0:31f7be68e52d 59 * Destructor of the Object to destroy the Object.
chrigelburri 0:31f7be68e52d 60 **/
chrigelburri 0:31f7be68e52d 61 virtual ~State();
chrigelburri 2:d8e1613dc38b 62
chrigelburri 0:31f7be68e52d 63 /**
chrigelburri 3:92ba0254af87 64 * Initzialize the File. Open the File plots.txt and set the title at first line.
chrigelburri 0:31f7be68e52d 65 */
chrigelburri 0:31f7be68e52d 66 void initPlotFile(void);
chrigelburri 0:31f7be68e52d 67
chrigelburri 0:31f7be68e52d 68 /**
chrigelburri 0:31f7be68e52d 69 * Save the char to the file.
chrigelburri 0:31f7be68e52d 70 * For example at the end.
chrigelburri 0:31f7be68e52d 71 * Don't forget the \n at first.
chrigelburri 0:31f7be68e52d 72 */
chrigelburri 0:31f7be68e52d 73 void savePlotText(char text[]);
chrigelburri 0:31f7be68e52d 74
chrigelburri 0:31f7be68e52d 75 /**
chrigelburri 3:92ba0254af87 76 * Close the File.
chrigelburri 0:31f7be68e52d 77 */
chrigelburri 0:31f7be68e52d 78 void closePlotFile(void);
chrigelburri 0:31f7be68e52d 79
chrigelburri 0:31f7be68e52d 80 /**
chrigelburri 0:31f7be68e52d 81 * Return the Battery voltage
chrigelburri 0:31f7be68e52d 82 * state variables.
chrigelburri 0:31f7be68e52d 83 * @return Batterie Voltage [V]
chrigelburri 0:31f7be68e52d 84 */
chrigelburri 0:31f7be68e52d 85 float readBattery();
chrigelburri 0:31f7be68e52d 86
chrigelburri 1:6cd533a712c6 87 /**
chrigelburri 3:92ba0254af87 88 * Starts the timer from zero.
chrigelburri 1:6cd533a712c6 89 * The timer is for the logging Time.
chrigelburri 1:6cd533a712c6 90 */
chrigelburri 0:31f7be68e52d 91 void startTimerFromZero();
chrigelburri 0:31f7be68e52d 92
chrigelburri 0:31f7be68e52d 93 /**
chrigelburri 3:92ba0254af87 94 * Save the new state to a new line.
chrigelburri 0:31f7be68e52d 95 */
chrigelburri 0:31f7be68e52d 96 void savePlotFile(state_t s);
chrigelburri 0:31f7be68e52d 97
chrigelburri 0:31f7be68e52d 98 void run();
chrigelburri 0:31f7be68e52d 99
chrigelburri 0:31f7be68e52d 100 private:
chrigelburri 0:31f7be68e52d 101
chrigelburri 0:31f7be68e52d 102 void setBatteryBit();
chrigelburri 0:31f7be68e52d 103
chrigelburri 0:31f7be68e52d 104 void setEnableLeftBit();
chrigelburri 0:31f7be68e52d 105
chrigelburri 0:31f7be68e52d 106 void setEnableRightBit();
chrigelburri 0:31f7be68e52d 107 };
chrigelburri 0:31f7be68e52d 108
chrigelburri 0:31f7be68e52d 109 #endif