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
Fork of autonomous Robot Android by
StateDefines/State.h@2:d8e1613dc38b, 2013-03-03 (annotated)
- Committer:
- chrigelburri
- Date:
- Sun Mar 03 16:26:47 2013 +0000
- Revision:
- 2:d8e1613dc38b
- Parent:
- 1:6cd533a712c6
- Child:
- 3:92ba0254af87
Viereck Fahren; Code aufger?umt und eine setter methode progammiert f?r sollwert
Who changed what in which revision?
User | Revision | Line number | New 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 © 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 | 1:6cd533a712c6 | 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 | public: |
chrigelburri | 0:31f7be68e52d | 44 | |
chrigelburri | 0:31f7be68e52d | 45 | |
chrigelburri | 0:31f7be68e52d | 46 | /** |
chrigelburri | 1:6cd533a712c6 | 47 | * Creates a robot control object and initializes all private state variables. |
chrigelburri | 1:6cd533a712c6 | 48 | * @param s struct to read and write the state. |
chrigelburri | 1:6cd533a712c6 | 49 | * @param robotControl Object to read the state. |
chrigelburri | 0:31f7be68e52d | 50 | * @param motorControllerLeft a reference to the servo drive for the left motor. |
chrigelburri | 0:31f7be68e52d | 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 | 0:31f7be68e52d | 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 | 0:31f7be68e52d | 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 | 0:31f7be68e52d | 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 | 1:6cd533a712c6 | 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 | 0:31f7be68e52d | 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 | |
chrigelburri | 0:31f7be68e52d | 101 | private: |
chrigelburri | 0:31f7be68e52d | 102 | |
chrigelburri | 0:31f7be68e52d | 103 | void setBatteryBit(); |
chrigelburri | 0:31f7be68e52d | 104 | |
chrigelburri | 0:31f7be68e52d | 105 | void setEnableLeftBit(); |
chrigelburri | 0:31f7be68e52d | 106 | |
chrigelburri | 0:31f7be68e52d | 107 | void setEnableRightBit(); |
chrigelburri | 0:31f7be68e52d | 108 | }; |
chrigelburri | 0:31f7be68e52d | 109 | |
chrigelburri | 0:31f7be68e52d | 110 | #endif |