Skip to content

Commit b2670df

Browse files
author
redto0
committed
using smaller contour plus ingoring out of bounds points
Signed-off-by: redto0 <aboccacc@gmail.com>
1 parent d219bf8 commit b2670df

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/backend.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,32 @@ std::optional<nav_msgs::msg::Path> backend::create_path(std::vector<cv::Point2d>
4343

4444
bool is_left_bigger = left_contours.size() > right_contours.size();
4545
Polynomial poly_center = Polynomial(center_poly);
46-
if (is_left_bigger) {
46+
if (!is_left_bigger) {
4747
for (int i = 0; i < left_contours.size(); i++){
4848
float x = poly_center.poly(left_contours[i].y);
4949
float y = left_contours[i].y;
50+
// prevents placing points too far out of the camera frame,
51+
// a little extrapolation is fine but if the poly is too steep it can easily put points at super high x vals and throws off the cart
52+
if (x < -10) {
53+
x = -10;
54+
}
55+
if (x > width + 10) {
56+
x = width + 10;
57+
}
5058
cam_path.push_back(cv::Point2d(x, y));
5159
}
5260
} else {
5361
for (int i = 0; i < right_contours.size(); i++){
5462
float x = poly_center.poly(right_contours[i].y);
5563
float y = right_contours[i].y;
56-
cam_path.push_back(cv::Point2d(y, x));
64+
if (x < -10) {
65+
x = -10;
66+
}
67+
if (x > width + 10) {
68+
x = width + 10;
69+
}
70+
cam_path.push_back(cv::Point2d(x, y));
71+
//cam_path.push_back(cv::Point2d(x, y)); // should this be x, y? switched from y, x to match left contour
5772
}
5873
}
5974

0 commit comments

Comments
 (0)