Tobis Programm forked to not destroy your golden files
Fork of Robocode by
source/Mapping.cpp@34:40d8d29b44b8, 2017-03-29 (annotated)
- Committer:
- cittecla
- Date:
- Wed Mar 29 12:10:32 2017 +0000
- Revision:
- 34:40d8d29b44b8
- Parent:
- source/mapping.cpp@29:e7d0208bf2af
- Child:
- 38:3526c36e4c73
update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cittecla | 12:91c2e07d2b5b | 1 | /** |
cittecla | 12:91c2e07d2b5b | 2 | * Mapping function library |
cittecla | 12:91c2e07d2b5b | 3 | * Handels Mapping of the arena and LEGO-stones |
cittecla | 12:91c2e07d2b5b | 4 | **/ |
cittecla | 29:e7d0208bf2af | 5 | /* |
cittecla | 12:91c2e07d2b5b | 6 | #include "mbed.h" |
cittecla | 12:91c2e07d2b5b | 7 | |
cittecla | 12:91c2e07d2b5b | 8 | double time_counter = 0.0f; |
cittecla | 12:91c2e07d2b5b | 9 | double deltatime = 0.0f; |
cittecla | 12:91c2e07d2b5b | 10 | |
cittecla | 13:57f5a7876d2f | 11 | void mapping() |
cittecla | 13:57f5a7876d2f | 12 | { |
cittecla | 28:274e1d4ecac5 | 13 | //pseudo code |
cittecla | 28:274e1d4ecac5 | 14 | check_sensor(left); |
cittecla | 28:274e1d4ecac5 | 15 | check_sensor(right); |
cittecla | 28:274e1d4ecac5 | 16 | |
cittecla | 28:274e1d4ecac5 | 17 | } |
cittecla | 28:274e1d4ecac5 | 18 | |
cittecla | 28:274e1d4ecac5 | 19 | void chack_sensor(sensor) |
cittecla | 28:274e1d4ecac5 | 20 | { |
cittecla | 28:274e1d4ecac5 | 21 | get_distance(); |
cittecla | 28:274e1d4ecac5 | 22 | if(sensor < 80cm || sensor > 10cm) { |
cittecla | 28:274e1d4ecac5 | 23 | calculate_position(sensor, distance); |
cittecla | 28:274e1d4ecac5 | 24 | check_map(position.this, obstacle); |
cittecla | 28:274e1d4ecac5 | 25 | if(map.no-entry){ |
cittecla | 28:274e1d4ecac5 | 26 | check_if_obstacle(distance); |
cittecla | 28:274e1d4ecac5 | 27 | update_map(); |
cittecla | 28:274e1d4ecac5 | 28 | } |
cittecla | 28:274e1d4ecac5 | 29 | } |
cittecla | 14:9e2ce5880fb0 | 30 | } |
cittecla | 28:274e1d4ecac5 | 31 | |
cittecla | 28:274e1d4ecac5 | 32 | void get_distance(sensor) |
cittecla | 28:274e1d4ecac5 | 33 | { |
cittecla | 28:274e1d4ecac5 | 34 | sensor.value; |
cittecla | 28:274e1d4ecac5 | 35 | return value; |
cittecla | 28:274e1d4ecac5 | 36 | } |
cittecla | 28:274e1d4ecac5 | 37 | |
cittecla | 28:274e1d4ecac5 | 38 | void calcualte_position(sensor, distance) |
cittecla | 28:274e1d4ecac5 | 39 | { |
cittecla | 28:274e1d4ecac5 | 40 | do math; |
cittecla | 28:274e1d4ecac5 | 41 | return position; |
cittecla | 28:274e1d4ecac5 | 42 | } |
cittecla | 28:274e1d4ecac5 | 43 | |
cittecla | 28:274e1d4ecac5 | 44 | void check_if_obstacle(distance) |
cittecla | 28:274e1d4ecac5 | 45 | { |
cittecla | 28:274e1d4ecac5 | 46 | move_scanner(); |
cittecla | 28:274e1d4ecac5 | 47 | distance2 = get_distance(sensor); |
cittecla | 28:274e1d4ecac5 | 48 | reset_scanner(); |
cittecla | 28:274e1d4ecac5 | 49 | if(distance -5cm < distance2 && distance +5cm > distance2) { |
cittecla | 28:274e1d4ecac5 | 50 | return 1; |
cittecla | 28:274e1d4ecac5 | 51 | } else { |
cittecla | 28:274e1d4ecac5 | 52 | return 0; |
cittecla | 28:274e1d4ecac5 | 53 | } |
cittecla | 29:e7d0208bf2af | 54 | }*/ |