
Time is good
Fork of Robot2016_2-0 by
Revision 60:8d2320a54a32, committed 2016-05-04
- Comitter:
- IceTeam
- Date:
- Wed May 04 23:35:03 2016 +0200
- Parent:
- 57:86f491f5b25d
- Child:
- 61:4a414820870f
- Commit message:
- Commit de test map/objectif
Changed in this revision
--- a/Map/Objectif/objectif.cpp Wed May 04 21:04:50 2016 +0200 +++ b/Map/Objectif/objectif.cpp Wed May 04 23:35:03 2016 +0200 @@ -2,13 +2,31 @@ /* 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); +objectif::objectif (int ntype, float nx_obj, float ny_obj, float nthet_obj, AX12 * np, ControlleurPince * npince) { + Parasol = np; + pince = npince; + type = ntype; + x_objectif = nx_obj; + y_objectif = ny_obj; + thet_objectif = nthet_obj; +} bool Objectif::Action () { switch(type) { case OBJ_BLOC: - break; + return obj_bloc_action(); + break; + case OBJ_PARA: + return obj_para_action(); + break; default: - break; + break; } +} + +bool Objectif::obj_bloc_action () { + return true; +} + +bool Objectif::obj_para_action(); () { return true; } \ No newline at end of file
--- a/Map/Objectif/objectif.h Wed May 04 21:04:50 2016 +0200 +++ b/Map/Objectif/objectif.h Wed May 04 23:35:03 2016 +0200 @@ -9,19 +9,19 @@ class objectif { public: - objectif (int type, float x_obj, float y_obj, float thet_obj, AX12 * nA1, AX12 * nA2, AX12 * nA3, Stepper * nS1, Stepper * nS2); + objectif (int ntype, float nx_obj, float ny_obj, float nthet_obj, AX12 * np, ControlleurPince npince); bool Action (); float getX() { return x_objectif; } float getY() { return y_objectif; } - float getThet() { return thet_object; } + float getThet() { return thet_objectif; } private: bool obj_bloc_action(); - + bool obj_para_action(); + int type; - float x_objectif, y_objectif, thet_object; - AX12 * A1, * A2, * A3; - Stepper * S1, * S2; -}; + float x_objectif, y_objectif, thet_objectif; + AX12 * Parasol; + ControlleurPince pince; #endif \ No newline at end of file
--- a/Map/Objectif/objectif_type.h Wed May 04 21:04:50 2016 +0200 +++ b/Map/Objectif/objectif_type.h Wed May 04 23:35:03 2016 +0200 @@ -2,5 +2,6 @@ #define OBJECTIF_TYPE_H #define OBJ_BLOC 1 +#define OBJ_PARA 2 #endif \ No newline at end of file
--- a/Map/map.cpp Wed May 04 21:04:50 2016 +0200 +++ b/Map/map.cpp Wed May 04 23:35:03 2016 +0200 @@ -5,52 +5,12 @@ map::map (Odometry* nodo) : Codo(nodo) { } -void map::Build (int couleur, int formation) { - 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)); - - addObs(obsCarr (1500, 750, 1100, 15)); - addObs(obsCarr (1500, 1050, 20, 300)); - - if (formation == 1) { - addObs(obsCarr (0, 2000, 250, 150)); // Coté haut droite - addObs(obsCarr (200, 2000, 200, 50)); - - addObs(obsCarr (3000, 2000, 250, 150)); // Coté bas droite - addObs(obsCarr (2800, 2000, 200, 50)); - - addObs(obsCarr (200, 2000-450, 40, 40)); // Coquillages du haut droit - addObs(obsCarr (200, 2000-750, 40, 40)); - - addObs(obsCarr (900, 2000-550, 40, 40)); - addObs(obsCarr (1200, 2000-350, 40, 40)); // Coquillages du milieu/haut - - addObs(obsCarr (1500, 2000-550, 40, 40)); - addObs(obsCarr (1500, 2000-350, 40, 40)); - - addObs(obsCarr (3000-900, 2000-550, 40, 40)); - addObs(obsCarr (3000-1200, 2000-350, 40, 40)); - - addObs(obsCarr (3000-200, 2000-450, 40, 40)); // Coquillages du bas droite - addObs(obsCarr (3000-200, 2000-750, 40, 40)); - } - else { - addObs(obsCarr (1250, 1000, 220, 220)); - addObs(obsCarr (1500, 750, 220, 220)); - addObs(obsCarr (1500, 1250, 220, 220)); - } -} - void map::addObs (obsCarr nobs) { obs.push_back (nobs); } +void map::addObj (objectif nobj) { + objectifs.push_back(nobj); +} void map::FindWay (float depX, float depY, float arrX, float arrY) { point depart(depX, depY); @@ -212,9 +172,9 @@ endedParc = false; } -void map::Execute(float XObjectif, float YObjectif) { +void map::Execute(int obj) { // logger.printf("Findway %f-%f -> %f-%f\n\r", Codo->getX(), Codo->getY(), XObjectif, YObjectif); - Objectif o; + Objectif o = objectifs[obj]; FindWay (Codo->getX(), Codo->getY(), o.getX(), o.getY()); if (endedParc) { @@ -225,11 +185,123 @@ Codo->GotoXY((double)path[i].getX(), (double)path[i].getY()); // logger.printf("Goto Fini\n\r"); } - + Codo->gotoThet(o.getThet()); + o.Action(); //logger.printf("Chemin fini !\n\r"); } else { logger.printf("Chemin pas trouve ...\n\r"); } endedParc = false; +} + +void map::Build (int couleur, int formation) { + if (couleur == VERT) { + max_x_table = 1400; + max_y_table = 1800; + min_x_table = 0; + min_y_table = 0; + } + else { + max_x_table = 2900; + max_y_table = 1800; + min_x_table = 1600; + min_y_table = 0; + } + + if (couleur == VERT) + addObs(obsCarr (0, 2000, 250, 150)); // Coté haut droite + addObs(obsCarr (200, 2000, 200, 50)); + addObs(obsCarr (800, 100, 100, 15)); + } + else { + addObs(obsCarr (3000, 2000, 250, 150)); // Coté bas droite + addObs(obsCarr (2800, 2000, 200, 50)); + addObs(obsCarr (2200, 100, 100, 15)); + } + + addObs(obsCarr (1500, 750, 1100, 15)); + addObs(obsCarr (1500, 1050, 20, 300)); + + if (formation == 1) { + Build_formation_1 (couleur); + } + else { + addObs(obsCarr (1250, 1000, 220, 220)); + addObs(obsCarr (1500, 750, 220, 220)); + addObs(obsCarr (1500, 1250, 220, 220)); + } +} + +void map::Build_formation_1 (int couleur) { + if (couleur == VERT) { + addObs(obsCarr (200, 2000-450, 40, 40)); // Coquillages du haut droit + addObs(obsCarr (200, 2000-750, 40, 40)); + + addObs(obsCarr (900, 2000-550, 40, 40)); + addObs(obsCarr (1200, 2000-350, 40, 40)); // Coquillages du milieu/haut + + addObs(obsCarr (1500, 2000-550, 40, 40)); + addObs(obsCarr (1500, 2000-350, 40, 40)); + + //addObs(obsCarr (3000-900, 2000-550, 40, 40)); + addObs(obsCarr (3000-1200, 2000-350, 40, 40)); + + //addObs(obsCarr (3000-200, 2000-450, 40, 40)); // Coquillages du bas droite + //addObs(obsCarr (3000-200, 2000-750, 40, 40)); + } + else { + //addObs(obsCarr (200, 2000-450, 40, 40)); // Coquillages du haut droit + //addObs(obsCarr (200, 2000-750, 40, 40)); + + //addObs(obsCarr (900, 2000-550, 40, 40)); + addObs(obsCarr (1200, 2000-350, 40, 40)); // Coquillages du milieu/haut + + addObs(obsCarr (1500, 2000-550, 40, 40)); + addObs(obsCarr (1500, 2000-350, 40, 40)); + + addObs(obsCarr (3000-900, 2000-550, 40, 40)); + addObs(obsCarr (3000-1200, 2000-350, 40, 40)); + + addObs(obsCarr (3000-200, 2000-450, 40, 40)); // Coquillages du bas droite + addObs(obsCarr (3000-200, 2000-750, 40, 40)); + } +} + +void map::Build_formation_2 (int couleur) { + if (couleur == VERT) { + addObs(obsCarr (200, 2000-450, 40, 40)); // Coquillages du haut droit + addObs(obsCarr (200, 2000-750, 40, 40)); + + addObs(obsCarr (600, 2000-450, 40, 40)); // Coquillages du milieu haut + addObs(obsCarr (600, 2000-750, 40, 40)); + + addObs(obsCarr (900, 2000-550, 40, 40)); + addObs(obsCarr (1200, 2000-350, 40, 40)); // Coquillages du milieu/haut + + addObs(obsCarr (1500, 2000-550, 40, 40)); + addObs(obsCarr (1500, 2000-350, 40, 40)); + + //addObs(obsCarr (3000-900, 2000-550, 40, 40)); + addObs(obsCarr (3000-1200, 2000-350, 40, 40)); + + //addObs(obsCarr (3000-200, 2000-450, 40, 40)); // Coquillages du bas droite + //addObs(obsCarr (3000-200, 2000-750, 40, 40)); + } + else { + //addObs(obsCarr (200, 2000-450, 40, 40)); // Coquillages du haut droit + //addObs(obsCarr (200, 2000-750, 40, 40)); + + //addObs(obsCarr (900, 2000-550, 40, 40)); + addObs(obsCarr (1200, 2000-350, 40, 40)); // Coquillages du milieu/haut + + addObs(obsCarr (1500, 2000-550, 40, 40)); + addObs(obsCarr (1500, 2000-350, 40, 40)); + + addObs(obsCarr (3000-900, 2000-550, 40, 40)); + addObs(obsCarr (3000-1200, 2000-350, 40, 40)); + + addObs(obsCarr (3000-200, 2000-450, 40, 40)); // Coquillages du bas droite + addObs(obsCarr (3000-200, 2000-750, 40, 40)); + } } \ No newline at end of file
--- a/Map/map.h Wed May 04 21:04:50 2016 +0200 +++ b/Map/map.h Wed May 04 23:35:03 2016 +0200 @@ -21,6 +21,7 @@ public: map (Odometry* nodo, AX12 * nA1, AX12 * nA2, AX12 * nA3, Stepper * nS1, Stepper * nS2); void addObs (obsCarr nobs); + void addObj (objectif nobj); void FindWay (point dep, point arr); void FindWay (float depX, float depY, float arrX, float arrY); void Execute (int obj); @@ -40,6 +41,8 @@ Stepper * S1, * S2; float min_x_table, min_y_table, max_x_table, max_y_table; + + void Build_formation_1 (int couleur); }; #endif \ No newline at end of file