// 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 space_h #define space_h #include #include #include "group.hh" #include "oconfig.hh" /// Etalonnage des distances et localisation de la balle class Space { /// Classe config OConfig *oconfig_; /// hauteur de l'image int imgHeight_; /// largeur de l'image int imgWidth_; /// tableau d'index des distances double *tabX_, *tabY_; /// liste des distances etalonnees struct SetupPoint; std::vector setupTab; double aY_, bY_, cY_; public: /// Constructeur Space (const int width, const int height); /// Destructeur ~Space (); /// Position d'un objet dans le referentiel du robot void getLoc (const int locImgX, const int locImgY, int &locX, int &locY_); void getLoc (const int locImgX, const int locImgY, double &locX, double &locY_); /// Donne la position reelle sur la table de la balle void getPos (const double locX, const double locY, const double posRobotX, const double posRobotY, const double angleRobot, double &posX, double &posY); /// Give Real Location dist and angle void getRealLoc (Zone &zone, int &x, int &y, double &angle, int &dist); /// Ajoute un point pour l'etalonnage void addSetupPoint (const int x, const int y, const int distx, const int disty); /// Chargement des points a partir d'un fichier void loadFromFile (); /// Etalonnage des distances int setup (const double aY_, const double bY_, const double cY_); private: struct SetupPoint { int x, y; int distx, disty; }; /// Donne les coefficients d'une ligne void findCoeffLine (const double x1, const double y1, const double x2, const double y2, double &a, double &b); /// Cree un fichier gnuplot avec la courbe des points donnés par la courbe x et y void createGnuPlotFile (const int y = 100); /// Cree un fichier avec l'erreur en fonction des itérations void logErrorPoint (FILE *f, const int iter); }; #endif // space_h