NavMap
Loading...
Searching...
No Matches
conversions.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// This file is part of the project Easy Navigation (EasyNav in short)
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16
17#ifndef NAVMAP_ROS__CONVERSIONS_HPP_
18#define NAVMAP_ROS__CONVERSIONS_HPP_
19
38
39#include <string>
40#include <memory>
41#include <vector>
42#include <Eigen/Core>
43#include <pcl/point_cloud.h>
44#include <pcl/point_types.h>
45
46#include "sensor_msgs/msg/point_cloud2.hpp"
47#include "navmap_ros_interfaces/msg/nav_map.hpp"
48#include "navmap_ros_interfaces/msg/nav_map_layer.hpp"
49#include "nav_msgs/msg/occupancy_grid.hpp"
50
52
57namespace navmap_ros
58{
59
60// --------- NavMap <-> ROS message ---------
61
75navmap_ros_interfaces::msg::NavMap to_msg(
76 const navmap::NavMap & nm);
77
90navmap::NavMap from_msg(const navmap_ros_interfaces::msg::NavMap & msg);
91
106navmap_ros_interfaces::msg::NavMapLayer to_msg(
107 const navmap::NavMap & nm,
108 const std::string & layer);
109
126void from_msg(
127 const navmap_ros_interfaces::msg::NavMapLayer & msg,
128 navmap::NavMap & nm);
129
130// --------- OccupancyGrid <-> NavMap (shared vertices, per-NavCel layer) ---------
131
152navmap::NavMap from_occupancy_grid(const nav_msgs::msg::OccupancyGrid & grid);
153
177nav_msgs::msg::OccupancyGrid to_occupancy_grid(const navmap::NavMap & nm);
178
186{
188 Eigen::Vector3f seed = {0.0, 0.0, 0.0};
189
191 float resolution = 1.0;
192
194 float max_edge_len = 2.0;
195
197 float max_dz = 0.25f;
198
200 float max_slope_deg = 30.0f; // maximum slope w.r.t. vertical
201
203 float neighbor_radius = 2.0f; // search radius
204
206 int k_neighbors = 20; // k-NN alternative to radius
207
209 float min_area = 1e-6f; // minimum triangle area to avoid degenerates
210
212 bool use_radius = true;
213
215 float min_angle_deg = 20.0f; // minimum interior angle (deg) to avoid sliver triangles
216};
217
241 const pcl::PointCloud<pcl::PointXYZ> & input_points,
242 navmap_ros_interfaces::msg::NavMap & out_msg,
243 BuildParams params);
244
262 const sensor_msgs::msg::PointCloud2 & pc2,
263 navmap_ros_interfaces::msg::NavMap & out_msg,
264 BuildParams params);
265
266} // namespace navmap_ros
267
268#endif // NAVMAP_ROS__CONVERSIONS_HPP_
Core container and data structures for EasyNav navigable meshes.
Main container for navigable surfaces, geometry, and layers.
Definition NavMap.hpp:434
Conversions between core NavMap and ROS-level structures.
nav_msgs::msg::OccupancyGrid to_occupancy_grid(const navmap::NavMap &nm)
Convert a navmap::NavMap back to nav_msgs::msg::OccupancyGrid.
Definition conversions.cpp:351
navmap::NavMap from_points(const pcl::PointCloud< pcl::PointXYZ > &input_points, navmap_ros_interfaces::msg::NavMap &out_msg, BuildParams params)
Build a NavMap surface from a PCL point cloud.
Definition conversions.cpp:1091
navmap_ros_interfaces::msg::NavMap to_msg(const navmap::NavMap &nm)
Convert a core navmap::NavMap into its compact ROS transport message.
Definition conversions.cpp:73
navmap::NavMap from_msg(const navmap_ros_interfaces::msg::NavMap &msg)
Reconstruct a core navmap::NavMap from the ROS transport message.
navmap::NavMap from_pointcloud2(const sensor_msgs::msg::PointCloud2 &pc2, navmap_ros_interfaces::msg::NavMap &out_msg, BuildParams params)
Build a NavMap surface from a ROS sensor_msgs::msg::PointCloud2.
Definition conversions.cpp:1336
navmap::NavMap from_occupancy_grid(const nav_msgs::msg::OccupancyGrid &grid)
Build a navmap::NavMap from a nav_msgs::msg::OccupancyGrid using a regular triangular surface with sh...
Definition conversions.cpp:277
Parameters controlling NavMap construction from unorganized points.
Definition conversions.hpp:186
float max_slope_deg
Maximum slope with respect to the vertical axis (degrees).
Definition conversions.hpp:200
float resolution
Target in-plane sampling resolution (meters) used by voxelization or gridding.
Definition conversions.hpp:191
int k_neighbors
Alternative to radius: number of nearest neighbors (k-NN).
Definition conversions.hpp:206
float min_angle_deg
Minimum interior angle (degrees) to avoid sliver triangles.
Definition conversions.hpp:215
float max_dz
Maximum allowed vertical jump (meters) between vertices of a triangle.
Definition conversions.hpp:197
Eigen::Vector3f seed
Seed position (world frame) used by region growing or initial search heuristics.
Definition conversions.hpp:188
float min_area
Minimum triangle area (square meters) to reject degenerate faces.
Definition conversions.hpp:209
float neighbor_radius
Neighborhood radius (meters) for candidate connectivity.
Definition conversions.hpp:203
bool use_radius
If true, use radius-based neighborhoods; otherwise use k-NN.
Definition conversions.hpp:212
float max_edge_len
Maximum allowed edge length (meters) when forming triangles.
Definition conversions.hpp:194