39 #include <boost/uuid/random_generator.hpp> 40 #include <boost/uuid/uuid.hpp> 41 #include <boost/uuid/uuid_io.hpp> 43 #include <geometry_msgs/PointStamped.h> 44 #include <geometry_msgs/Vector3.h> 45 #include <visualization_msgs/MarkerArray.h> 54 #include <mesh_msgs/MeshGeometryStamped.h> 58 #include <visualization_msgs/Marker.h> 67 , private_nh(
"~/mesh_map/")
70 , layer_loader(
"mesh_map",
"mesh_map::AbstractLayer")
99 new dynamic_reconfigure::Server<mesh_map::MeshMapConfig>(
private_nh));
114 mesh_io_ptr = std::shared_ptr<lvr2::AttributeMeshIOBase>(
128 mesh_io_ptr = std::shared_ptr<lvr2::AttributeMeshIOBase>(hdf_5_mesh_io);
151 <<
mesh_ptr->numFaces() <<
" faces and " 152 <<
mesh_ptr->numEdges() <<
" edges.");
154 adaptor_ptr = std::make_unique<NanoFlannMeshAdaptor>(*mesh_ptr);
170 boost::uuids::random_generator gen;
171 boost::uuids::uuid uuid = gen();
172 uuid_str = boost::uuids::to_string(uuid);
176 if (face_normals_opt)
183 ROS_INFO_STREAM(
"No face normals found in the given map file, computing them...");
198 if (vertex_normals_opt)
205 ROS_INFO_STREAM(
"No vertex normals found in the given map file, computing them...");
222 if (edge_distances_opt)
272 ROS_WARN_STREAM(
"No layer plugins configured! - Use the param \"layers\" " 273 "in the namespace \"" 275 <<
"\". \"layers\" must be must be a list of " 276 "tuples with a name and a type.");
282 for (
int i = 0; i < plugin_param_list.
size(); i++)
286 std::string name = elem[
"name"];
287 std::string type = elem[
"type"];
293 ROS_ERROR_STREAM(
"The plugin \"" << name <<
"\" has already been loaded! Names must be unique!");
308 std::pair<std::string, typename mesh_map::AbstractLayer::Ptr> elem(name, plugin_ptr);
314 << type <<
"\" has been loaded successfully under the name \"" << name <<
"\".");
318 ROS_ERROR_STREAM(
"Could not load the layer plugin with the name \"" << name <<
"\" and the type \"" << type
326 "has to be a list of structs " 327 <<
"with fields \"name\" and \"type\"!");
337 std::lock_guard<std::mutex> lock(
layer_mtx);
346 auto layer_iter =
layers.begin();
347 for (; layer_iter !=
layers.end(); layer_iter++)
350 lethals.insert(layer_iter->second->lethals().begin(), layer_iter->second->lethals().end());
352 if (layer_iter->first == layer_name)
357 layer_iter->second->defaultValue(), layer_iter->first,
360 if (layer_iter !=
layers.end())
365 for (; layer_iter !=
layers.end(); layer_iter++)
370 lethals.insert(layer_iter->second->lethals().begin(), layer_iter->second->lethals().end());
373 layer_iter->second->defaultValue(), layer_iter->first,
389 std::shared_ptr<mesh_map::MeshMap>
map(
this);
393 auto& layer_plugin =
layer.second;
394 const auto& layer_name =
layer.first;
396 auto callback = [
this](
const std::string& layer_name) {
layerChanged(layer_name); };
400 ROS_ERROR_STREAM(
"Could not initialize the layer plugin with the name \"" << layer_name <<
"\"!");
404 std::set<lvr2::VertexHandle> empty;
405 layer_plugin->updateLethal(
lethals, empty);
406 if (!layer_plugin->readLayer())
408 layer_plugin->computeLayer();
411 lethal_indices[layer_name].insert(layer_plugin->lethals().begin(), layer_plugin->lethals().end());
412 lethals.insert(layer_plugin->lethals().begin(), layer_plugin->lethals().end());
421 float combined_min = std::numeric_limits<float>::max();
422 float combined_max = std::numeric_limits<float>::min();
429 const auto& costs =
layer.second->costs();
432 const float norm = max - min;
434 const float norm_factor = factor / norm;
435 ROS_INFO_STREAM(
"Layer \"" <<
layer.first <<
"\" max value: " << max <<
" min value: " << min <<
" norm: " << norm
436 <<
" factor: " << factor <<
" norm factor: " << norm_factor);
440 for (
auto vH :
mesh_ptr->vertices())
442 const float cost = costs.
containsKey(vH) ? costs[vH] : default_value;
443 if (std::isnan(cost))
446 if (std::isfinite(cost))
448 combined_max = std::max(combined_max,
vertex_costs[vH]);
449 combined_min = std::min(combined_min,
vertex_costs[vH]);
456 const float combined_norm = combined_max - combined_min;
460 vertex_costs[vH] = std::numeric_limits<float>::infinity();
471 std::array<lvr2::VertexHandle, 2> eH_vHs =
mesh_ptr->getVerticesOfEdge(eH);
476 if (
config.layer_factor != 0)
487 float vertex_factor =
config.layer_factor * cost_diff;
488 if (std::isnan(vertex_factor))
490 <<
" vertex_factor:" << vertex_factor <<
" cost_diff:" << cost_diff);
500 ROS_INFO(
"Successfully combined costs!");
505 int size = lethals.size();
506 std::vector<std::vector<lvr2::VertexHandle>> contours;
508 for (
auto contour : contours)
510 lethals.insert(contour.begin(), contour.end());
512 ROS_INFO_STREAM(
"Found " << lethals.size() - size <<
" lethal vertices as contour vertices");
519 std::vector<std::vector<lvr2::VertexHandle>> tmp_contours;
521 array<lvr2::OptionalFaceHandle, 2> facepair;
523 for (
auto eHStart :
mesh_ptr->edges())
530 facepair =
mesh_ptr->getFacesOfEdge(eHStart);
533 if ((!facepair[0] || !facepair[1]) && !usedEdges[eHStart])
536 vector<lvr2::VertexHandle> contour;
538 array<lvr2::VertexHandle, 2> vertexPair =
mesh_ptr->getVerticesOfEdge(eHStart);
540 vector<lvr2::EdgeHandle> curEdges;
543 bool vertex_flag =
false;
549 usedEdges.
insert(eHTemp,
true);
550 local_usedEdges.
insert(eHTemp,
true);
552 vertexPair =
mesh_ptr->getVerticesOfEdge(eHTemp);
554 if (vH != vertexPair[0])
558 else if (vH != vertexPair[1])
564 usedVertices.
insert(vH,
true);
566 contour.push_back(vH);
567 mesh_ptr->getEdgesOfVertex(vH, curEdges);
570 for (
auto eHT : curEdges)
572 if (!usedEdges[eHT] && !local_usedEdges[eHT])
574 facepair =
mesh_ptr->getFacesOfEdge(eHT);
575 if (!facepair[0] || !facepair[1])
585 if (contour.size() > min_contour_size)
587 contours.push_back(contour);
602 const std::array<lvr2::VertexHandle, 3>& vertices,
603 const std::array<float, 3>& barycentric_coords)
612 if (a) vec += a.get() * barycentric_coords[0];
613 if (b) vec += b.get() * barycentric_coords[1];
614 if (c) vec += c.get() * barycentric_coords[2];
615 if (std::isfinite(vec.
x) && std::isfinite(vec.
y) && std::isfinite(vec.
z))
622 ROS_ERROR_THROTTLE(0.3,
"vector map does not contain any of the corresponding vectors");
628 const std::array<float, 3>& barycentric_coords)
634 const std::array<lvr2::VertexHandle, 3>& vertices,
635 const std::array<float, 3>& barycentric_coords)
637 const auto& a = costs.
get(vertices[0]);
638 const auto& b = costs.
get(vertices[1]);
639 const auto& c = costs.
get(vertices[2]);
643 std::array<float, 3> costs = { a.
get(), b.get(), c.get() };
646 return std::numeric_limits<float>::quiet_NaN();
651 visualization_msgs::Marker marker;
652 marker.header.frame_id =
mapFrame();
656 marker.type = visualization_msgs::Marker::SPHERE;
657 marker.action = visualization_msgs::Marker::ADD;
658 geometry_msgs::Vector3 scale;
662 marker.scale = scale;
664 geometry_msgs::Pose
p;
665 p.position.x = pos.
x;
666 p.position.y = pos.
y;
667 p.position.z = pos.
z;
669 marker.color =
color;
674 const std::string& name)
676 const auto& vertices =
mesh_ptr->getVerticesOfFace(face_handle);
677 visualization_msgs::Marker marker;
678 marker.header.frame_id =
mapFrame();
682 marker.type = visualization_msgs::Marker::TRIANGLE_LIST;
683 marker.action = visualization_msgs::Marker::ADD;
684 geometry_msgs::Vector3 scale;
688 marker.scale = scale;
690 for (
auto vertex : vertices)
692 auto& pos =
mesh_ptr->getVertexPosition(vertex);
693 geometry_msgs::Point
p;
697 marker.points.push_back(p);
698 marker.colors.push_back(color);
705 const bool publish_face_vectors)
722 auto opt_vec_map = layer->vectorMap();
726 const auto& vecs = opt_vec_map.
get();
729 auto opt_val = vertex_vectors.
get(vH);
730 vertex_vectors.
insert(vH, opt_val ? opt_val.get() + vecs[vH] : vecs[vH]);
731 for (
auto fH :
mesh_ptr->getFacesOfVertex(vH))
732 vector_field_faces[fH]++;
735 for (
auto fH : vector_field_faces)
737 if (vector_field_faces[fH] != 3)
740 const auto& vertices =
mesh_ptr->getVertexPositionsOfFace(fH);
741 const auto& vertex_handles =
mesh_ptr->getVerticesOfFace(fH);
743 std::array<float, 3> barycentric_coords;
747 auto opt_val = face_vectors.
get(fH);
748 auto vec_at = layer->vectorAt(vertex_handles, barycentric_coords);
751 face_vectors.
insert(fH, opt_val ? opt_val.get() + vec_at : vec_at);
761 const std::function<
float(
float)>& cost_function,
const bool publish_face_vectors)
767 visualization_msgs::Marker vector_field;
769 geometry_msgs::Pose pose;
770 pose.position.x = pose.position.y = pose.position.z = 0;
771 pose.orientation.x = pose.orientation.y = pose.orientation.z = 0;
772 pose.orientation.w = 1;
773 vector_field.pose = pose;
775 vector_field.type = visualization_msgs::Marker::LINE_LIST;
776 vector_field.header.frame_id =
mapFrame();
778 vector_field.ns = name;
779 vector_field.scale.x = 0.01;
780 vector_field.color.a = 1;
783 vector_field.colors.reserve(2 *
vector_map.numValues());
784 vector_field.points.reserve(2 *
vector_map.numValues());
786 unsigned int cnt = 0;
787 unsigned int faces = 0;
790 std::set<lvr2::FaceHandle> complete_faces;
794 const auto& dir_vec = vector_map[vH];
795 const float len2 = dir_vec.length2();
796 if (len2 == 0 || !std::isfinite(len2))
802 auto u =
mesh.getVertexPosition(vH);
803 auto v = u + dir_vec * 0.1;
808 if (!std::isfinite(u.x) || !std::isfinite(u.y) || !std::isfinite(u.z) || !std::isfinite(v.x) ||
809 !std::isfinite(v.y) || !std::isfinite(v.z))
813 vector_field.points.push_back(
toPoint(u));
814 vector_field.points.push_back(
toPoint(v));
816 const float value = cost_function ? cost_function(values[vH]) : values[vH];
818 vector_field.colors.push_back(color);
819 vector_field.colors.push_back(color);
827 for (
auto fH :
mesh.getFacesOfVertex(vH))
829 if (++vector_field_faces[fH] == 3)
832 complete_faces.
insert(fH);
842 size_t invalid_cnt = 0;
855 if (publish_face_vectors)
857 vector_field.points.reserve(faces + cnt);
859 for (
auto fH : complete_faces)
861 const auto& vertices =
mesh.getVertexPositionsOfFace(fH);
862 const auto& vertex_handles =
mesh.getVerticesOfFace(fH);
864 std::array<float, 3> barycentric_coords;
868 boost::optional<mesh_map::Vector> dir_opt =
directionAtPosition(vector_map, vertex_handles, barycentric_coords);
871 const float& cost =
costAtPosition(values, vertex_handles, barycentric_coords);
872 const float& value = cost_function ? cost_function(cost) : cost;
879 auto v = u + dir_opt.get() * 0.1;
881 if (!std::isfinite(u.x) || !std::isfinite(u.y) || !std::isfinite(u.z) || !std::isfinite(v.x) ||
882 !std::isfinite(v.y) || !std::isfinite(v.z))
889 vector_field.points.push_back(
toPoint(u));
890 vector_field.points.push_back(
toPoint(v));
893 vector_field.colors.push_back(color);
894 vector_field.colors.push_back(color);
908 ROS_INFO_STREAM(
"Published vector field \"" << name <<
"\" with " << cnt <<
" elements.");
913 const auto& vertices =
mesh_ptr->getVerticesOfFace(face);
915 mesh_ptr->getVertexPosition(vertices[2]), dist, 0.0001);
918 boost::optional<std::tuple<lvr2::FaceHandle, std::array<Vector, 3>, std::array<float, 3>>>
921 const float& max_radius,
const float& max_dist)
923 std::list<lvr2::FaceHandle> possible_faces;
924 possible_faces.push_back(face);
925 std::list<lvr2::FaceHandle>::iterator face_iter = possible_faces.begin();
928 const auto& start_vertices =
mesh_ptr->getVertexPositionsOfFace(face);
929 for (
auto vertex : start_vertices)
935 float vertex_center_max = 0;
936 for (
auto vertex : start_vertices)
938 vertex_center_max = std::max(vertex_center_max, vertex.distance(center));
941 float ext_radius = max_radius + vertex_center_max;
942 float max_radius_sq = ext_radius * ext_radius;
945 in_list_map.
insert(face,
true);
947 std::array<float, 3> bary_coords;
949 while (possible_faces.end() != face_iter)
951 const auto& vertices =
mesh_ptr->getVertexPositionsOfFace(*face_iter);
955 return std::make_tuple(*face_iter, vertices, bary_coords);
959 const auto& vertices =
mesh_ptr->getVerticesOfFace(*face_iter);
960 for (
auto vertex : vertices)
966 const auto& nn_faces =
mesh_ptr->getFacesOfVertex(vertex);
967 for (
auto nn_face : nn_faces)
971 possible_faces.push_back(nn_face);
972 in_list_map.
insert(nn_face,
true);
991 std::array<float, 3> bary_coords;
1000 auto search_res = *search_res_opt;
1001 face = std::get<0>(search_res);
1002 std::array<Vector, 3> vertices = std::get<1>(search_res);
1003 bary_coords = std::get<2>(search_res);
1016 std::array<lvr2::VertexHandle, 3> handels =
mesh_ptr->getVerticesOfFace(face);
1020 dir +=
layer.second->vectorAt(handels, bary_coords);
1023 pos += dir * step_size;
1033 return std::get<0>(*search_result);
1037 boost::optional<std::tuple<lvr2::FaceHandle, std::array<mesh_map::Vector , 3>,
1039 Vector& position,
const float& max_dist)
1043 auto vH = vH_opt.unwrap();
1044 float min_triangle_position_distance = std::numeric_limits<float>::max();
1045 std::array<Vector, 3> vertices;
1046 std::array<float, 3> bary_coords;
1048 for(
auto fH :
mesh_ptr->getFacesOfVertex(vH))
1050 const auto& tmp_vertices =
mesh_ptr->getVertexPositionsOfFace(fH);
1052 std::array<float, 3> tmp_bary_coords;
1054 && std::fabs(dist) < max_dist)
1056 return std::make_tuple(fH, tmp_vertices, tmp_bary_coords);
1059 float triangle_dist = 0;
1060 triangle_dist += (vertices[0] - position).length2();
1061 triangle_dist += (vertices[1] - position).length2();
1062 triangle_dist += (vertices[2] - position).length2();
1063 if(triangle_dist < min_triangle_position_distance)
1065 min_triangle_position_distance = triangle_dist;
1067 vertices = tmp_vertices;
1068 bary_coords = tmp_bary_coords;
1073 return std::make_tuple(opt_fH.
unwrap(), vertices, bary_coords);
1084 float querry_point[3] = {pos.
x, pos.
y, pos.
z};
1087 size_t num_results =
kd_tree_ptr->knnSearch(&querry_point[0], 1, &ret_index, &out_dist_sqr);
1093 geometry_msgs::Point
p;
1103 std::array<float, 3>& barycentric_coords,
float& dist)
1105 const auto& face =
mesh_ptr->getVertexPositionsOfFace(triangle);
1116 const auto& face =
mesh_ptr->getVertexPositionsOfFace(triangle);
1121 const Vector& v2,
float& t,
float& u,
float& v,
Vector& p)
1129 float denom = N.
dot(N);
1134 float NdotRayDirection = N.
dot(dir);
1135 if (fabs(NdotRayDirection) < kEpsilon)
1139 float d = N.
dot(v0);
1142 t = (N.
dot(orig) + d) / NdotRayDirection;
1156 C = edge0.
cross(vp0);
1163 C = edge1.
cross(vp1);
1164 if ((u = N.
dot(C)) < 0)
1170 C = edge2.
cross(vp2);
1171 if ((v = N.
dot(C)) < 0)
1206 VertexColorMapOpt vertex_colors_opt = this->
mesh_io_ptr->getDenseAttributeMap<VertexColorMap>(
"vertex_colors");
1207 if (vertex_colors_opt)
1209 const VertexColorMap
colors = vertex_colors_opt.get();
1210 mesh_msgs::MeshVertexColorsStamped msg;
1214 msg.mesh_vertex_colors.vertex_colors.reserve(colors.numValues());
1215 for (
auto vH : colors)
1217 std_msgs::ColorRGBA color_rgba;
1218 const auto& color_array = colors[vH];
1220 color_rgba.r = color_array[0] / 255.0;
1221 color_rgba.g = color_array[1] / 255.0;
1222 color_rgba.b = color_array[2] / 255.0;
1223 msg.mesh_vertex_colors.vertex_colors.push_back(color_rgba);
1241 if (cfg.cost_limit !=
config.cost_limit)
boost::optional< std::tuple< lvr2::FaceHandle, std::array< Vector, 3 >, std::array< float, 3 > > > searchNeighbourFaces(const Vector &pos, const lvr2::FaceHandle &face, const float &max_radius, const float &max_dist)
FaceHandle unwrap() const
bool meshAhead(Vector &vec, lvr2::FaceHandle &face, const float &step_width)
void open(std::string filename)
ros::Publisher mesh_geometry_pub
publisher for the mesh geometry
bool loadLayerPlugins()
Loads all configures layer plugins.
void publishDebugPoint(const Vector pos, const std_msgs::ColorRGBA &color, const std::string &name)
Publishes a position as marker. Used for debug purposes.
T linearCombineBarycentricCoords(const std::array< T, 3 > &vertex_properties, const std::array< float, 3 > &barycentric_coords)
Computes a linear combination of vertex properties and the barycentric coordinates.
pluginlib::ClassLoader< mesh_map::AbstractLayer > layer_loader
plugin class loader for for the layer plugins
bool readMap()
Reads in the mesh geometry, normals and cost values and publishes all as mesh_msgs.
#define ROS_ERROR_STREAM_THROTTLE(period, args)
const lvr2::HalfEdgeMesh< Vector > & mesh()
Returns the stored mesh.
ros::NodeHandle private_nh
private node handle within the mesh map namespace
boost::optional< std::tuple< lvr2::FaceHandle, std::array< mesh_map::Vector, 3 >, std::array< float, 3 > > > searchContainingFace(Vector &position, const float &max_dist)
Searches for a triangle which contains the given position with respect to the maximum distance...
mesh_map::AbstractLayer::Ptr layer(const std::string &layer_name)
returns a shared pointer to the specified layer
std::set< lvr2::VertexHandle > lethals
all impassable vertices
std_msgs::ColorRGBA getRainbowColor(const float value)
map value to color on color rainbow
bool barycentricCoords(const Vector &p, const Vector &v0, const Vector &v1, const Vector &v2, float &u, float &v, float &w)
Computes the barycentric coordinates u, v,q of a query point p onto the triangle v0, v1, v2.
std::string srv_password
login password to connect to the server
bool rayTriangleIntersect(const Vector &orig, const Vector &dir, const Vector &v0, const Vector &v1, const Vector &v2, float &t, float &u, float &v, Vector &p)
bool inTriangle(const Vector &pos, const lvr2::FaceHandle &face, const float &dist)
return true if the given position lies inside the triangle with respect to the given maximum distance...
lvr2::DenseEdgeMap< float > edge_weights
edge weights
std::string srv_username
login username to connect to the server
bool initLayerPlugins()
Initialized all loaded layer plugins.
void combineVertexCosts()
A method which combines all layer costs with the respective weightings.
DenseVertexMap< Normal< typename BaseVecT::CoordType > > calcVertexNormals(const BaseMesh< BaseVecT > &mesh, const FaceMap< Normal< typename BaseVecT::CoordType >> &normals, const PointsetSurface< BaseVecT > &surface)
boost::shared_ptr< T > createInstance(const std::string &lookup_name)
lvr2::OptionalVertexHandle getNearestVertexHandle(const mesh_map::Vector &pos)
Return and optional vertex handle of to the closest vertex to the given position. ...
std::unique_ptr< NanoFlannMeshAdaptor > adaptor_ptr
k-d tree nano flann mesh adaptor to access mesh data
const std::string & getMessage() const
void publishCostLayers()
Publishes all layer costs as mesh_msgs/VertexCosts.
const geometry_msgs::Point toPoint(const Vector &vec)
Converts a vector to a ROS geometry_msgs/Point message.
bool projectedBarycentricCoords(const Vector &p, const lvr2::FaceHandle &triangle, std::array< float, 3 > &barycentric_coords, float &dist)
Computes the projected barycentric coordinates, it implements Heidrich's method See https://www...
DenseFaceMap< Normal< typename BaseVecT::CoordType > > calcFaceNormals(const BaseMesh< BaseVecT > &mesh)
std::string srv_url
server url
BaseVector< CoordT > cross(const BaseVector &other) const
bool first_config
first reconfigure call
lvr2::Hdf5IO< lvr2::hdf5features::ArrayIO, lvr2::hdf5features::ChannelIO, lvr2::hdf5features::VariantChannelIO, lvr2::hdf5features::MeshIO > HDF5MeshIO
bool projectedBarycentricCoords(const Vector &p, const std::array< Vector, 3 > &vertices, std::array< float, 3 > &barycentric_coords, float &dist)
Computes projected barycentric coordinates and whether the query point lies inside or outside the giv...
const mesh_msgs::MeshVertexCostsStamped toVertexCostsStamped(const lvr2::VertexMap< float > &costs, const size_t num_values, const float default_value, const std::string &name, const std::string &frame_id, const std::string &uuid, const ros::Time &stamp=ros::Time::now())
std::shared_ptr< lvr2::HalfEdgeMesh< Vector > > mesh_ptr
bool resetLayers()
Resets all layers.
void publishVectorField(const std::string &name, const lvr2::DenseVertexMap< lvr2::BaseVector< float >> &vector_map, const bool publish_face_vectors=false)
Publishes a vector field as visualisation_msgs/Marker.
lvr2::DenseVertexMap< float > vertex_costs
combined layer costs
const lvr2::DenseFaceMap< Normal > & faceNormals()
Returns the mesh's triangle normals.
std::vector< std::pair< std::string, mesh_map::AbstractLayer::Ptr > > layers
vector of name and layer instances
#define ROS_DEBUG_STREAM_THROTTLE(period, args)
void reserve(size_t newCap)
lvr2::DenseVertexMap< mesh_map::Vector > vector_map
stored vector map to share between planner and controller
ros::Publisher vertex_costs_pub
publisher for vertex costs
void publishVertexColors()
bool containsKey(HandleT key) const final
OutMapT< typename InMapT::HandleType, std::result_of_t< MapF(typename InMapT::ValueType)> > map(const InMapT &mapIn, MapF func)
lvr2::OptionalFaceHandle getContainingFace(Vector &position, const float &max_dist)
Searches for a triangle which contains the given position with respect to the maximum distance...
std::shared_ptr< lvr2::AttributeMeshIOBase > mesh_io_ptr
CoordT distance2(const BaseVector &other) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void publish(const boost::shared_ptr< M > &message) const
void getMinMax(const lvr2::VertexMap< float > &map, float &min, float &max)
Function to compute the minimum and maximum of a cost layer.
boost::optional< ValueT > insert(HandleT key, const ValueT &value) final
const std::string & mapFrame()
Returns the map frame / coordinate system id.
Normal< CoordT > normalized() const
void publishCombinedVectorField()
Publishes the vector field as visualisation_msgs/Marker.
#define ROS_FATAL_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
#define ROS_ERROR_THROTTLE(period,...)
ros::Publisher vertex_colors_pub
publisher for vertex colors
void setVectorMap(lvr2::DenseVertexMap< mesh_map::Vector > &vector_map)
Stores the given vector map.
DenseEdgeMap< float > calcVertexDistances(const BaseMesh< BaseVecT > &mesh)
void reconfigureCallback(mesh_map::MeshMapConfig &config, uint32_t level)
reconfigure callback function which is called if a dynamic reconfiguration were triggered.
double min(double a, double b)
ros::Publisher marker_pub
publisher for the debug markers
void setBoundingBox(float min_x, float min_y, float min_z, const float max_x, const float max_y, const float max_z)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::map< std::string, std::set< lvr2::VertexHandle > > lethal_indices
each layer maps to a set of impassable indices
lvr2::DenseFaceMap< Normal > face_normals
triangle normals
void findContours(std::vector< std::vector< lvr2::VertexHandle >> &contours, int min_contour_size)
Computes contours.
#define ROS_WARN_STREAM(args)
std::string global_frame
global frame / coordinate system id
bool map_loaded
indicates whether the map has been loaded
bool containsKey(HandleT key) const final
lvr2::BaseVector< float > Vector
use vectors with datatype folat
bool barycentricCoords(const Vector &p, const lvr2::FaceHandle &triangle, float &u, float &v, float &w)
void layerChanged(const std::string &layer_name)
Callback function which is called from inside a layer plugin if cost values change.
tf2_ros::Buffer * tf_buffer
#define ROS_INFO_STREAM(args)
const std::string & getNamespace() const
MeshMapConfig config
current mesh map configuration
boost::optional< ValueT > insert(HandleT key, const ValueT &value) final
lvr2::DenseVertexMap< Normal > vertex_normals
vertex normals
lvr2::DenseEdgeMap< float > edge_distances
vertex distance for each edge
lvr2::DenseVertexMap< bool > invalid
const lvr2::DenseVertexMap< float > & vertexCosts()
Returns the stored combined costs.
MeshMap(tf2_ros::Buffer &tf)
void publishDebugFace(const lvr2::FaceHandle &face_handle, const std_msgs::ColorRGBA &color, const std::string &name)
Publishes a triangle as marker. Used for debug purposes.
ros::Publisher vector_field_pub
publisher for the stored vector field
std::mutex layer_mtx
layer mutex to handle simultaneous layer changes
boost::optional< Vector > directionAtPosition(const lvr2::VertexMap< lvr2::BaseVector< float >> &vector_map, const std::array< lvr2::VertexHandle, 3 > &vertices, const std::array< float, 3 > &barycentric_coords)
std_msgs::ColorRGBA color(const float &r, const float &g, const float &b, const float &a=1.0)
Function to build std_msgs color instances.
const std::string getGlobalFrameID()
Returns the global frame / coordinate system id string.
float costAtPosition(const lvr2::DenseVertexMap< float > &costs, const std::array< lvr2::VertexHandle, 3 > &vertices, const std::array< float, 3 > &barycentric_coords)
boost::optional< DenseVertexMap< ValueT > > DenseVertexMapOptional
void findLethalByContours(const int &min_contour_size, std::set< lvr2::VertexHandle > &lethals)
Compute all contours and returns the corresponding vertices to use these as lethal vertices...
__kf_device__ float norm(const float3 &v)
std::unique_ptr< KDTree > kd_tree_ptr
k-d tree to query mesh vertices in logarithmic time
CoordT dot(const BaseVector &other) const
boost::shared_ptr< dynamic_reconfigure::Server< mesh_map::MeshMapConfig > > reconfigure_server_ptr
shared pointer to dynamic reconfigure server
std::string uuid_str
uuid for the load mesh map
#define ROS_ERROR_STREAM(args)
dynamic_reconfigure::Server< mesh_map::MeshMapConfig >::CallbackType config_callback
dynamic reconfigure callback function binding
boost::optional< ValueT &> get(HandleT key) final
double max(double a, double b)
void publishVertexCosts(const lvr2::VertexMap< float > &costs, const std::string &name)
Publishes the given vertex map as mesh_msgs/VertexCosts, e.g. to visualize these. ...
bool inTriangle(const Vector &p, const Vector &v0, const Vector &v1, const Vector &v2, const float &max_dist, const float &epsilon)
Computes whether a points lies inside or outside a triangle with respect to a maximum distance while ...
std::map< std::string, mesh_map::AbstractLayer::Ptr > layer_names
mapping from name to layer instance