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 <Eigen/Core>
41#include <pcl/point_cloud.h>
42#include <pcl/point_types.h>
43
44#include "std_msgs/msg/header.hpp"
45#include "sensor_msgs/msg/point_cloud2.hpp"
46#include "navmap_ros_interfaces/msg/nav_map.hpp"
47#include "navmap_ros_interfaces/msg/nav_map_layer.hpp"
48#include "nav_msgs/msg/occupancy_grid.hpp"
49
51
56namespace navmap_ros
57{
58
72constexpr uint8_t NO_INFORMATION = 255;
73constexpr uint8_t LETHAL_OBSTACLE = 254;
74constexpr uint8_t INSCRIBED_INFLATED_OBSTACLE = 253;
75constexpr uint8_t MAX_NON_OBSTACLE = 252;
76constexpr uint8_t FREE_SPACE = 0; // end of Costmap value semantics group
78
79// --------- NavMap <-> ROS message ---------
80
95navmap_ros_interfaces::msg::NavMap to_msg(
96 const navmap::NavMap & nm, const std_msgs::msg::Header & header);
97
103navmap_ros_interfaces::msg::NavMap to_msg(const navmap::NavMap & nm);
104
119 const navmap_ros_interfaces::msg::NavMap & msg,
120 std_msgs::msg::Header & header);
121
125navmap::NavMap from_msg(const navmap_ros_interfaces::msg::NavMap & msg);
126
142navmap_ros_interfaces::msg::NavMapLayer to_msg(
143 const navmap::NavMap & nm,
144 const std::string & layer,
145 const std_msgs::msg::Header & header);
146
150navmap_ros_interfaces::msg::NavMapLayer to_msg(
151 const navmap::NavMap & nm,
152 const std::string & layer);
153
171void from_msg(
172 const navmap_ros_interfaces::msg::NavMapLayer & msg,
173 navmap::NavMap & nm,
174 std_msgs::msg::Header & header);
175
179void from_msg(
180 const navmap_ros_interfaces::msg::NavMapLayer & msg,
181 navmap::NavMap & nm);
182
183// --------- OccupancyGrid <-> NavMap (shared vertices, per-NavCel layer) ---------
184
207 const nav_msgs::msg::OccupancyGrid & grid,
208 std_msgs::msg::Header & header);
209
213navmap::NavMap from_occupancy_grid(const nav_msgs::msg::OccupancyGrid & grid);
214
238nav_msgs::msg::OccupancyGrid to_occupancy_grid(
239 const navmap::NavMap & nm,
240 const std_msgs::msg::Header & header);
241
245nav_msgs::msg::OccupancyGrid to_occupancy_grid(const navmap::NavMap & nm);
246
254{
256 float resolution = 1.0;
257
259 float max_edge_len = 2.0;
260
262 float max_dz = 0.25f;
263
265 float max_slope_deg = 30.0f; // maximum slope w.r.t. vertical
266
268 float neighbor_radius = 2.0f; // search radius
269
271 int k_neighbors = 20; // k-NN alternative to radius
272
274 float min_area = 1e-6f; // minimum triangle area to avoid degenerates
275
277 bool use_radius = true;
278
280 float min_angle_deg = 20.0f; // minimum interior angle (deg) to avoid sliver triangles
281
283 int max_surfaces = 0; // 0 รณ <0 => no limits. >0 => Keep only N larger
284};
285
309 const pcl::PointCloud<pcl::PointXYZ> & input_points,
310 navmap_ros_interfaces::msg::NavMap & out_msg,
311 BuildParams params);
312
330 const sensor_msgs::msg::PointCloud2 & pc2,
331 navmap_ros_interfaces::msg::NavMap & out_msg,
332 BuildParams params);
333
334} // namespace navmap_ros
335
336#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:465
Conversions between core NavMap and ROS-level structures.
nav_msgs::msg::OccupancyGrid to_occupancy_grid(const navmap::NavMap &nm, const std_msgs::msg::Header &header)
Convert a navmap::NavMap back to nav_msgs::msg::OccupancyGrid.
Definition conversions.cpp:393
constexpr uint8_t NO_INFORMATION
Definition conversions.hpp:72
navmap::NavMap from_msg(const navmap_ros_interfaces::msg::NavMap &msg, std_msgs::msg::Header &header)
Reconstruct a core navmap::NavMap from the ROS transport message.
navmap_ros_interfaces::msg::NavMap to_msg(const navmap::NavMap &nm, const std_msgs::msg::Header &header)
Convert a core navmap::NavMap into its compact ROS transport message.
Definition conversions.cpp:70
constexpr uint8_t LETHAL_OBSTACLE
Definition conversions.hpp:73
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:1000
constexpr uint8_t MAX_NON_OBSTACLE
Definition conversions.hpp:75
constexpr uint8_t INSCRIBED_INFLATED_OBSTACLE
Definition conversions.hpp:74
constexpr uint8_t FREE_SPACE
Definition conversions.hpp:76
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:1364
navmap::NavMap from_occupancy_grid(const nav_msgs::msg::OccupancyGrid &grid, std_msgs::msg::Header &header)
Build a navmap::NavMap from a nav_msgs::msg::OccupancyGrid using a regular triangular surface with sh...
Definition conversions.cpp:313
Parameters controlling NavMap construction from unorganized points.
Definition conversions.hpp:254
float max_slope_deg
Maximum slope with respect to the vertical axis (degrees).
Definition conversions.hpp:265
float resolution
Target in-plane sampling resolution (meters) used by voxelization or gridding.
Definition conversions.hpp:256
int max_surfaces
Maximun surfaces to keep, ordenred by size.
Definition conversions.hpp:283
int k_neighbors
Alternative to radius: number of nearest neighbors (k-NN).
Definition conversions.hpp:271
float min_angle_deg
Minimum interior angle (degrees) to avoid sliver triangles.
Definition conversions.hpp:280
float max_dz
Maximum allowed vertical jump (meters) between vertices of a triangle.
Definition conversions.hpp:262
float min_area
Minimum triangle area (square meters) to reject degenerate faces.
Definition conversions.hpp:274
float neighbor_radius
Neighborhood radius (meters) for candidate connectivity.
Definition conversions.hpp:268
bool use_radius
If true, use radius-based neighborhoods; otherwise use k-NN.
Definition conversions.hpp:277
float max_edge_len
Maximum allowed edge length (meters) when forming triangles.
Definition conversions.hpp:259