Navigate to a given point using the OGM and virtual forces

Dependencies:   ISR_Mini-explorer mbed

Fork of VirtualForces by Georgios Tsamis

Revision:
45:fb07065a64a9
Parent:
44:e2bd06f94dc0
Child:
46:e57ebcf747dc
--- a/main.cpp	Mon May 29 11:52:56 2017 +0000
+++ b/main.cpp	Mon May 29 12:59:51 2017 +0000
@@ -67,6 +67,7 @@
 float sign1(float value);
 //return 1 if positiv, 0 if negativ
 int sign2(float value);
+//set target in ortho space, in reference to the robot (so if the robot is in the middle, you want to him to go 10cm down and 15 right, set_target_to(15,-10)
 void set_target_to(float x, float y);
 void try_to_reach_target();
 
@@ -139,13 +140,13 @@
 int main(){
     initialise_parameters();   
     //try to reach the target     
-    set_target_to(50,0);//up right
+    set_target_to(0,50);//up right
     print_final_map_with_robot_position_and_target();
     try_to_reach_target();
-    set_target_to(-50,0);//lower right
+    set_target_to(0,-50);//lower right
     print_final_map_with_robot_position_and_target();
     try_to_reach_target();
-    set_target_to(50,50);//up left
+    set_target_to(-50,50);//up left
     print_final_map_with_robot_position_and_target();
     try_to_reach_target();
     //print the map forever
@@ -180,9 +181,10 @@
     pc.printf("\r\n target reached");
 }
 
+//target in ortho space
 void set_target_to(float x, float y){
-    targetX=x;
-    targetY=y;
+    targetX=y;
+    targetY=-x;
     targetXOrhto=x_robot_in_orthonormal_x(targetX,targetY);
     targetYOrhto=y_robot_in_orthonormal_y(targetX,targetY);
 }