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@6:48eeb41188dd, 2013-03-23 (annotated)
- Committer:
- chrigelburri
- Date:
- Sat Mar 23 13:52:48 2013 +0000
- Revision:
- 6:48eeb41188dd
- Parent:
- 3:92ba0254af87
- Child:
- 11:775ebb69d5e1
mit link und rechten Radradius
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 | 6:48eeb41188dd | 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 | 6:48eeb41188dd | 37 | // HMC6352* compass; |
chrigelburri | 0:31f7be68e52d | 38 | AnalogIn* battery; |
chrigelburri | 0:31f7be68e52d | 39 | Timer timer; |
chrigelburri | 0:31f7be68e52d | 40 | float period; |
chrigelburri | 6:48eeb41188dd | 41 | //float magout[3]; |
chrigelburri | 0:31f7be68e52d | 42 | |
chrigelburri | 0:31f7be68e52d | 43 | public: |
chrigelburri | 0:31f7be68e52d | 44 | |
chrigelburri | 0:31f7be68e52d | 45 | /** |
chrigelburri | 1:6cd533a712c6 | 46 | * Creates a robot control object and initializes all private state variables. |
chrigelburri | 3:92ba0254af87 | 47 | * @param s struct to read and write the state |
chrigelburri | 3:92ba0254af87 | 48 | * @param robotControl Object to read the state |
chrigelburri | 3:92ba0254af87 | 49 | * @param motorControllerLeft a reference to the servo drive for the left motor |
chrigelburri | 3:92ba0254af87 | 50 | * @param motorControllerRight a reference to the servo drive for the right motor |
chrigelburri | 0:31f7be68e52d | 51 | * @param compass Modul HMC5883L |
chrigelburri | 1:6cd533a712c6 | 52 | * @param battery Analog Input Battery Voltage input |
chrigelburri | 3:92ba0254af87 | 53 | * @param period the sampling period of the run loop of this controller, given in [s] |
chrigelburri | 0:31f7be68e52d | 54 | */ |
chrigelburri | 6:48eeb41188dd | 55 | State(state_t* s, |
chrigelburri | 6:48eeb41188dd | 56 | RobotControl* robotControl, |
chrigelburri | 6:48eeb41188dd | 57 | MaxonESCON* motorControllerLeft, |
chrigelburri | 6:48eeb41188dd | 58 | MaxonESCON* motorControllerRight, |
chrigelburri | 6:48eeb41188dd | 59 | /*HMC6352* compass,*/ |
chrigelburri | 6:48eeb41188dd | 60 | AnalogIn* battery, |
chrigelburri | 6:48eeb41188dd | 61 | float period); |
chrigelburri | 0:31f7be68e52d | 62 | |
chrigelburri | 0:31f7be68e52d | 63 | /** |
chrigelburri | 6:48eeb41188dd | 64 | * Destructor of the Object to destroy the Object. |
chrigelburri | 6:48eeb41188dd | 65 | **/ |
chrigelburri | 0:31f7be68e52d | 66 | virtual ~State(); |
chrigelburri | 6:48eeb41188dd | 67 | |
chrigelburri | 0:31f7be68e52d | 68 | /** |
chrigelburri | 3:92ba0254af87 | 69 | * Initzialize the File. Open the File plots.txt and set the title at first line. |
chrigelburri | 0:31f7be68e52d | 70 | */ |
chrigelburri | 0:31f7be68e52d | 71 | void initPlotFile(void); |
chrigelburri | 0:31f7be68e52d | 72 | |
chrigelburri | 0:31f7be68e52d | 73 | /** |
chrigelburri | 6:48eeb41188dd | 74 | * Save the char to the file. |
chrigelburri | 6:48eeb41188dd | 75 | * For example at the end. |
chrigelburri | 6:48eeb41188dd | 76 | * Don't forget the \n at first. |
chrigelburri | 6:48eeb41188dd | 77 | */ |
chrigelburri | 0:31f7be68e52d | 78 | void savePlotText(char text[]); |
chrigelburri | 0:31f7be68e52d | 79 | |
chrigelburri | 0:31f7be68e52d | 80 | /** |
chrigelburri | 6:48eeb41188dd | 81 | * Close the File. |
chrigelburri | 6:48eeb41188dd | 82 | */ |
chrigelburri | 0:31f7be68e52d | 83 | void closePlotFile(void); |
chrigelburri | 0:31f7be68e52d | 84 | |
chrigelburri | 0:31f7be68e52d | 85 | /** |
chrigelburri | 0:31f7be68e52d | 86 | * Return the Battery voltage |
chrigelburri | 0:31f7be68e52d | 87 | * state variables. |
chrigelburri | 0:31f7be68e52d | 88 | * @return Batterie Voltage [V] |
chrigelburri | 0:31f7be68e52d | 89 | */ |
chrigelburri | 0:31f7be68e52d | 90 | float readBattery(); |
chrigelburri | 0:31f7be68e52d | 91 | |
chrigelburri | 6:48eeb41188dd | 92 | /** |
chrigelburri | 3:92ba0254af87 | 93 | * Starts the timer from zero. |
chrigelburri | 1:6cd533a712c6 | 94 | * The timer is for the logging Time. |
chrigelburri | 1:6cd533a712c6 | 95 | */ |
chrigelburri | 0:31f7be68e52d | 96 | void startTimerFromZero(); |
chrigelburri | 0:31f7be68e52d | 97 | |
chrigelburri | 0:31f7be68e52d | 98 | /** |
chrigelburri | 6:48eeb41188dd | 99 | * Save the new state to a new line. |
chrigelburri | 6:48eeb41188dd | 100 | */ |
chrigelburri | 0:31f7be68e52d | 101 | void savePlotFile(state_t s); |
chrigelburri | 0:31f7be68e52d | 102 | |
chrigelburri | 0:31f7be68e52d | 103 | void run(); |
chrigelburri | 0:31f7be68e52d | 104 | |
chrigelburri | 0:31f7be68e52d | 105 | private: |
chrigelburri | 0:31f7be68e52d | 106 | |
chrigelburri | 0:31f7be68e52d | 107 | void setBatteryBit(); |
chrigelburri | 0:31f7be68e52d | 108 | |
chrigelburri | 0:31f7be68e52d | 109 | void setEnableLeftBit(); |
chrigelburri | 0:31f7be68e52d | 110 | |
chrigelburri | 0:31f7be68e52d | 111 | void setEnableRightBit(); |
chrigelburri | 0:31f7be68e52d | 112 | }; |
chrigelburri | 0:31f7be68e52d | 113 | |
chrigelburri | 0:31f7be68e52d | 114 | #endif |