]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Shape_detect:
authorMartin Synek <synek.martin@gmail.com>
Wed, 27 Apr 2011 10:38:01 +0000 (12:38 +0200)
committerMartin Synek <synek.martin@gmail.com>
Wed, 27 Apr 2011 10:38:01 +0000 (12:38 +0200)
Moved method bresenham_cicle to constructor.
Add maximal (70) and minimal (-70) angle detection (polar_to_cartes()).

src/hokuyo/shape-detect/shape_detect.cc
src/hokuyo/shape-detect/shape_detect.h

index f7d9bac11dc88880c74b7cce6426a238637f1f1d..468bc77e0cc68999c643879cf4637940f7e5aff4 100644 (file)
@@ -22,7 +22,9 @@ Shape_detect::Shape_detect()
        Shape_detect::Radius = 100;
        Shape_detect::Scale = 10;
        Shape_detect::Arc_min_points = 10;
-       Shape_detect::Arc_max_distance = 1000;
+       Shape_detect::Arc_max_distance = 2000;
+
+       bresenham_circle(circle);
 }
 
 Shape_detect::Shape_detect(int line_min_points, int line_error_threshold, int max_distance_point,
@@ -36,6 +38,8 @@ Shape_detect::Shape_detect(int line_min_points, int line_error_threshold, int ma
        Shape_detect::Scale = scale;
        Shape_detect::Arc_min_points = arc_min_points;
        Shape_detect::Arc_max_distance = arc_max_distance;
+
+       bresenham_circle(circle);
 }
 
 inline Shape_detect::Point Shape_detect::intersection_line(const Shape_detect::Point point, const General_form gen)
@@ -160,10 +164,6 @@ void Shape_detect::hough_transform_arc(int begin, int end, std::vector<Arc> &arc
 
        memset(accumulator, 0, sizeof(accumulator));
 
-       std::vector<Shape_detect::Point> circle;
-
-       bresenham_circle(circle);
-
        for (int i = begin; i <= end; i++) {
                int xc = floor((cartes[i].x - center_x) / Shape_detect::Scale);
                int yc = floor((cartes[i].y - center_y) / Shape_detect::Scale);
@@ -381,8 +381,10 @@ void Shape_detect::polar_to_cartes(const unsigned short laser_scan[])
   
        for (int i = 0; i < (int) HOKUYO_ARRAY_SIZE; i++) { 
                r = (laser_scan[i] <= 19) ? 0 : laser_scan[i];
+               
+               fi = HOKUYO_INDEX_TO_RAD(i);
 
-               if (r > 0) {
+               if (r > 0 && fi > (MIN_ANGLE / 180.0 * M_PI) && fi < (MAX_ANGLE / 180.0 * M_PI)) {
                        fi = HOKUYO_INDEX_TO_RAD(i);
                        point.x = r * cos(fi);
                        point.y = r * sin(fi);
index 7d85059ee4083fd9003f93635d2bd936a1ed4723..c789ddb940abb0d69451f95fd7f90e64167cb23d 100644 (file)
@@ -89,6 +89,18 @@ http://mathpages.com/home/kmath110.htm
 #include <robottype.h>
 #include <roboorte_robottype.h>
 
+/**
+ * Maximal angle detection
+ * @ingroup shapedet
+ */
+#define MAX_ANGLE 70.0
+
+/**
+ * Minimal angle detection
+ * @ingroup shapedet
+ */
+#define MIN_ANGLE -70.0
+
 /**
  * There are detected line segments in input array of measured data (laser_scan)
  * by using perpendicular line regression.
@@ -254,6 +266,8 @@ class Shape_detect
 
                std::vector<Point> cartes;//(HOKUYO_ARRAY_SIZE);
 
+               std::vector<Shape_detect::Point> circle;
+
                /**
                 * Calculation of lines intersection.
                 * @param point which pertains to line.