Commit 15034d9e authored by Guillaume Buret's avatar Guillaume Buret
Browse files

added class Dune

parent a425893c
......@@ -76,7 +76,6 @@ HEADERS += \
../../include/actionneurs/brasKrabi.h \
../../include/actionneurs/brasLateraux.h \
../../include/actionneurs/pinces.h \
../../include/strategie/ramasserPied.h \
../../include/hardware/microSwitch.h \
../../include/simul/debugwindow.h \
../../include/asservissement/commandTournerVers.h \
......@@ -106,6 +105,7 @@ HEADERS += \
../../include/actionneurs/parasol.h \
../../include/actionneurs/benne.h \
../../include/strategie/cubeDebut.h \
../../include/strategie/dune.h \
../../include/clock.h
......@@ -155,7 +155,6 @@ SOURCES += \
../../src/actionneurs/brasKrabi.cpp \
../../src/actionneurs/ascenseur.cpp \
../../src/actionneurs/pinces.cpp \
../../src/strategie/ramasserPied.cpp \
../../src/simul/debugwindow.cpp \
../../src/hardware/microSwitch.cpp \
../../src/asservissement/commandTournerVers.cpp \
......@@ -180,6 +179,7 @@ SOURCES += \
../../src/strategie/krabijunior2016.cpp \
../../src/strategie/krabi2016.cpp \
../../src/strategie/cabine.cpp \
../../src/strategie/dune.cpp \
../../src/actionneurs/benne.cpp \
../../src/strategie/zoneConstruction.cpp \
../../src/strategie/cubeDebut.cpp \
......
#ifndef DUNE_H
#define DUNE_H
#include "position.h"
#include "mediumLevelAction.h"
#include "command.h"
#include "benne.h"
class Dune : public MediumLevelAction
{
public:
Dune();
Dune(Position position, Benne* benne);
~Dune();
int update();
Etape::EtapeType getType();
protected:
Position position;
Benne* benne_locale;
};
#endif // DUNE_H
......@@ -23,14 +23,13 @@ public:
CABINE = 8,
ZONE_CONSTRUCTION = 9,
CUBE_DEBUT = 10,
DUNE = 11,
POINT_PASSAGE = 0,
COLLECT = 1,
DEPART = 5,
RAMASSER_PIED = 19,
COIN_GAUCHE_HAUT = 24,
COIN_GAUCHE_BAS = 25,
SPOT_SOLITAIRE_COIN = 26,
......@@ -38,7 +37,6 @@ public:
ROBOT_POINT_PASSAGE = POINT_PASSAGE + ROBOT_VU_ICI,
ROBOT_DEPART = DEPART + ROBOT_VU_ICI,
ROBOT_PIED = RAMASSER_PIED + ROBOT_VU_ICI,
ROBOT_COIN_GAUCHE_HAUT = COIN_GAUCHE_HAUT + ROBOT_VU_ICI,
ROBOT_COIN_GAUCHE_BAS = COIN_GAUCHE_BAS + ROBOT_VU_ICI,
ROBOT_SPOT_SOLITAIRE_COIN = SPOT_SOLITAIRE_COIN + ROBOT_VU_ICI
......
......@@ -9,11 +9,11 @@
#include "etape.h"
#include "zoneConstruction.h"
#include "cabine.h"
#include "ramasserPied.h"
#include "manipulationCoinGaucheBas.h"
#include "manipulationCoinGaucheHaut.h"
#include "manipulationCoinGaucheHautPiedSolitaire.h"
#include "benne.h"
#include "dune.h"
#include "cubeDebut.h"
class Krabi2016 : public StrategieV3
......@@ -25,8 +25,6 @@ public:
/** @brief Actions de Krabi */
Cabine actionCabine[2];
RamasserPied actionRamasserPied[8];
private:
......
#ifndef PIED_H
#define PIED_H
#include "position.h"
#include "mediumLevelAction.h"
#include "command.h"
class RamasserPied : public MediumLevelAction
{
public :
RamasserPied();
RamasserPied(Position goalPosition, bool recule = false);
~RamasserPied();
int update();
Etape::EtapeType getType();
protected :
Position depart;
bool recule;
};
#endif // PIED_H
#include "dune.h"
#include "strategieV2.h"
#include "mediumLevelAction.h"
#include "command.h"
#include "position.h"
#ifndef ROBOTHW
#include <QDebug>
#endif
Dune::Dune(){}
Dune::Dune(Position goalPosition, Benne* benne):MediumLevelAction(goalPosition)
{
goalPosition = this->goalPosition;
benne_locale = benne;
}
Dune::~Dune(){}
Etape::EtapeType Dune::getType()
{
return Etape::DUNE;
}
int Dune::update()
{
if (status == 0)
{
#ifndef ROBOTHW
qDebug() << "Dune";
#endif
//StrategieV2::setCurrentGoal(this->getGoalPosition(), false, VITESSE_LINEAIRE_MAX, -100.0, 200.f);
status++;
}
else if (status == 1)
{
StrategieV2::setCurrentGoal(this->getGoalPosition(), false, VITESSE_LINEAIRE_MAX, -100.0, 200.f);
status++;
}
else if (status == 2) {
if (Command::isNear(this->getGoalPosition(), 100.0f)) // le second paramètre est la distance a l'objectif
{
StrategieV2::stop();
StrategieV2::lookAt(this->getGoalPosition());
status++;
}
}
else if (status == 3) {
#ifndef ROBOTHW
qDebug() << "Etape dune finie";
#endif
benne_locale->setBenneFull();
status = -1;
}
return status;
}
......@@ -354,16 +354,14 @@ QString Etape::getNameType(EtapeType type)
{
case CABINE:
return "Cabine";
case DUNE:
return "Dune";
case ZONE_CONSTRUCTION:
return "Zone de construction";
case POINT_PASSAGE:
return "Passage";
case DEPART:
return "Départ";
case RAMASSER_PIED:
return "Pied";
case CUBE_DEBUT:
return "Pousser les cubes a l'init";
default:
......@@ -377,16 +375,14 @@ QString Etape::getShortNameType(EtapeType type)
{
case CABINE:
return "Cabine";
case DUNE:
return "Dune";
case ZONE_CONSTRUCTION:
return "Z.C";
case POINT_PASSAGE:
return "";
case DEPART:
return "Start";
case RAMASSER_PIED:
return "Pied";
case CUBE_DEBUT:
return "Cube debut";
default:
......
......@@ -31,7 +31,7 @@ Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow)
Position wd_position = Position(400, 500, true);
int wd = Etape::makeEtape(wd_position);
int we = Etape::makeEtape(Position(900, 425, true));
int we = Etape::makeEtape(Position(950, 425, true));
int wf = Etape::makeEtape(Position(1400, 425, true));
// On crée l'étape "pousse les cubes du début"
......@@ -44,11 +44,11 @@ Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow)
int zc2 = Etape::makeEtape(new ZoneConstruction(Position(1150, 600, true), benne));
// Pieds
int pa = Etape::makeEtape(new RamasserPied(Position(1200, 280, true)));
int pb = Etape::makeEtape(new RamasserPied(Position(1400, 280, true)));
int pc = Etape::makeEtape(new RamasserPied(Position(900, 280, true)));
int pd = Etape::makeEtape(new RamasserPied(Position(1500, 280, true)));
// Dune
int da = Etape::makeEtape(new Dune(Position(1200, 280, true), benne));
int db = Etape::makeEtape(new Dune(Position(1400, 280, true), benne));
int dc = Etape::makeEtape(new Dune(Position(950, 250, true), benne));
int dd = Etape::makeEtape(new Dune(Position(1500, 280, true), benne));
// Cabines de plage
int cp1 = Etape::makeEtape(new Cabine(Position(250, 50, true), wd_position));
......@@ -64,31 +64,31 @@ Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow)
Etape::get(wc) ->addVoisin(zc1);
Etape::get(wc) ->addVoisin(zc2);
Etape::get(wc) ->addVoisin(pa);
Etape::get(wc) ->addVoisin(da);
Etape::get(cp1) ->addVoisin(wd);
Etape::get(cp2) ->addVoisin(wd);
Etape::get(wd) ->addVoisin(wb);
Etape::get(pa) ->addVoisin(wb);
Etape::get(pb) ->addVoisin(pa);
Etape::get(pc) ->addVoisin(we);
Etape::get(da) ->addVoisin(wb);
Etape::get(db) ->addVoisin(da);
Etape::get(dc) ->addVoisin(we);
Etape::get(we) ->addVoisin(wa);
Etape::get(we) ->addVoisin(wb);
Etape::get(we) ->addVoisin(wc);
Etape::get(we) ->addVoisin(wd);
Etape::get(we) ->addVoisin(pa);
Etape::get(we) ->addVoisin(da);
Etape::get(wf) ->addVoisin(pb);
Etape::get(wf) ->addVoisin(pd);
Etape::get(wf) ->addVoisin(db);
Etape::get(wf) ->addVoisin(dd);
Etape::get(wf) ->addVoisin(wc);
Etape::get(zc1) ->addVoisin(pa);
Etape::get(zc1) ->addVoisin(pb);
Etape::get(zc1) ->addVoisin(da);
Etape::get(zc1) ->addVoisin(db);
Etape::get(zc2) ->addVoisin(pa);
Etape::get(zc2) ->addVoisin(pb);
Etape::get(zc2) ->addVoisin(da);
Etape::get(zc2) ->addVoisin(db);
Etape::get(zc2) ->addVoisin(wf);
#ifndef ROBOTHW
......@@ -98,7 +98,7 @@ Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow)
// Certaines actions d'étapes ne finnissent pas là où elles ont commencé :
// Clapets:
// Etape::get(4)->setNumeroEtapeFinAction(43); //Clapet notre côté vers notre bord
// Etape::get(4)->setNumeroEtapeFinAction(43); //Clapet notre côté vers notre bord
this->nombreEtapes = Etape::getTotalEtapes();
......@@ -131,14 +131,14 @@ int Krabi2016::getScoreEtape(int i)
case Etape::CUBE_DEBUT :
return 10000;
case Etape::RAMASSER_PIED : {
case Etape::DUNE : {
// On fait comme si on avait rammasé un cube, du coup la benne est pleine, en vrai on fera
// tout ça dans la future classe cube
// le probleme avec le setter est que dans la recherche de meilleur itineraire la methode est exectuee
benne->setBenneFull();
// benne->setBenneFull();
return 100;
}
......
#include "ramasserPied.h"
#include "ascenseur.h"
#include "pinces.h"
#include "strategieV2.h"
#include "mediumLevelAction.h"
#include "command.h"
#include "pinces.h"
#include "odometrie.h"
//MLA : Medium Level Action
#define MLA_RAMASSER_PIED_APPROCHE 1
#define MLA_RAMASSER_PIED_REGARDE 1
#define MLA_RAMASSER_PIED_OUVRIR_PINCES 50
#define MLA_RAMASSER_PIED_APPROCHE_PLUS 1
#define MLA_RAMASSER_PIED_SAISIR 50
#define MLA_RAMASSER_PIED_OUVRE_ASC 50
#define MLA_RAMASSER_PIED_BAISSER_ASC 1
#define MLA_RAMASSER_PIED_FERME 50
#define MLA_RAMASSER_PIED_LEVER_ASC 1
#define MLA_RAMASSER_PIED_FERMER_PINCES 50
#define MLA_RAMASSER_PIED_PART 1
#ifndef ROBOTHW
#include <QDebug>
#endif
RamasserPied::RamasserPied(){}
RamasserPied::RamasserPied(Position goalposition, bool recule): MediumLevelAction(goalposition), recule(recule)
{
}
RamasserPied::~RamasserPied(){}
Etape::EtapeType RamasserPied::getType()
{
return Etape::RAMASSER_PIED;
}
int RamasserPied::update()
{
if (status == 0)
{
#ifndef ROBOTHW
qDebug() << "action pied";
qDebug() << this->goBack;
#endif
depart = Odometrie::odometrie->getPos().getPosition();
StrategieV2::setCurrentGoal(this->goalPosition, false, VITESSE_LINEAIRE_MAX, -100.0, 200.f);
Ascenseur::getSingleton()->leverAscenseur();
status++;
}
else if (status == MLA_RAMASSER_PIED_APPROCHE)
{
if (Command::isNear(goalPosition, 200.0f))
{
StrategieV2::stop();
StrategieV2::lookAt(goalPosition);
status++;
}
}
/*if(status == 0)
{
StrategieV2::lookAt(goalPosition);
status = MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE;
}*/
else if (status == MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE)
{
if (Command::isLookingAt(goalPosition))
{
Pinces::getSingleton()->ouvrirPinces();
status++;
//status = MLA_RAMASSER_PIED_APPROCHE_PLUS + MLA_RAMASSER_PIED_OUVRIR_PINCES + MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE;
}
}
else if (status == MLA_RAMASSER_PIED_OUVRIR_PINCES + MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE)
{
StrategieV2::setCurrentGoal(this->goalPosition, false, VITESSE_LINEAIRE_MAX, -100.0, 140.f);
status++;
}
else if (status == MLA_RAMASSER_PIED_APPROCHE_PLUS + MLA_RAMASSER_PIED_OUVRIR_PINCES + MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE)
{
if(Command::isNear(goalPosition, 140.f))
{
StrategieV2::stop();
Pinces::getSingleton()->saisirPied();
status++;
}
}
else if (status == MLA_RAMASSER_PIED_SAISIR + MLA_RAMASSER_PIED_APPROCHE_PLUS
+ MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE + MLA_RAMASSER_PIED_OUVRIR_PINCES)
{
Ascenseur::getSingleton()->ouvrirAscenseur();
status++;
}
else if (status == MLA_RAMASSER_PIED_OUVRE_ASC + MLA_RAMASSER_PIED_SAISIR + MLA_RAMASSER_PIED_APPROCHE_PLUS
+ MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE + MLA_RAMASSER_PIED_OUVRIR_PINCES)
{
Ascenseur::getSingleton()->baisserAscenseur();
status++;
}
else if (status == MLA_RAMASSER_PIED_BAISSER_ASC + MLA_RAMASSER_PIED_OUVRE_ASC + MLA_RAMASSER_PIED_SAISIR + MLA_RAMASSER_PIED_APPROCHE_PLUS
+ MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE + MLA_RAMASSER_PIED_OUVRIR_PINCES)
{
if(Ascenseur::getSingleton()->estEnBas())
{
Ascenseur::getSingleton()->fermerAscenseur();
status++;
}
}
else if (status == MLA_RAMASSER_PIED_FERME + MLA_RAMASSER_PIED_BAISSER_ASC + MLA_RAMASSER_PIED_OUVRE_ASC
+ MLA_RAMASSER_PIED_SAISIR + MLA_RAMASSER_PIED_APPROCHE_PLUS + MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE + MLA_RAMASSER_PIED_OUVRIR_PINCES)
{
Ascenseur::getSingleton()->leverAscenseur();
status++;
}
else if (status == MLA_RAMASSER_PIED_LEVER_ASC+ MLA_RAMASSER_PIED_FERME + MLA_RAMASSER_PIED_BAISSER_ASC + MLA_RAMASSER_PIED_OUVRE_ASC
+ MLA_RAMASSER_PIED_SAISIR + MLA_RAMASSER_PIED_APPROCHE_PLUS + MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE + MLA_RAMASSER_PIED_OUVRIR_PINCES)
{
if(Ascenseur::getSingleton()->estEnHaut())
{
#ifndef ROBOTHW
qDebug() << this->goBack;
#endif
if(this->recule)
StrategieV2::setCurrentGoal(this->depart, this->recule);
else
StrategieV2::setCurrentGoal(this->goalPosition, this->recule);
Pinces::getSingleton()->fermerPinces();
Ascenseur::getSingleton()->addPied();
status++;
}
}
else if (status == MLA_RAMASSER_PIED_FERMER_PINCES + MLA_RAMASSER_PIED_LEVER_ASC + MLA_RAMASSER_PIED_FERME + MLA_RAMASSER_PIED_BAISSER_ASC + MLA_RAMASSER_PIED_OUVRE_ASC
+ MLA_RAMASSER_PIED_SAISIR + MLA_RAMASSER_PIED_APPROCHE_PLUS + MLA_RAMASSER_PIED_REGARDE + MLA_RAMASSER_PIED_APPROCHE + MLA_RAMASSER_PIED_OUVRIR_PINCES)
{
if ((!this->recule && Command::isNear(goalPosition) || (this->recule && Command::isNear(depart))))
{
#ifndef ROBOTHW
qDebug() << "Etape pied finie";
#endif
status = -1;
}
}
else
{
status++;
}
return status;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment