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 Feb 07 17:43:19 2013 +0000
Revision:
0:31f7be68e52d
Child:
1:6cd533a712c6
first steps

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 0:31f7be68e52d 18 * Copyright (c) 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 0:31f7be68e52d 25 */
chrigelburri 0:31f7be68e52d 26
chrigelburri 0:31f7be68e52d 27 class State : public Task
chrigelburri 0:31f7be68e52d 28 {
chrigelburri 0:31f7be68e52d 29
chrigelburri 0:31f7be68e52d 30 private:
chrigelburri 0:31f7be68e52d 31
chrigelburri 0:31f7be68e52d 32 state_t* s;
chrigelburri 0:31f7be68e52d 33 RobotControl* robotControl;
chrigelburri 0:31f7be68e52d 34 MaxonESCON* motorControllerLeft;
chrigelburri 0:31f7be68e52d 35 MaxonESCON* motorControllerRight;
chrigelburri 0:31f7be68e52d 36 HMC6352* compass;
chrigelburri 0:31f7be68e52d 37 AnalogIn* battery;
chrigelburri 0:31f7be68e52d 38 Timer timer;
chrigelburri 0:31f7be68e52d 39 float period;
chrigelburri 0:31f7be68e52d 40
chrigelburri 0:31f7be68e52d 41 float magout[3];
chrigelburri 0:31f7be68e52d 42
chrigelburri 0:31f7be68e52d 43
chrigelburri 0:31f7be68e52d 44
chrigelburri 0:31f7be68e52d 45 public:
chrigelburri 0:31f7be68e52d 46
chrigelburri 0:31f7be68e52d 47
chrigelburri 0:31f7be68e52d 48 /**
chrigelburri 0:31f7be68e52d 49 * Creates a robot control object and initializes all private
chrigelburri 0:31f7be68e52d 50 * state variables.
chrigelburri 0:31f7be68e52d 51 * @param RobotControl Objekt to read the state.
chrigelburri 0:31f7be68e52d 52 * @param motorControllerLeft a reference to the servo drive for the left motor.
chrigelburri 0:31f7be68e52d 53 * @param motorControllerRight a reference to the servo drive for the right motor.
chrigelburri 0:31f7be68e52d 54 * @param compass Modul HMC5883L
chrigelburri 0:31f7be68e52d 55 * @param Analog Input Battery Voltage input
chrigelburri 0:31f7be68e52d 56 * @param period the sampling period of the run loop of this controller, given in [s].
chrigelburri 0:31f7be68e52d 57 */
chrigelburri 0:31f7be68e52d 58 State(state_t* s, RobotControl* robotControl, MaxonESCON* motorControllerLeft, MaxonESCON* motorControllerRight, HMC6352* compass, AnalogIn* battery, float period);
chrigelburri 0:31f7be68e52d 59
chrigelburri 0:31f7be68e52d 60 /**
chrigelburri 0:31f7be68e52d 61 * Destructor of the Object to destroy the Object.
chrigelburri 0:31f7be68e52d 62 **/
chrigelburri 0:31f7be68e52d 63 virtual ~State();
chrigelburri 0:31f7be68e52d 64
chrigelburri 0:31f7be68e52d 65
chrigelburri 0:31f7be68e52d 66 /**
chrigelburri 0:31f7be68e52d 67 * Initzialize the File. Open the File plots.txt and set the title at first line
chrigelburri 0:31f7be68e52d 68 */
chrigelburri 0:31f7be68e52d 69 void initPlotFile(void);
chrigelburri 0:31f7be68e52d 70
chrigelburri 0:31f7be68e52d 71
chrigelburri 0:31f7be68e52d 72
chrigelburri 0:31f7be68e52d 73 /**
chrigelburri 0:31f7be68e52d 74 * Save the char to the file.
chrigelburri 0:31f7be68e52d 75 * For example at the end.
chrigelburri 0:31f7be68e52d 76 * Don't forget the \n at first.
chrigelburri 0:31f7be68e52d 77 */
chrigelburri 0:31f7be68e52d 78 void savePlotText(char text[]);
chrigelburri 0:31f7be68e52d 79
chrigelburri 0:31f7be68e52d 80
chrigelburri 0:31f7be68e52d 81 /**
chrigelburri 0:31f7be68e52d 82 * Close the File
chrigelburri 0:31f7be68e52d 83 */
chrigelburri 0:31f7be68e52d 84 void closePlotFile(void);
chrigelburri 0:31f7be68e52d 85
chrigelburri 0:31f7be68e52d 86
chrigelburri 0:31f7be68e52d 87 /**
chrigelburri 0:31f7be68e52d 88 * Return the Battery voltage
chrigelburri 0:31f7be68e52d 89 * state variables.
chrigelburri 0:31f7be68e52d 90 * @return Batterie Voltage [V]
chrigelburri 0:31f7be68e52d 91 */
chrigelburri 0:31f7be68e52d 92 float readBattery();
chrigelburri 0:31f7be68e52d 93
chrigelburri 0:31f7be68e52d 94 void startTimerFromZero();
chrigelburri 0:31f7be68e52d 95
chrigelburri 0:31f7be68e52d 96 /**
chrigelburri 0:31f7be68e52d 97 * Save the new state to a new line
chrigelburri 0:31f7be68e52d 98 */
chrigelburri 0:31f7be68e52d 99 void savePlotFile(state_t s);
chrigelburri 0:31f7be68e52d 100
chrigelburri 0:31f7be68e52d 101 void run();
chrigelburri 0:31f7be68e52d 102
chrigelburri 0:31f7be68e52d 103
chrigelburri 0:31f7be68e52d 104 private:
chrigelburri 0:31f7be68e52d 105
chrigelburri 0:31f7be68e52d 106 void setBatteryBit();
chrigelburri 0:31f7be68e52d 107
chrigelburri 0:31f7be68e52d 108 void setEnableLeftBit();
chrigelburri 0:31f7be68e52d 109
chrigelburri 0:31f7be68e52d 110 void setEnableRightBit();
chrigelburri 0:31f7be68e52d 111 };
chrigelburri 0:31f7be68e52d 112
chrigelburri 0:31f7be68e52d 113 #endif