Go to the documentation of this file.
17 #include <opencv2/highgui/highgui.hpp>
19 #include <ros/console.h>
32 for(
unsigned int i = 0; i < points.
size(); ++i)
36 cv::Mat filtered_depth_image;
46 for(
int y = 0; y < filtered_depth_image.rows; ++y)
48 for(
int x = 0; x < filtered_depth_image.cols; ++x)
50 float d = filtered_depth_image.at<
float>(y, x);
60 z_min = std::min<float>(z_min, p_map.
z);
61 z_max = std::max<float>(z_max, p_map.
z);
69 double h = z_max - z_min;
90 for (
unsigned int p = 0; p < u1.
chull.
points.size(); ++p)
96 for (
unsigned int p = 0; p < u2.
chull.
points.size(); ++p)
116 ROS_INFO(
"mergoverlapping chulls: nr of updates: %lu", updates.
size());
125 for (uint i = 0; i < updates.
size(); ++i)
135 for (uint j = 0; j < updates.
size(); ++j)
146 ROS_DEBUG(
"Collition item %i with %i", i, j);
147 ROS_DEBUG(
"Item %i: xyz: %.2f, %.2f, %.2f, z_min: %.2f, z_max: %.2f", i, u1.
pose_map.
t.
getX(), u1.
pose_map.
t.
getY(), u1.
pose_map.
t.
getZ(), u1.
chull.
z_min, u1.
chull.
z_max);
148 ROS_DEBUG(
"Item %i: xyz: %.2f, %.2f, %.2f, z_min: %.2f, z_max: %.2f", j, u2.
pose_map.
t.
getX(), u2.
pose_map.
t.
getY(), u2.
pose_map.
t.
getZ(), u2.
chull.
z_min, u2.
chull.
z_max);
149 collission_map[i].push_back(j);
156 for (uint i = 0; i < updates.
size(); ++i)
169 ROS_DEBUG_COND(it == collission_map[i].begin(),
"Merging entity %i and xx", i);
170 ROS_DEBUG(
"Merging entity %i and %i", i, *it);
176 ROS_DEBUG(
"Adding update of entity %i", i);
180 ROS_DEBUG(
"Skipping update %i because of collision", i);
208 cv::Mat filtered_depth_image;
214 const cv::Mat& depth =
image->getDepthImage();
222 if (!
req.area_description.empty())
228 bool fit_supporting_entity =
req.fit_supporting_entity;
233 area_description = it_area_descr->second;
234 fit_supporting_entity =
false;
237 area_description =
req.area_description;
247 if (i_space == std::string::npos)
249 entity_id = area_description;
253 area_name = area_description.
substr(0, i_space);
254 entity_id = area_description.
substr(i_space + 1);
264 res.
error <<
"No such entity: '" << entity_id.
str() <<
"'.";
267 else if (!e->has_pose())
269 res.
error <<
"Entity: '" << entity_id.
str() <<
"' has no pose.";
278 if (fit_supporting_entity)
297 new_pose = e->pose();
302 new_pose = e->pose();
310 fitZRP(*e->visual(), new_pose, *
image, sensor_pose_const, sensor_pose);
312 ROS_DEBUG_STREAM(
"Old sensor pose: " << sensor_pose_const);
313 ROS_DEBUG_STREAM(
"New sensor pose: " << sensor_pose);
319 if (!area_name.
empty())
324 if (it == e->volumes().
end())
326 res.
error <<
"No area '" << area_name <<
"' for entity '" << entity_id.
str() <<
"'.";
333 res.
error <<
"Could not load shape of area '" << area_name <<
"' for entity '" << entity_id.
str() <<
"'.";
346 filtered_depth_image =
image->getDepthImage().clone();
368 if (e->visual() || !e->has_pose() || e->convexHull().points.empty())
428 if (p_2d.x < 0 || p_2d.y < 0 || p_2d.x >= depth.cols || p_2d.y >= depth.rows)
434 ROS_INFO(
"Entity not associated and not seen in the frustum, while seeable");
436 float d = depth.at<
float>(p_2d);
437 if (d > 0 && d == d && -p_3d.
z < d)
439 ROS_INFO_STREAM(
"We can shoot a ray through the center(" << d <<
" > " << -p_3d.
z <<
"), removing entity " << e->id());
450 if (!area_description.
empty())
void cluster(const cv::Mat &depth_image, const geo::DepthCamera &cam_model, const geo::Pose3D &sensor_pose, std::vector< EntityUpdate > &clusters) const
EntityConstPtr getEntity(const ed::UUID &id) const
std::vector< unsigned int > pixel_indices
ed::UpdateRequest & update_req
collection structure for laser entities
void create(const std::vector< geo::Vec2f > &points, float z_min, float z_max, ConvexHull &chull, geo::Pose3D &pose)
void removeBackground(cv::Mat &depth_image, const ed::WorldModel &world, const geo::DepthCamera &cam, const geo::Pose3D &sensor_pose, double background_padding)
void associateAndUpdate(const std::vector< ed::EntityConstPtr > &entities, const rgbd::ImageConstPtr &image, const geo::Pose3D &sensor_pose, std::vector< EntityUpdate > &clusters, ed::UpdateRequest &req)
void removeEntity(const UUID &id)
bool estimateEntityPose(const FitterData &data, const ed::WorldModel &world, const ed::UUID &id, const geo::Pose3D &expected_pose, geo::Pose3D &fitted_pose, double max_yaw_change=M_PI) const
estimateEntityPose performs the entity pose estimation. Basically, tries to call estimateEntityPoseIm...
The FitterData struct contains the downprojected (hence 2D) sensor readings as well as the sensor pos...
virtual const Mesh & getMesh() const
void update(const UpdateRequest &req)
const_iterator begin() const
EntityIterator const_iterator
shared_ptr< const Entity > EntityConstPtr
const_iterator end() const
std::vector< EntityUpdate > entity_updates
bool collide(const ConvexHull &c1, const geo::Vector3 &pos1, const ConvexHull &c2, const geo::Vector3 &pos2, float xy_padding, float z_padding)
const geo::DepthCamera & getRasterizer() const
EntityUpdate mergeConvexHulls(const rgbd::Image &image, const geo::Pose3D &sensor_pose, const geo::DepthCamera &cam_model, const Segmenter &segmenter_, const EntityUpdate &u1, const EntityUpdate &u2)
mergeConvexHulls, creating a new convexHull around the two objects. Working in both XY and Z.
std::set< UUID > updated_entities
void calculatePointsWithin(const rgbd::Image &image, const geo::Shape &shape, const geo::Pose3D &shape_pose, cv::Mat &filtered_depth_image) const
void refitConvexHull(const rgbd::Image &image, const geo::Pose3D &sensor_pose, const geo::DepthCamera &cam_model, const Segmenter &segmenter_, EntityUpdate &up)
void setPose(const UUID &id, const geo::Pose3D &pose)
void fitZRP(const geo::Shape &shape, const geo::Pose3D &shape_pose, const rgbd::Image &image, const geo::Pose3D &sensor_pose, geo::Pose3D &updated_sensor_pose)
geo::Vec3T< T > project2Dto3D(int x, int y) const
std::vector< ed::UUID > removed_entity_ids
void createConvexPolygon(geo::Shape &shape, const std::vector< geo::Vec2 > &points, double height)
std::vector< geo::Vec3 > points
bool update(const ed::WorldModel &world, const rgbd::ImageConstPtr &image, const geo::Pose3D &sensor_pose, const UpdateRequest &req, UpdateResult &res)
cv::Point_< Tout > project3Dto2D(const geo::Vec3T< Tin > &p) const
void configureBeamModel(const image_geometry::PinholeCameraModel &cammodel)
configure the beam model (nr of data points and focal length) according to the camera you are using.
void processSensorData(const rgbd::Image &image, const geo::Pose3D &sensor_pose, FitterData &data) const
processSensorData pre-processes sensor data, i.e., performs a downprojection of the input depth image...
std::vector< EntityUpdate > mergeOverlappingConvexHulls(const rgbd::Image &image, const geo::Pose3D &sensor_pose, const geo::DepthCamera &cam_model, const Segmenter &segmenter_, const std::vector< EntityUpdate > &updates)
std::map< ed::UUID, std::string > id_to_area_description_
const std::string & str() const
std::vector< geo::Vec2f > points