Tobis Programm forked to not destroy your golden files
Fork of Robocode by
source/Positioning.cpp@38:3526c36e4c73, 2017-04-04 (annotated)
- Committer:
- cittecla
- Date:
- Tue Apr 04 15:01:59 2017 +0000
- Revision:
- 38:3526c36e4c73
- Parent:
- 34:40d8d29b44b8
- Child:
- 39:92723f7ea54f
Started resolving State_Machine
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cittecla | 12:91c2e07d2b5b | 1 | /** |
cittecla | 12:91c2e07d2b5b | 2 | * Positioning function library |
cittecla | 12:91c2e07d2b5b | 3 | * Handels position of the Robot on the map |
cittecla | 12:91c2e07d2b5b | 4 | **/ |
cittecla | 33:8a98f8b9d859 | 5 | |
cittecla | 33:8a98f8b9d859 | 6 | |
cittecla | 38:3526c36e4c73 | 7 | #include "Positioning.h" |
cittecla | 33:8a98f8b9d859 | 8 | position current_pos; |
cittecla | 12:91c2e07d2b5b | 9 | |
cittecla | 34:40d8d29b44b8 | 10 | position get_current_pos() |
cittecla | 33:8a98f8b9d859 | 11 | { |
cittecla | 33:8a98f8b9d859 | 12 | return current_pos; |
cittecla | 33:8a98f8b9d859 | 13 | } |
cittecla | 38:3526c36e4c73 | 14 | |
cittecla | 38:3526c36e4c73 | 15 | int positioning(){ |
cittecla | 38:3526c36e4c73 | 16 | |
cittecla | 38:3526c36e4c73 | 17 | return 0; |
cittecla | 38:3526c36e4c73 | 18 | } |
cittecla | 38:3526c36e4c73 | 19 | |
cittecla | 38:3526c36e4c73 | 20 | |
cittecla | 38:3526c36e4c73 | 21 | |
cittecla | 34:40d8d29b44b8 | 22 | /* |
cittecla | 33:8a98f8b9d859 | 23 | void initial_positioning() |
cittecla | 33:8a98f8b9d859 | 24 | { |
cittecla | 33:8a98f8b9d859 | 25 | float last_dist_r = 1.0f; |
cittecla | 33:8a98f8b9d859 | 26 | float last_dist_f = 1.0f; |
cittecla | 33:8a98f8b9d859 | 27 | |
cittecla | 33:8a98f8b9d859 | 28 | int deg_r = 0; |
cittecla | 33:8a98f8b9d859 | 29 | int deg_l = 0; |
cittecla | 33:8a98f8b9d859 | 30 | |
cittecla | 33:8a98f8b9d859 | 31 | turn_straight_right(); |
cittecla | 33:8a98f8b9d859 | 32 | turn_straight_left(); |
cittecla | 12:91c2e07d2b5b | 33 | |
cittecla | 33:8a98f8b9d859 | 34 | while(last_dist_r > sensors[r]) { |
cittecla | 33:8a98f8b9d859 | 35 | turn_sensor_right(1); //turn sensor + 1 deg |
cittecla | 33:8a98f8b9d859 | 36 | wait(0.1f) |
cittecla | 33:8a98f8b9d859 | 37 | deg_r += 1; |
cittecla | 33:8a98f8b9d859 | 38 | last_dist_r = sensors[r]; |
cittecla | 33:8a98f8b9d859 | 39 | } |
cittecla | 33:8a98f8b9d859 | 40 | |
cittecla | 33:8a98f8b9d859 | 41 | while(last_dist_l > sensors[l]) { |
cittecla | 33:8a98f8b9d859 | 42 | turn_sensor_left(-1); //turn sensor - 1 deg |
cittecla | 33:8a98f8b9d859 | 43 | wait(0.1f) |
cittecla | 33:8a98f8b9d859 | 44 | deg_l += 1; |
cittecla | 33:8a98f8b9d859 | 45 | last_dist_l = sensors[l]; |
cittecla | 33:8a98f8b9d859 | 46 | } |
cittecla | 33:8a98f8b9d859 | 47 | |
cittecla | 33:8a98f8b9d859 | 48 | int deg_l_2=0; |
cittecla | 33:8a98f8b9d859 | 49 | turn_straight_left(); |
cittecla | 33:8a98f8b9d859 | 50 | last_dist_l = 0; |
cittecla | 33:8a98f8b9d859 | 51 | |
cittecla | 33:8a98f8b9d859 | 52 | while(last_dist_l < sensors[l]) { |
cittecla | 33:8a98f8b9d859 | 53 | turn_sensor_left(1); //turn sensor +1 deg (positiv = uhrzeigersinn) |
cittecla | 33:8a98f8b9d859 | 54 | wait(0.1f) |
cittecla | 33:8a98f8b9d859 | 55 | deg_l_2 += 1; |
cittecla | 33:8a98f8b9d859 | 56 | last_dist_l = sensors[l]; |
cittecla | 33:8a98f8b9d859 | 57 | } |
cittecla | 33:8a98f8b9d859 | 58 | |
cittecla | 33:8a98f8b9d859 | 59 | turn_straight_right(); |
cittecla | 33:8a98f8b9d859 | 60 | turn_straight_left(); |
cittecla | 33:8a98f8b9d859 | 61 | |
cittecla | 33:8a98f8b9d859 | 62 | wait(0.2f); |
cittecla | 33:8a98f8b9d859 | 63 | |
cittecla | 14:9e2ce5880fb0 | 64 | } |
cittecla | 34:40d8d29b44b8 | 65 | */ |