Skip to content

Commit b5f600c

Browse files
authored
Merge pull request #48 from tue-robotics/cleanup/laser_plugin
Cleanup laser plugin
2 parents a6e2342 + adf432a commit b5f600c

File tree

10 files changed

+1014
-729
lines changed

10 files changed

+1014
-729
lines changed

ed_sensor_integration/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ add_library(ed_kinect
6262
target_link_libraries(ed_kinect ed_association ${catkin_LIBRARIES})
6363
add_dependencies(ed_kinect ${catkin_EXPORTED_TARGETS})
6464

65+
add_library(ed_laser
66+
src/laser/updater.cpp
67+
include/ed/laser/updater.h
68+
include/ed/laser/entity_update.h
69+
)
70+
target_link_libraries(ed_laser ed_association ${catkin_LIBRARIES})
71+
add_dependencies(ed_laser ${catkin_EXPORTED_TARGETS})
72+
6573
# ------------------------------------------------------------------------------------------------
6674
# PLUGINS
6775
# ------------------------------------------------------------------------------------------------
@@ -81,7 +89,7 @@ add_library(ed_laser_plugin
8189
src/laser/laser_plugin.cpp
8290
src/laser/laser_plugin.h
8391
)
84-
target_link_libraries(ed_laser_plugin ed_association ${catkin_LIBRARIES})
92+
target_link_libraries(ed_laser_plugin ed_laser ed_association ${catkin_LIBRARIES})
8593

8694
# ------------------------------------------------------------------------------------------------
8795

@@ -108,6 +116,9 @@ target_link_libraries(ed_segmenter ed_kinect)
108116
if(CATKIN_ENABLE_TESTING)
109117
catkin_add_gtest(test_furniture_fitting test/test_furniture_fit.cpp)
110118
target_link_libraries(test_furniture_fitting ed_kinect ${catkin_LIBRARIES})
119+
120+
catkin_add_gtest(test_laser_fitting test/test_laser_segmenter.cpp)
121+
target_link_libraries(test_laser_fitting ed_laser ${catkin_LIBRARIES})
111122
endif ()
112123

113124

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef ED_LASER_ENTITY_UPDATE_H_
2+
#define ED_LASER_ENTITY_UPDATE_H_
3+
4+
#include <ed/convex_hull.h>
5+
6+
/**
7+
* @brief collection structure for laser entities
8+
*/
9+
struct EntityUpdate
10+
{
11+
ed::ConvexHull chull;
12+
geo::Pose3D pose;
13+
std::string flag; // Temp for RoboCup 2015; todo: remove after
14+
};
15+
16+
#endif
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#ifndef ED_LASER_LASER_UPDATER_H_
2+
#define ED_LASER_LASER_UPDATER_H_
3+
4+
#include "ed/laser/entity_update.h"
5+
6+
#include <ed/convex_hull.h>
7+
#include <ed/init_data.h>
8+
#include <ed/world_model.h>
9+
10+
#include <geolib/sensors/LaserRangeFinder.h>
11+
12+
#include <map>
13+
#include <string>
14+
15+
typedef std::vector<unsigned int> ScanSegment;
16+
17+
class LaserUpdater
18+
{
19+
20+
public:
21+
/**
22+
* @brief Configure updater
23+
*
24+
* @param[in] config Configuration which may contain the following fields:
25+
* world_association_distance
26+
* min_segment_size_pixels
27+
* segment_depth_threshold
28+
* min_cluster_size
29+
* max_cluster_size
30+
* max_gap_size
31+
* fit_entities Whether or not to fit an entity (0 or 1)
32+
*/
33+
void configure(tue::Configuration& config);
34+
35+
/**
36+
* @brief update update the worldmodel based on a novel laserscan message.
37+
*
38+
* @param[in] world worldmodel to be updated
39+
* @param[in] sensor_ranges distances measured by the lrf
40+
* @param[in] sensor_pose pose of the lrf sensor at the time of the measurement
41+
* @param[in] timestamp timestamp of the lrf measurment
42+
* @param[out] req update request
43+
*/
44+
void update(const ed::WorldModel& world, std::vector<double>& sensor_ranges,
45+
const geo::Pose3D& sensor_pose, const double timestamp, ed::UpdateRequest& req);
46+
47+
/**
48+
* @brief configure the LRF model based on a laserscan message
49+
*
50+
* @param num_beams number of beams in the lrf model
51+
* @param angle_min angle corresponding to the first beam in radians
52+
* @param angle_max angle corresponding to the final beam in radians
53+
* @param range_min minimum distance that can be detected with the lrf in meters
54+
* @param range_max maximum distance that can be detected with the lrf in meters
55+
*/
56+
void configureLaserModel(uint num_beams, double angle_min, double angle_max, double range_min, double range_max)
57+
{
58+
lrf_model_.setNumBeams(num_beams);
59+
lrf_model_.setAngleLimits(angle_min, angle_max);
60+
lrf_model_.setRangeLimits(range_min, range_max);
61+
}
62+
63+
/**
64+
* @brief set the frame of the laser model
65+
*
66+
* @param frame_id frame id of the laser
67+
*/
68+
inline void setLaserFrame(const std::string& frame_id) { lrf_frame_ = frame_id; }
69+
70+
/**
71+
* @brief get the number of beams of the model
72+
*/
73+
unsigned int getNumBeams() { return lrf_model_.getNumBeams(); }
74+
75+
/**
76+
* @brief render the worldmodel as would be seen by the lrf.
77+
*
78+
* @param[in] sensor_pose pose of the lrf to be modeled in the world frame.
79+
* @param[in] world worldmodel
80+
* @param[out] model_ranges ranges of distances as would be seen by an lrf
81+
*/
82+
void renderWorld(const geo::Pose3D& sensor_pose, const ed::WorldModel& world, std::vector<double>& model_ranges);
83+
84+
// parameters
85+
int min_segment_size_pixels_; // in nr of laser points
86+
double world_association_distance_; // in m
87+
double segment_depth_threshold_;
88+
double min_cluster_size_;
89+
double max_cluster_size_;
90+
bool fit_entities_;
91+
int max_gap_size_;
92+
93+
private:
94+
/**
95+
* @brief associate: filter sensor information and remove ranges that can be associated with the worldmodel. Leaving only novel data.
96+
*
97+
* @param[in] sensor_ranges distances measured by the lrf
98+
* @param[in,out] model_ranges distances as predicted by the worldmodel. Will be filtered. (associated ranges have value 0.0)
99+
*/
100+
void associate(std::vector<double>& sensor_ranges, const std::vector<double>& model_ranges);
101+
102+
/**
103+
* @brief divide the sensor ranges into segments
104+
*/
105+
std::vector<ScanSegment> segment(const std::vector<double>& sensor_ranges);
106+
107+
/**
108+
* @brief convert a segment of ranges to a convex hull
109+
*/
110+
EntityUpdate segmentToConvexHull(const ScanSegment& segment, const geo::Pose3D& sensor_pose, const std::vector<double>& sensor_ranges);
111+
112+
// PARAMETERS
113+
geo::LaserRangeFinder lrf_model_;
114+
std::string lrf_frame_;
115+
116+
std::map<ed::UUID, geo::Pose3D> pose_cache;
117+
118+
};
119+
120+
#endif

0 commit comments

Comments
 (0)