Tobis Programm forked to not destroy your golden files

Dependencies:   mbed

Fork of Robocode by PES 2 - Gruppe 1

Committer:
cittecla
Date:
Tue Apr 18 13:43:44 2017 +0000
Revision:
54:36c290715769
Parent:
53:453f24775644
Child:
61:628f8a4e857c
update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cittecla 18:a82994e67297 1 /**
cittecla 18:a82994e67297 2 * Movement function library
cittecla 18:a82994e67297 3 * Handels Movement of the Robot
cittecla 18:a82994e67297 4 **/
cittecla 39:92723f7ea54f 5
cittecla 39:92723f7ea54f 6 #include "Movement.h"
cittecla 39:92723f7ea54f 7
cittecla 52:56399c2f13cd 8 int moving()
cittecla 52:56399c2f13cd 9 {
cittecla 52:56399c2f13cd 10
cittecla 39:92723f7ea54f 11 return 0;
cittecla 52:56399c2f13cd 12 }
cittecla 52:56399c2f13cd 13
cittecla 52:56399c2f13cd 14 int move_forward_for_distance(float distance)
cittecla 52:56399c2f13cd 15 {
cittecla 52:56399c2f13cd 16
cittecla 39:92723f7ea54f 17 return 0;
cittecla 52:56399c2f13cd 18 }
cittecla 52:56399c2f13cd 19
cittecla 52:56399c2f13cd 20 int move_backward_for_distance()
cittecla 52:56399c2f13cd 21 {
cittecla 52:56399c2f13cd 22
cittecla 39:92723f7ea54f 23 return 0;
cittecla 52:56399c2f13cd 24 }
cittecla 52:56399c2f13cd 25
cittecla 52:56399c2f13cd 26 int turn_for_deg(float deg)
cittecla 52:56399c2f13cd 27 {
cittecla 52:56399c2f13cd 28
cittecla 39:92723f7ea54f 29 return 0;
cittecla 52:56399c2f13cd 30 }
cittecla 52:56399c2f13cd 31
cittecla 52:56399c2f13cd 32
cittecla 52:56399c2f13cd 33 int move_to_next_coord()
cittecla 52:56399c2f13cd 34 {
cittecla 52:56399c2f13cd 35
cittecla 52:56399c2f13cd 36 float current_heading = get_current_heading();
cittecla 53:453f24775644 37 position current_pos = get_current_pos();
cittecla 52:56399c2f13cd 38 position next_pos = get_next_pos();
cittecla 39:92723f7ea54f 39
cittecla 52:56399c2f13cd 40 float needed_heading = 0;
cittecla 52:56399c2f13cd 41 float distance = 0;
cittecla 39:92723f7ea54f 42
cittecla 52:56399c2f13cd 43 // nord(-y) = 0 grad
cittecla 52:56399c2f13cd 44 if(current_pos.y > next_pos.y){
cittecla 52:56399c2f13cd 45 if(current_pos.x > next_pos.x) needed_heading = 315; distance = sqrt2;
cittecla 53:453f24775644 46 if(current_pos.x == next_pos.x) needed_heading = 0; distance = 1;
cittecla 52:56399c2f13cd 47 if(current_pos.x < next_pos.x) needed_heading = 45; distance = sqrt2;
cittecla 52:56399c2f13cd 48 }
cittecla 53:453f24775644 49 if(current_pos.y == next_pos.y){
cittecla 52:56399c2f13cd 50 if(current_pos.x > next_pos.x) needed_heading = 270; distance = 1;
cittecla 53:453f24775644 51 if(current_pos.x == next_pos.x) //error same position;
cittecla 52:56399c2f13cd 52 if(current_pos.x < next_pos.x) needed_heading = 90; distance = 1;
cittecla 52:56399c2f13cd 53 }
cittecla 52:56399c2f13cd 54 if(current_pos.y < next_pos.y){
cittecla 52:56399c2f13cd 55 if(current_pos.x > next_pos.x) needed_heading = 225; distance = sqrt2;
cittecla 53:453f24775644 56 if(current_pos.x == next_pos.x) needed_heading = 180; distance = 1;
cittecla 52:56399c2f13cd 57 if(current_pos.x < next_pos.x) needed_heading = 135; distance = sqrt2;
cittecla 52:56399c2f13cd 58 }
cittecla 52:56399c2f13cd 59
cittecla 52:56399c2f13cd 60 if(needed_heading != current_heading) {
cittecla 53:453f24775644 61 turn_for_deg((needed_heading-current_heading));
cittecla 52:56399c2f13cd 62 } else {
cittecla 53:453f24775644 63 move_forward_for_distance(distance);
cittecla 39:92723f7ea54f 64 }
cittecla 39:92723f7ea54f 65 return 0;
cittecla 52:56399c2f13cd 66 }
cittecla 52:56399c2f13cd 67
cittecla 52:56399c2f13cd 68 int move_in_search_for_brick()
cittecla 52:56399c2f13cd 69 {
cittecla 52:56399c2f13cd 70
cittecla 52:56399c2f13cd 71 return 0;
cittecla 52:56399c2f13cd 72 }
cittecla 52:56399c2f13cd 73
cittecla 39:92723f7ea54f 74
cittecla 39:92723f7ea54f 75
cittecla 39:92723f7ea54f 76
cittecla 39:92723f7ea54f 77
cittecla 39:92723f7ea54f 78
cittecla 39:92723f7ea54f 79
cittecla 39:92723f7ea54f 80