with class
Dependencies: ISR_Mini-explorer mbed
Fork of VirtualForces by
Map.hpp@39:890439b495e3, 2017-06-16 (annotated)
- Committer:
- Ludwigfr
- Date:
- Fri Jun 16 10:40:53 2017 +0000
- Revision:
- 39:890439b495e3
- Parent:
- 36:b59d56d0b3b4
last version with the 4th lab;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ludwigfr | 33:814bcd7d3cfe | 1 | #ifndef MAP_HPP |
Ludwigfr | 33:814bcd7d3cfe | 2 | #define MAP_HPP |
Ludwigfr | 33:814bcd7d3cfe | 3 | |
Ludwigfr | 34:c208497dd079 | 4 | #include<math.h> |
Ludwigfr | 33:814bcd7d3cfe | 5 | |
Ludwigfr | 34:c208497dd079 | 6 | /* |
Ludwigfr | 33:814bcd7d3cfe | 7 | Robot coordinate system: World coordinate system: |
Ludwigfr | 33:814bcd7d3cfe | 8 | ^ ^ |
Ludwigfr | 33:814bcd7d3cfe | 9 | |x |y |
Ludwigfr | 33:814bcd7d3cfe | 10 | <--R O--> |
Ludwigfr | 33:814bcd7d3cfe | 11 | y x |
Ludwigfr | 33:814bcd7d3cfe | 12 | |
Ludwigfr | 33:814bcd7d3cfe | 13 | Screen coordinate system |
Ludwigfr | 33:814bcd7d3cfe | 14 | x |
Ludwigfr | 33:814bcd7d3cfe | 15 | O---> |
Ludwigfr | 33:814bcd7d3cfe | 16 | y| |
Ludwigfr | 33:814bcd7d3cfe | 17 | v |
Ludwigfr | 33:814bcd7d3cfe | 18 | |
Ludwigfr | 33:814bcd7d3cfe | 19 | how the float[2] arrays stock the position |
Ludwigfr | 33:814bcd7d3cfe | 20 | Start at 0,0 end top right |
Ludwigfr | 33:814bcd7d3cfe | 21 | ^ |
Ludwigfr | 33:814bcd7d3cfe | 22 | |heightIndice |
Ludwigfr | 33:814bcd7d3cfe | 23 | | |
Ludwigfr | 33:814bcd7d3cfe | 24 | _____> |
Ludwigfr | 33:814bcd7d3cfe | 25 | widthIndice |
Ludwigfr | 33:814bcd7d3cfe | 26 | */ |
Ludwigfr | 33:814bcd7d3cfe | 27 | |
Ludwigfr | 33:814bcd7d3cfe | 28 | |
Ludwigfr | 33:814bcd7d3cfe | 29 | class Map { |
Ludwigfr | 33:814bcd7d3cfe | 30 | |
Ludwigfr | 33:814bcd7d3cfe | 31 | public: |
Ludwigfr | 33:814bcd7d3cfe | 32 | float widthRealMap; |
Ludwigfr | 34:c208497dd079 | 33 | float heightRealMap; |
Ludwigfr | 33:814bcd7d3cfe | 34 | int nbCellWidth; |
Ludwigfr | 33:814bcd7d3cfe | 35 | int nbCellHeight; |
Ludwigfr | 33:814bcd7d3cfe | 36 | float sizeCellWidth; |
Ludwigfr | 33:814bcd7d3cfe | 37 | float sizeCellHeight; |
Ludwigfr | 33:814bcd7d3cfe | 38 | float** cellsLogValues; |
Ludwigfr | 33:814bcd7d3cfe | 39 | float** initialLogValues; |
Ludwigfr | 33:814bcd7d3cfe | 40 | |
Ludwigfr | 34:c208497dd079 | 41 | Map(float widthRealMap, float heightRealMap, int nbCellWidth, int nbCellHeight); |
Ludwigfr | 34:c208497dd079 | 42 | |
Ludwigfr | 34:c208497dd079 | 43 | float cell_width_coordinate_to_world(int i); |
Ludwigfr | 33:814bcd7d3cfe | 44 | |
Ludwigfr | 34:c208497dd079 | 45 | float cell_height_coordinate_to_world(int j); |
Ludwigfr | 34:c208497dd079 | 46 | |
Ludwigfr | 34:c208497dd079 | 47 | float get_proba_cell(int widthIndice, int heightIndice); |
Ludwigfr | 34:c208497dd079 | 48 | |
Ludwigfr | 39:890439b495e3 | 49 | void fill_map_with_initial(); |
Ludwigfr | 39:890439b495e3 | 50 | |
Ludwigfr | 34:c208497dd079 | 51 | //Updates map value |
Ludwigfr | 34:c208497dd079 | 52 | void update_cell_value(int widthIndice,int heightIndice ,float proba); |
Ludwigfr | 36:b59d56d0b3b4 | 53 | |
Ludwigfr | 33:814bcd7d3cfe | 54 | //returns the probability [0,1] that the cell is occupied from the log valAue lt |
Ludwigfr | 33:814bcd7d3cfe | 55 | float log_to_proba(float lt); |
Ludwigfr | 33:814bcd7d3cfe | 56 | |
Ludwigfr | 33:814bcd7d3cfe | 57 | //returns the log value that the cell is occupied from the probability value [0,1] |
Ludwigfr | 33:814bcd7d3cfe | 58 | float proba_to_log(float p); |
Ludwigfr | 35:68f9edbb3cff | 59 | |
Ludwigfr | 36:b59d56d0b3b4 | 60 | private: |
Ludwigfr | 36:b59d56d0b3b4 | 61 | |
Ludwigfr | 36:b59d56d0b3b4 | 62 | //fill initialLogValues with the values we already know (here the bordurs) |
Ludwigfr | 36:b59d56d0b3b4 | 63 | void fill_initialLogValues(); |
Ludwigfr | 36:b59d56d0b3b4 | 64 | |
Ludwigfr | 35:68f9edbb3cff | 65 | /* |
Ludwigfr | 35:68f9edbb3cff | 66 | |
Ludwigfr | 33:814bcd7d3cfe | 67 | float robot_x_coordinate_in_world(float robot_x, float robot_y); |
Ludwigfr | 33:814bcd7d3cfe | 68 | |
Ludwigfr | 33:814bcd7d3cfe | 69 | float robot_y_coordinate_in_world(float robot_x, float robot_y); |
Ludwigfr | 34:c208497dd079 | 70 | |
Ludwigfr | 34:c208497dd079 | 71 | void print_final_map(); |
Ludwigfr | 33:814bcd7d3cfe | 72 | |
Ludwigfr | 34:c208497dd079 | 73 | void print_final_map_with_robot_position(float robot_x,float robot_y); |
Ludwigfr | 33:814bcd7d3cfe | 74 | |
Ludwigfr | 34:c208497dd079 | 75 | void print_final_map_with_robot_position_and_target(float robot_x,float robot_y,float targetXWolrd, float targetYWorld); |
Ludwigfr | 34:c208497dd079 | 76 | */ |
Ludwigfr | 33:814bcd7d3cfe | 77 | }; |
Ludwigfr | 33:814bcd7d3cfe | 78 | |
Ludwigfr | 33:814bcd7d3cfe | 79 | #endif |
Ludwigfr | 33:814bcd7d3cfe | 80 |