From 3ece446c2a9198b4b50323cd1b3a5182114c26df Mon Sep 17 00:00:00 2001 From: dufourj Date: Sat, 7 May 2005 01:36:46 +0000 Subject: M2ga commit bordelique du vendredi à 3h du matin avec un gars lourd --- 2005/i/robert/runtime/rc/config | 2 +- 2005/i/robert/runtime/rc/poids | 22 +++--- 2005/i/robert/src/Makefile.defs | 3 - 2005/i/robert/src/ai/Makefile.defs | 2 + 2005/i/robert/src/ai/ai.cc | 45 ++++++++++--- 2005/i/robert/src/ai/ai.hh | 8 ++- 2005/i/robert/src/ai/test_ai.cc | 101 ++++++++++++++++++++++------ 2005/i/robert/src/data/Makefile.defs | 2 +- 2005/i/robert/src/ovision/see/Makefile.defs | 6 +- 2005/i/robert/src/ovision/see/ovision.cc | 8 +-- 10 files changed, 144 insertions(+), 55 deletions(-) diff --git a/2005/i/robert/runtime/rc/config b/2005/i/robert/runtime/rc/config index b08ecd0..0844d9b 100644 --- a/2005/i/robert/runtime/rc/config +++ b/2005/i/robert/runtime/rc/config @@ -33,7 +33,7 @@ es.ascAccBas = 1 es.pVentouses = 3 es.pStatTele = 1 -es.teleSeuil = 1 +es.teleSeuil = 0x171 motor.pStatPosition = 8 motor.pStatMotor = 0 diff --git a/2005/i/robert/runtime/rc/poids b/2005/i/robert/runtime/rc/poids index 33db4a8..a87703b 100644 --- a/2005/i/robert/runtime/rc/poids +++ b/2005/i/robert/runtime/rc/poids @@ -1,15 +1,15 @@ -redSkittle 0 -greenSkittle 2 +redSkittle 3 +greenSkittle 4 gap -1 border -1 base -1 #index #x1 x2 x3 -0 60 105 159 -1 123 125 115 -2 35 118 114 -2 64 128 98 -4 74 121 125 -5 173 145 103 -0 194 139 192 -105 90 111 163 -152 98 90 220 +0 155 124 113 +1 45 124 122 +2 49 110 140 +2 75 172 94 +4 70 107 157 +5 87 124 119 +0 98 180 89 +105 137 220 30 +152 30 220 30 diff --git a/2005/i/robert/src/Makefile.defs b/2005/i/robert/src/Makefile.defs index a25a857..08b5008 100644 --- a/2005/i/robert/src/Makefile.defs +++ b/2005/i/robert/src/Makefile.defs @@ -16,9 +16,6 @@ CXXFLAGS += -pg LDFLAGS += -pg endif -ifeq ($(shell hostname),hermes) -LDFLAGS = -static -endif # Messages sur une ligne. CXXFLAGS += -fmessage-length=0 diff --git a/2005/i/robert/src/ai/Makefile.defs b/2005/i/robert/src/ai/Makefile.defs index 6f13fcf..e64ce6e 100644 --- a/2005/i/robert/src/ai/Makefile.defs +++ b/2005/i/robert/src/ai/Makefile.defs @@ -7,4 +7,6 @@ $(asserv_OBJECTS) $(proto_OBJECTS) $(utils_OBJECTS) $(serial_OBJECTS) \ $(timer_OBJECTS) $(config_OBJECTS) $(scheduler_OBJECTS) $(es_OBJECTS) \ $(ovision_OBJECTS) $(video4linux_OBJECTS) $(image_OBJECTS) + test_ai: $(test_ai_OBJECTS) +test_ai: LDFLAGS += -static diff --git a/2005/i/robert/src/ai/ai.cc b/2005/i/robert/src/ai/ai.cc index 7cd50ab..b3b4f09 100644 --- a/2005/i/robert/src/ai/ai.cc +++ b/2005/i/robert/src/ai/ai.cc @@ -52,7 +52,10 @@ Ai::Ai(const Config & config) Ai::~Ai (void) { // On réinitialise - init (); + // Initialise les moteurs + motor_.init(); + // initialise la carte es + es_.init(); // On sync do { @@ -71,8 +74,8 @@ void Ai::init(void) // initialise la carte es es_.init(); // on init la vision - oVision_.init(motor_.colorState() ? Group::redSkittle : - Group::greenSkittle); +// oVision_.init(motor_.colorState() ? Group::redSkittle : +// Group::greenSkittle); while (!update()); } @@ -235,7 +238,21 @@ Ai::setAccel (int a) { motor_.setAccel (a); while (!update ()); -}/*}}}*/ +} + +/// Renvoye l'état du bouton de sélection de couleur. +bool +Ai::colorBouton (void) +{ + return motor_.colorState (); +} +/// Renvoye si l'objet devant nous est trop prêt. +bool +Ai::objectInFront (void) +{ + return es_.obsTropPres (); +} +/*}}}*/ // *** Les runs ***/*{{{*/ // Balistique non fiable. @@ -268,6 +285,16 @@ Ai::runProtectFond (void) parcourtFond (); } +void Ai::runVisionLine(void) +{ + init(); + initTest(); + do + { + scanVision(true); + basic(100); + }while(motor_.getY() < 1700); +} // Pour les Tests. void Ai::runTest (void) @@ -410,11 +437,11 @@ void Ai::scanVision (bool followLine) /// XXX mettre un argument for (int i = 0; i < (followLine ? 1 : 4) ; i++) { // On prend la photo - oVision_.takeShoot(); - // On analyse la photo - oVision_.update(); +// oVision_.takeShoot(); +// // On analyse la photo +// oVision_.update(); // On mets la liste brute dans le vector - skittles.push_back(oVision_.getSkittles()); +// skittles.push_back(oVision_.getSkittles()); // on tournicote motor_.rotation(angleDepart + ((i + 1) * M_PI/4)); } @@ -452,7 +479,7 @@ void Ai::remonteWithCam(void) { int x, y , angle, dist; Zone zeSkittles = goodSkittles_.back(); - oVision_.getLoc(zeSkittles, x, y, angle, dist); +// oVision_.getLoc(zeSkittles, x, y, angle, dist); dist -= 9; rotation(motor_.getA() + angle); setMaxSpeed(2,1); diff --git a/2005/i/robert/src/ai/ai.hh b/2005/i/robert/src/ai/ai.hh index 8454706..6867031 100644 --- a/2005/i/robert/src/ai/ai.hh +++ b/2005/i/robert/src/ai/ai.hh @@ -40,7 +40,7 @@ class Ai // Modules de controle du robot Motor motor_; Es es_; - OVision oVision_; +// OVision oVision_; // Scheduler du robot scheduler::Scheduler scheduler_; scheduler::SchedulableReadFd schedulableMotor_; @@ -87,6 +87,12 @@ class Ai bool sync (void); /// Reset la PWM à zéro. void resetPwm (void); + /// Renvoye l'état du bouton de sélection de couleur. + /// Bas - vert - faux + /// Haut - rouge - vrai + bool colorBouton (void); + /// Renvoye si l'objet devant nous est trop prêt. + bool objectInFront (void); // Balistique non fiable. void runBalNonFiable (void); diff --git a/2005/i/robert/src/ai/test_ai.cc b/2005/i/robert/src/ai/test_ai.cc index f205819..03a1642 100644 --- a/2005/i/robert/src/ai/test_ai.cc +++ b/2005/i/robert/src/ai/test_ai.cc @@ -75,24 +75,27 @@ main (int argc, char **argv) if (++i > argc) throw std::runtime_error ("syntax error"); switch (argv[i][0]) - { - case '0': + { + case '0': // Pour un robot qui n'est pas fiable en // asservissement ai_.runBalNonFiable(); break; - case '1': + case '1': ai_.runBalFiable (); break; - case '2': + case '2': ai_.runTest (); break; - case '3': + case '3': ai_.runProtectFond (); break; - default: + case '4': + ai_.runVisionLine (); + break; + default: throw std::runtime_error ("Param inconnue"); - } + } break; case 'j': if(++i > argc) @@ -130,34 +133,88 @@ main (int argc, char **argv) ai_.rotation(strtod(argv[i], 0)); break; case 'A': - if(++i + 1 > argc) + if(++i > argc) throw std::runtime_error("syntax error"); -// switch(argv[i]) -// { -// case '0': -// ai.moveAsc(BAS); -// break; -// case '1': -// ai.moveAsc(MILIEU); -// break; -// case '2': -// ai.moveAsc(HAUT); -// break; -// } + switch(argv[i][0]) + { + case '0': + ai_.ascenceur(false); + break; + case '1': + ai_.ascenceur(true); + break; + default: + throw std::runtime_error ("Param inconnue"); + break; + } break; case 'v': ai_.ventouses(); break; case 'U': - ai_.update(); + while (!ai_.update()); break; case 'z': ai_.init(); break; + case 't': + if(++i > argc) + throw std::runtime_error("syntax error"); + ai_.temporisation (argv[i][0]); + case 'o': + if(++i > argc) + throw std::runtime_error("syntax error"); + switch (argv[i][0]) + { + case '0': + while (true) + { + while (!ai_.update ()); + if (ai_.objectInFront()) + std::cout << "Objet devant" << std::endl; + else + std::cout << "Pas d'objet devant" << std::endl; + } + break; + case '1': + while (!ai_.update ()); + if (ai_.objectInFront()) + std::cout << "Objet devant" << std::endl; + else + std::cout << "Pas d'objet devant" << std::endl; + } + break; + case 'c': + if(++i > argc) + throw std::runtime_error("syntax error"); + switch (argv[i][0]) + { + case '0': + while (true) + { + while (!ai_.update ()); + if (ai_.colorBouton()) + std::cout << "Couleur vraie" << std::endl; + else + std::cout << "Couleur faux" << std::endl; + } + break; + case '1': + while (!ai_.update ()); + if (ai_.colorBouton()) + std::cout << "Couleur V" << std::endl; + else + std::cout << "Couleur F" << std::endl; + break; + default: + throw std::runtime_error ("Param inconnue"); + } + break; + break; default: throw std::runtime_error ("Error de syntaxe"); } - ai_.update (); + ai_.update (); // XXX à virer ? break; } case 'w': diff --git a/2005/i/robert/src/data/Makefile.defs b/2005/i/robert/src/data/Makefile.defs index 31698f1..b571b9f 100644 --- a/2005/i/robert/src/data/Makefile.defs +++ b/2005/i/robert/src/data/Makefile.defs @@ -1,7 +1,7 @@ PROGRAMS += test_data test_data_buffer data_OBJECTS = data_input.o data_input_file.o data_input_zlib.o \ - data_buffer.o data_output.o -lz + data_buffer.o data_output.o /usr/lib/libz.a test_data_OBJECTS = test_data.o $(data_OBJECTS) diff --git a/2005/i/robert/src/ovision/see/Makefile.defs b/2005/i/robert/src/ovision/see/Makefile.defs index e75b320..f930295 100644 --- a/2005/i/robert/src/ovision/see/Makefile.defs +++ b/2005/i/robert/src/ovision/see/Makefile.defs @@ -1,12 +1,12 @@ PROGRAMS += test_ovision test_img test_group test_map test_ovisiontracker test_cam test_segm test_magnifier test_ovision test_colortable test_space genct n2ml test_hotelling test_eraser -LIBS += $(ovision_OBJECTS) +#LIBS += $(ovision_OBJECTS) -ovision_OBJECTS = convertImg.o img.o oconfig.o segmTable.o hotelling.o segm.o imgInterface.o colorTable.o segmTable.o segmLearn.o group.o magnifier.o skittle.o ovision.o -lz space.o eraser.o# map.o +ovision_OBJECTS = convertImg.o img.o oconfig.o segmTable.o hotelling.o segm.o imgInterface.o colorTable.o segmTable.o segmLearn.o group.o magnifier.o skittle.o ovision.o space.o eraser.o /usr/lib/libz.a# map.o test_img_OBJECTS = test_img.o img.o imgInterface.o oconfig.o $(image_OBJECTS) $(data_OBJECTS) $(net_OBJECTS) test_eraser_OBJECTS = test_eraser.o eraser.o oconfig.o $(image_OBJECTS) $(data_OBJECTS) $(net_OBJECTS) n2ml_OBJECTS = n2ml.o oconfig.o img.o segm.o segmLearn.o $(image_OBJECTS) $(data_OBJECTS) $(net_OBJECTS) -genct_OBJECTS = genct.o oconfig.o segm.o segmLearn.o colorTable.o -lz +genct_OBJECTS = genct.o oconfig.o segm.o segmLearn.o colorTable.o /usr/lib/libz.a test_hotelling_OBJECTS = test_hotelling.o hotelling.o oconfig.o test_cam_OBJECTS = test_cam.o img.o imgInterface.o oconfig.o $(video4linux_OBJECTS) $(image_OBJECTS) $(utils_OBJECTS) $(data_OBJECTS) $(net_OBJECTS) test_segm_OBJECTS = test_segm.o img.o segm.o segmLearn.o oconfig.o imgInterface.o colorTable.o segmTable.o $(image_OBJECTS) $(data_OBJECTS) $(net_OBJECTS) diff --git a/2005/i/robert/src/ovision/see/ovision.cc b/2005/i/robert/src/ovision/see/ovision.cc index 8b7b28d..220bd89 100644 --- a/2005/i/robert/src/ovision/see/ovision.cc +++ b/2005/i/robert/src/ovision/see/ovision.cc @@ -4,7 +4,7 @@ /// Constructeur OVision::OVision (bool useSocket) : oconfig_ (0), img_ (0), colorTab_ (0), segm_ (0), eraser_ (0), - group_ (0), mag_ (0), step_ (0), aim_ (Group::undefined) //map_ (0), + group_ (0), mag_ (0), v4l_ (0), step_ (0), aim_ (Group::undefined) //map_ (0), { // socket_ = 0; } @@ -31,18 +31,18 @@ OVision::init (const Group::ZoneType aim) // Initialisation des classes if (aim == Group::redSkittle) { - colorTab_ = new ColorTable ("../runtime/rc/colortableGreen.z"); + colorTab_ = new ColorTable ("../runtime/rc/colortableRed.z"); oconfig_->nnInfluLum = 0.4; oconfig_->groupColor.clear (); ObjectColor tmp; tmp.label = "redSkittle"; - tmp.color = 0; + tmp.color = 3; tmp.type = aim; oconfig_->groupColor.push_back (tmp); } else { - colorTab_ = new ColorTable ("../runtime/rc/colortableRed.z"); + colorTab_ = new ColorTable ("../runtime/rc/colortableGreen.z"); oconfig_->nnInfluLum = 0.4; ObjectColor tmp; oconfig_->groupColor.clear (); -- cgit v1.2.3