summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/map.hh
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/map.hh')
-rw-r--r--2005/i/robert/src/ovision/see/map.hh163
1 files changed, 163 insertions, 0 deletions
diff --git a/2005/i/robert/src/ovision/see/map.hh b/2005/i/robert/src/ovision/see/map.hh
new file mode 100644
index 0000000..dca9ee0
--- /dev/null
+++ b/2005/i/robert/src/ovision/see/map.hh
@@ -0,0 +1,163 @@
+// robert - programme du robot 2005
+//
+// Copyright (C) 2005 Olivier Gaillard
+//
+// Robot APB Team/Efrei 2005.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+
+#ifndef map_h
+#define map_h
+
+#include <list>
+#include "group.hh"
+#include "oconfig.hh"
+#include "space.hh"
+#include "motor/motor.hh"
+
+
+#define LOCKED 1
+#define UNLOCKED 0
+
+
+/// Structure stockant les balles
+struct tBALL {
+ /// position de la balle
+ double position[2];
+
+ /// score balle pour le choix de la prochaine balle a aller chercher
+ double score;
+
+ /// score precalcule sans distance pour eviter les calculs redondants
+ double preScore;
+
+ // zone balle, facilite le calcul de la distance robot-balle
+ int zone;
+
+ /// probabilite que la balle sot a la zone indique par la map
+ int skepticism;
+
+ /// balle vu seulement partiellement par la camera
+ bool partial;
+
+ /// précision de la position de la balle pour mettre à jour sa position
+ int precision;
+
+ /// marqueur pour savoir si la balle a quitte le champ de vision par le bas
+ int bottom;
+};
+
+
+/// Classe Map
+class Map
+{
+ /// Variables configurables
+ OConfig *oconfig;
+ Space *space;
+// Motor &motor;
+// const Tracker &tracker;
+
+ /// position des goals
+ double posGoal[2];
+
+ /// Liste de balles trouvees
+ std::list<tBALL> ball;
+
+ /// balle locke ?
+ bool lock;
+
+ /// Palmier sur l'image ?
+ bool treeFound;
+
+ /// Position du palmier à l'écran
+ double posTree[2];
+
+ /// Ajoute une balle a la map
+ void AddBall(double *pos, ZONE *pZone);
+
+ /// Supprime une balle de la map
+ void DelBall(std::list<tBALL>::iterator &iter);
+
+ /// Test si une balle trouvà correspond a une balle de la map
+ int TestSimilarBall(ZONE *pBall , std::list<tBALL>::iterator &iter);
+
+ /// Distance robot-balle
+ double Dist(double *pos1, double *pos2);
+ double Dist(double pos1X, double pos1Y, double pos2X, double pos2Y);
+
+ /// Calcul de l'angle robot-balle
+ double Angle (double ballPosY, double robotPosY, double distRobotBall);
+
+ /// Balle ayant le plus haut score
+ std::list<tBALL>::iterator curBall;
+
+ /// Permet de savoir si une balle est dans curBall
+ bool checkCurBall;
+
+ public:
+
+ /// Balle ayant la plus grand score
+ int goodBall;
+
+ /// Zone ou est situe le robot
+ int zoneRobot;
+
+ /// Constructeurs.
+ Map (Space *space);
+
+ /// Destructeur.
+ ~Map (void);
+
+ /// Retourne si une balle est locke
+ bool IsLock ();
+
+ /// Lock une balle pour savoir quel balle le robot suit
+ void SetLock (bool value);
+
+ /// Presence de palmier sur l'image
+ bool IsTree ();
+
+ /// Ajoute des balles a la liste
+ void AddBallsToMap (Group *group);
+
+ /// Met a jour les scores des balles
+ void UpdateMap ();
+
+ //Affiche les balles de la map
+ void ShowBalls ();
+
+ /// Donne la position du 1er arbre trouvé sur la map
+ bool GetTreePos (double &x, double &y);
+
+ /// Accessors
+ /// Renvoie l'iterator sur la balle courante
+ const std::list<tBALL>::iterator &GetCurBall ();
+
+ /// Donne la position de la balle la plus proche ou locke
+ /// Retourne NULL si la balle locke est perdu
+ bool GetCurBallPos (double &x, double &y);
+
+ /// Donne la position dans le référentiel de la table
+ void GetPosFromLoc (int locImgX, int locImgY, double &posX, double &posY);
+
+ protected:
+};
+
+
+#endif // map_h