30 #ifndef PLANNER_CSPACE_PLANNER_3D_GRID_METRIC_CONVERTER_H 31 #define PLANNER_CSPACE_PLANNER_3D_GRID_METRIC_CONVERTER_H 37 #include <costmap_cspace_msgs/MapMetaData3D.h> 38 #include <nav_msgs/Path.h> 47 namespace grid_metric_converter
51 const costmap_cspace_msgs::MapMetaData3D& map_info,
52 const T x,
const T y,
const T yaw,
53 float& gx,
float& gy,
float& gyaw)
56 std::is_same<float, T>() || std::is_same<int, T>(),
"T must be float or int");
58 gx = (x + 0.5) * map_info.linear_resolution + map_info.origin.position.x;
59 gy = (y + 0.5) * map_info.linear_resolution + map_info.origin.position.y;
60 gyaw = yaw * map_info.angular_resolution;
63 const costmap_cspace_msgs::MapMetaData3D& map_info,
64 int& x,
int& y,
int& yaw,
65 const float gx,
const float gy,
const float gyaw)
67 x =
static_cast<int>(std::floor((gx - map_info.origin.position.x) / map_info.linear_resolution));
68 y =
static_cast<int>(std::floor((gy - map_info.origin.position.y) / map_info.linear_resolution));
69 yaw = std::lround(gyaw / map_info.angular_resolution);
72 const costmap_cspace_msgs::MapMetaData3D& map_info,
73 float& x,
float& y,
float& yaw,
74 const float gx,
const float gy,
const float gyaw)
76 x = (gx - map_info.origin.position.x) / map_info.linear_resolution;
77 y = (gy - map_info.origin.position.y) / map_info.linear_resolution;
78 yaw = gyaw / map_info.angular_resolution;
81 template <
template <
class,
class>
class STL_CONTAINER = std::list>
83 const costmap_cspace_msgs::MapMetaData3D& map_info,
88 for (
const auto& p : path_grid)
92 geometry_msgs::PoseStamped ps;
93 ps.header = path.header;
95 ps.pose.position.x = x;
96 ps.pose.position.y = y;
97 ps.pose.position.z = 0;
100 path.poses.push_back(ps);
107 #endif // PLANNER_CSPACE_PLANNER_3D_GRID_METRIC_CONVERTER_H TFSIMD_FORCE_INLINE const tfScalar & y() const
void metric2Grid(const costmap_cspace_msgs::MapMetaData3D &map_info, int &x, int &y, int &yaw, const float gx, const float gy, const float gyaw)
TFSIMD_FORCE_INLINE const tfScalar & x() const
void grid2MetricPath(const costmap_cspace_msgs::MapMetaData3D &map_info, const STL_CONTAINER< CyclicVecFloat< 3, 2 >, std::allocator< CyclicVecFloat< 3, 2 >>> &path_grid, nav_msgs::Path &path)
void grid2Metric(const costmap_cspace_msgs::MapMetaData3D &map_info, const T x, const T y, const T yaw, float &gx, float &gy, float &gyaw)