Time is good

Dependencies:   RoboClaw mbed

Fork of Robot2016_2-0 by ARES

Files at this revision

API Documentation at this revision

Comitter:
IceTeam
Date:
Wed May 04 21:04:50 2016 +0200
Parent:
56:4fd9636dfb36
Child:
59:94b44c4a8a5a
Child:
60:8d2320a54a32
Commit message:
Rajout de la classe Objectif, petits changements dans le fonctionnement de map

Changed in this revision

Map/Objectif/objectif.cpp Show annotated file Show diff for this revision Revisions of this file
Map/Objectif/objectif.h Show annotated file Show diff for this revision Revisions of this file
Map/map.cpp Show annotated file Show diff for this revision Revisions of this file
Map/map.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Map/Objectif/objectif.cpp	Wed May 04 21:04:50 2016 +0200
@@ -0,0 +1,14 @@
+#include "objectif.h"
+
+/* Dernier Changement : Romain 20h20 */
+
+Objectif::Objectif (int type, float x_obj, float y_obj, float thet_obj, AX12 * nA1, AX12 * nA2, AX12 * nA3, Stepper * nS1, Stepper * nS2);
+bool Objectif::Action () {
+	switch(type) {
+		case OBJ_BLOC:
+		break;
+		default:
+		break;
+	}
+	return true;
+}
\ No newline at end of file
--- a/Map/Objectif/objectif.h	Wed May 04 19:43:53 2016 +0200
+++ b/Map/Objectif/objectif.h	Wed May 04 21:04:50 2016 +0200
@@ -1,13 +1,27 @@
 #ifndef OBJECTIF_H
 #define OBJECTIF_H
 
-class Objectif {
+/* Dernier Changement : Romain 20h20 
+Inclu dans : map.h */
+
+#include "../../AX12/AX12.h"
+#include "../../StepperMotor/Stepper.h"
+
+class objectif {
 public:
-	Objectif (int type, float x_obj, float y_obj, float y_objectif);
+	objectif (int type, float x_obj, float y_obj, float thet_obj, AX12 * nA1, AX12 * nA2, AX12 * nA3, Stepper * nS1, Stepper * nS2);
+	bool Action ();
+	float getX() { return x_objectif; }
+	float getY() { return y_objectif; }
+	float getThet() { return thet_object; }
 
 private:
+	bool obj_bloc_action();
+
 	int type;
 	float x_objectif, y_objectif, thet_object;
+	AX12 * A1, * A2, * A3;
+	Stepper * S1, * S2;
 };
 
 #endif
\ No newline at end of file
--- a/Map/map.cpp	Wed May 04 19:43:53 2016 +0200
+++ b/Map/map.cpp	Wed May 04 21:04:50 2016 +0200
@@ -1,13 +1,17 @@
 #include "map.h"
 
+/* Dernier Changement : Romain 20h30 */
+
 map::map (Odometry* nodo) : Codo(nodo) {
 }
 
 void map::Build (int couleur, int formation) {
-    max_x_table = 2800;
-    max_y_table = 1800;
-    min_x_table = 0;
-    min_y_table = 0;
+    if (couleur == VERT) {
+        max_x_table = 2800;
+        max_y_table = 1800;
+        min_x_table = 0;
+        min_y_table = 0;
+    }
 
     addObs(obsCarr (800, 100, 100, 15));
     addObs(obsCarr (2200, 100, 100, 15));
@@ -15,7 +19,7 @@
     addObs(obsCarr (1500, 750, 1100, 15));
     addObs(obsCarr (1500, 1050, 20, 300));
     
-    if (formation == MAP_RIGHTSIDE) { 
+    if (formation == 1) { 
         addObs(obsCarr (0, 2000, 250, 150));  // Coté haut droite
         addObs(obsCarr (200, 2000, 200, 50));
         
@@ -206,4 +210,26 @@
         logger.printf("Chemin pas trouve ...\n\r");
     }
     endedParc = false;
+}
+
+void map::Execute(float XObjectif, float YObjectif) {
+    // logger.printf("Findway %f-%f -> %f-%f\n\r", Codo->getX(), Codo->getY(), XObjectif, YObjectif);
+    Objectif o;
+    FindWay (Codo->getX(), Codo->getY(), o.getX(), o.getY());
+    
+    if (endedParc) {
+        //logger.printf("\n\r");
+        for (int i = 0; i < path.size (); i++) {
+            // logger.printf("Goto %d/%d [%f, %f]... \n\r", i, path.size()-1, path[i].getX(), path[i].getY());
+            //the = (float) atan2((double) (p[i].gety() - odo.getY()), (double) (p[i].getx() - odo.getX())); 
+            Codo->GotoXY((double)path[i].getX(), (double)path[i].getY());
+            // logger.printf("Goto Fini\n\r");
+        }
+
+        //logger.printf("Chemin fini !\n\r");
+    }
+    else {
+        logger.printf("Chemin pas trouve ...\n\r");
+    }
+    endedParc = false;
 }
\ No newline at end of file
--- a/Map/map.h	Wed May 04 19:43:53 2016 +0200
+++ b/Map/map.h	Wed May 04 21:04:50 2016 +0200
@@ -1,22 +1,29 @@
 #ifndef MAP_H
 #define MAP_H
 
+/* Dernier Changement : Romain 20h30 
+Inclu dans : main.cpp 
+Il faut encore gerer les formations de coquillage */
+
 #include "obsCarr.h"
 #include "pointParcours.h"
 #include "nVector.h"
 #include "controle.h"
-#include "Odometry.h"
+#include "Objectif/objectif.h"
+#include "../Odometry/Odometry.h"
 #include "../AX12/AX12.h"
+#include "../../StepperMotor/Stepper.h"
 
 #define MAP_RIGHTSIDE 1
 #define MAP_LEFTSIDE 2
 
 class map {
 public:
-    map (Odometry* nodo);
+    map (Odometry* nodo, AX12 * nA1, AX12 * nA2, AX12 * nA3, Stepper * nS1, Stepper * nS2);
     void addObs (obsCarr nobs);
     void FindWay (point dep, point arr);
     void FindWay (float depX, float depY, float arrX, float arrY);
+    void Execute (int obj);
     void Execute (float XObjectif, float YObjectif);
     void Build(int couleur, int formation);
     nVector<pointParcours>& getParc () { return path; }
@@ -25,8 +32,12 @@
 protected:
     nVector<obsCarr> obs;
     nVector<pointParcours> path;
+    nVector<Objectif> objectifs;
+
     bool endedParc; // Definit s'il existe un chemin parcourable dans le dernier FindWay
     Odometry* Codo;
+    AX12 * A1, * A2, * A3;
+    Stepper * S1, * S2;
 
     float min_x_table, min_y_table, max_x_table, max_y_table;
 };