summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/space.h
blob: be9686da5aecf23e723e3d9593fd10f5791451dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef space_h
#define space_h
// space.h - Space class
// nono - Programme du robot Efrei Robotique I1-I2 2004
// Copyright (C) 2004 Olivier Gaillard

#include <vector>
#include <iostream>

#define POS_ROBOT_ETALONNOGE_X 300

#include "group.h"
#include "oconfig.h"

struct SETUP_POINT
{
    int x, y;
    int distx, disty;
};


/// Etalonnage des distances et localisation de la balle
class Space
{
    /// Classe config
    OConfig *oconfig;
    
    /// tableau d'index des distances
    uint *tabX;
    uint *tabY;
    
    /// liste des distances etalonnees
    std::vector<SETUP_POINT> setupTab; 

    /// hautdddeur de l'image
    int imgHeight; 

    /// largeur de l'image
    int imgWidth; 

    /// coeff pour l'approximation de la profondeur
    double aY, bY, cY;

    /// coeff pour l'approximation de l'horizontal
    double aX, bX;

  public:

    // Constructeur
    Space (int width, int height, OConfig *oconfig);

    // Destructeur
    ~Space ();

    /// Affiche les tables de correspondances de distances
    void ShowTab ();    

    /// Position d'un objet dans le referentiel du robot
    void GetLoc(int locImgX, int locImgY, int &locX, int &locY);

    /// Ajoute un point pour l'etalonnage
    void AddSetupPoint(int x, int y, int distx, int disty);

    /// Chargement des points a partir d'un fichier
    void Space::LoadFromFile();

    /// Etalonnage des distances
    int Setup();
  protected:
    /// Calcul du determinant
    int Determinant(int matrix[][4]);
    
    /// Calcul du determinant caracteristique
    int CaracteristicDeterminant(int matrix[][4], int numRow);

    /// Donne la position reelle sur la table de la balle
    void GetPos(int locX, int locY, int posRobotX, int posRobotY, double angleRobot, int &posX, int &posY);
};

#endif // space_h