-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of autonomous map making strategy
- Loading branch information
Sebastian Theophil
committed
Sep 30, 2015
1 parent
43a9c0e
commit 7775714
Showing
9 changed files
with
138 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// edge_following_strategy.cpp | ||
// robotcontrol2 | ||
// | ||
// Created by Sebastian Theophil on 29.09.15. | ||
// Copyright © 2015 Sebastian Theophil. All rights reserved. | ||
// | ||
|
||
#include "edge_following_strategy.h" | ||
#include <opencv2/imgproc.hpp> | ||
|
||
namespace rbt { | ||
void CEdgeFollowingStrategy::update(point<double> const& ptf, double fYaw, COccupancyGrid const& occgrid) { | ||
// Threshold first, converting image to black & white. Decision to drive to a position is essentially binary. | ||
// Either we can drive someplace or we can't. | ||
cv::threshold(occgrid.ErodedMap(), m_matnMapEdges, /* pixels >= */ 255*0.4, /* are set to */ 255, cv::THRESH_BINARY); | ||
|
||
// Recognize edges in eroded map. | ||
// Threshold factors determined empirically to work well with greyscale image. | ||
// They don't matter with thresholded binary image | ||
cv::Canny(m_matnMapEdges, m_matnMapEdges, 100, 300); | ||
|
||
// Turn edges into lines. The robot must follow these lines to scan the walls. | ||
std::vector<cv::Vec4i> vecline; | ||
cv::HoughLinesP(m_matnMapEdges, | ||
vecline, | ||
1, // resolution of r in px | ||
CV_PI/180, // resolution of rho in rad | ||
15); // min number of votes for a line, 15-20 seems to work ok | ||
|
||
// Draw recognized features for debugging | ||
cvtColor(occgrid.GreyscaleMap(), m_matrgbMapFeatures, CV_GRAY2RGB); | ||
boost::for_each(vecline, [&](cv::Vec4i const& line) { | ||
cv::line(m_matrgbMapFeatures, cv::Point(line[0], line[1]), cv::Point(line[2], line[3]), cv::Scalar(0,0,255), /*thickness*/ 1); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// edge_following_strategy.hpp | ||
// robotcontrol2 | ||
// | ||
// Created by Sebastian Theophil on 29.09.15. | ||
// Copyright © 2015 Sebastian Theophil. All rights reserved. | ||
// | ||
|
||
#ifndef edge_following_strategy_hpp | ||
#define edge_following_strategy_hpp | ||
|
||
#include "occupancy_grid.h" | ||
|
||
namespace rbt { | ||
struct CEdgeFollowingStrategy { | ||
CEdgeFollowingStrategy() {} | ||
void update(point<double> const& ptf, double fYaw, COccupancyGrid const& occgrid); | ||
|
||
cv::Mat const& EdgeMap() const { return m_matnMapEdges; } | ||
cv::Mat const& FeatureRGBMap() const { return m_matrgbMapFeatures; } | ||
|
||
private: | ||
cv::Mat m_matnMapEdges; | ||
#ifndef NDEBUG | ||
cv::Mat m_matrgbMapFeatures; | ||
#endif | ||
}; | ||
} | ||
#endif /* edge_following_strategy_hpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters