summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/ovision/see/skittle.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/ovision/see/skittle.cc')
-rw-r--r--2005/i/robert/src/ovision/see/skittle.cc44
1 files changed, 27 insertions, 17 deletions
diff --git a/2005/i/robert/src/ovision/see/skittle.cc b/2005/i/robert/src/ovision/see/skittle.cc
index 3fb5f64..1253e26 100644
--- a/2005/i/robert/src/ovision/see/skittle.cc
+++ b/2005/i/robert/src/ovision/see/skittle.cc
@@ -23,7 +23,7 @@ Skittle::~Skittle (void)
/// Recherche de la composante principale
void
-Skittle::pca (Zone &zone)
+Skittle::pca (const Zone &zone)
{
// Agrandissement de la zone de recherche
const int grow = oconfig_->skittleGrow;
@@ -63,14 +63,18 @@ Skittle::climb (const int startX, int startY, const int color)
}
/// Vérifie qu'un catadiopre est à proximité
-int
-Skittle::isReflectBand (Zone &zone, std::vector<Zone> &listReflectBand)
+Skittle::Pos
+Skittle::whereIsReflectBand (const Zone &zone, const std::vector<Zone> &listReflectBand)
{
- // Test les variables de composantes principales
- if (!pcX_ && !pcY_ && listReflectBand.size ())
- {
+ const double minAreaRatio = 0.1;
+ const double maxAreaRatio = 0.4;
+ // Test les variables de composantes principales + liste transmise
+ if (pcX_ || !pcY_ || listReflectBand.size ())
+ return error;
+ // Analyse de la taille
+ if (zone.area < minAreaRatio || zone.area > maxAreaRatio) // valeur réelle 0.2
// Parcours la liste des catadiopres
- for (std::vector<Zone>::iterator iter = listReflectBand.begin ();
+ for (std::vector<Zone>::const_iterator iter = listReflectBand.begin ();
iter != listReflectBand.end (); ++iter)
{
// Test la distance cartésienne
@@ -78,16 +82,19 @@ Skittle::isReflectBand (Zone &zone, std::vector<Zone> &listReflectBand)
// Test la distance orthogonale
if (orthoDist (iter->centerx - zone.centerx, iter->centery - zone.centery,
pcX_, pcY_))
- return 1;
-
+ {
+ if (iter->centerx > zone.centerx)
+ return up;
+ else return down;
+ }
+
}
- }
- return 0;
+ return farAway;
}
/// Recherche de du côté de la courbure
-Skittle::BendType
-Skittle::bend (Zone &zone)
+Skittle::Pos
+Skittle::bend (const Zone &zone)
{
/// Border
const int border = oconfig_->skittleBorder;
@@ -116,7 +123,7 @@ Skittle::bend (Zone &zone)
std::cout << std::endl;
const int score = (int)((zone.xmax - zone.xmin - 2*border) / jump * oconfig_->skittleScoreBendRatio) - 2;
- BendType bending = error;
+ Pos bending = error;
if (above > score) bending = up;
else if (below > score) bending = down;
@@ -125,7 +132,7 @@ Skittle::bend (Zone &zone)
/// Analyse la zone
bool
-Skittle::analyse (Zone &zone, std::vector<Zone> &listReflectBand)
+Skittle::analyse (const Zone &zone, const std::vector<Zone> &listReflectBand)
{
// group est partiel ?
// if (zone.partial)
@@ -135,7 +142,7 @@ Skittle::analyse (Zone &zone, std::vector<Zone> &listReflectBand)
std::cout << "vertical !!!" << std::endl;
// debout ou couché ?
bend_ = bend (zone);
- isReflectBand (zone, listReflectBand);
+ whereIsReflectBand (zone, listReflectBand);
}
else
// calcul de l'orientation
@@ -149,5 +156,8 @@ Skittle::show () const
{
std::cout << "<Skittle::show> position : " << (bend_ == up ? "up"
: (bend_ == down ? "down" : "error")) << "\n";
- std::cout << "<Skittle::show> orientation : " << pcX_ << ", " << pcY_ << std::endl;
+ std::cout << "<Skittle::show> orientation : " << pcX_ << ", " << pcY_ << "\n";
+ std::cout << "<Skittle::show> catadiopre: " << (reflectBand_ == up ? "up"
+ : (reflectBand_ == down ? "down"
+ : (reflectBand_ == farAway ? "farAway" : "error"))) << std::endl;
}