summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/ia/ia.cc
blob: 14f47a2fcc5505e4d7c9f8fe91fe7cd09b99a02f (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
// ia.cc
// buzz - Programme du robot Efrei Robotique I1-I2 2003
// Copyright (C) 2003 Nicolas Schodet
//
#include "ia.h"

// Instance unique.
Ia *Ia::m_instance = 0;

// Constructeur.
Ia (const char *strat)
{
    // Instancie les objets du robot.
    m_thresholds = new Thresholds ("rc/vision/palets.rgb");
    m_camera = new Camera ();
    m_image = new Image (c, t);
    m_grafcet = new Grafcet (strat);
    // Init.
    m_instance = this;
    m_paletFound = false;
    for (int i = 0; i < 8; ++i)
      {
	m_var[i] = 0;
	m_tempo[i] = 0;
      }
}

// Destructeur.
~Ia (void)
{
    m_instance = 0;
    delete m_grafcet;
    delete m_image;
    delete m_camera;
    delete m_thresholds;
}

// Cherche un palet.
bool
Ia::seekPalet (void)
{
    i->reread ();
}

// Va vers le palet pr�c�dement trouv�.
void
Ia::goPalet (void)
{
}

// Variable de l'ia.
int getVar (int var)
{
    return m_var[var];
}

void setVar (int var, int val)
{
    m_var[var] = val;
}

// Tempos de l'ia.
void resetTempo (int tempo)
{
    m_tempo[tempo] = m_date.start ();
}

int getTempo (int tempo)
{
    return m_date.start () - m_tempo[tempo];
}