35 #include <costmap_cspace_msgs/MapMetaData3D.h> 45 const costmap_cspace_msgs::MapMetaData3D& map_info,
const CostCoeff& cc,
const int range)
48 rot_cache.
reset(map_info.linear_resolution, map_info.angular_resolution, range);
49 Vecf resolution_(1.0
f / map_info.linear_resolution,
50 1.0f / map_info.linear_resolution,
51 1.0f / map_info.angular_resolution);
53 std::vector<std::vector<Vec>> motion_primitives;
54 std::vector<Vec> search_list;
57 for (d[0] = -range; d[0] <= range; d[0]++)
59 for (d[1] = -range; d[1] <= range; d[1]++)
61 if (d.
sqlen() > range * range)
63 for (d[2] = 0; d[2] <
static_cast<int>(map_info.angle); d[2]++)
65 search_list.push_back(d);
71 motion_primitives.resize(map_info.angle);
72 for (
int i = 0; i < static_cast<int>(motion_primitives.size()); ++i)
74 auto& current_primitives = motion_primitives[i];
75 for (
const auto& prim : search_list)
77 if (prim[0] == 0 && prim[1] == 0)
84 current_primitives.push_back(prim);
87 int next_angle = i + prim[2];
88 if (next_angle >= static_cast<int>(map_info.angle))
90 next_angle -= map_info.angle;
92 const Vec d2(prim[0] + range, prim[1] + range, next_angle);
94 const Vecf motion_grid = motion * resolution_;
96 if (std::lround(motion_grid[0]) == 0 && std::lround(motion_grid[1]) != 0)
102 static constexpr
float EPS = 1.0e-6
f;
103 if (std::abs(motion[2]) >= 2.0 * M_PI / 4.0 - EPS)
113 if (std::lround(motion_grid[0]) == 0)
118 const float aspect = motion[0] / motion[1];
124 current_primitives.push_back(prim);
129 if (std::abs(motion[1]) < map_info.linear_resolution / 2.0)
134 if (motion[0] * motion[1] * motion[2] < 0)
138 if (prim.sqlen() < 3 * 3)
142 const std::pair<float, float>& radiuses = rot_cache.
getRadiuses(i, d2);
143 const float r1 = radiuses.first;
144 const float r2 = radiuses.second;
145 if (std::abs(r1 - r2) >= map_info.linear_resolution * 1.5)
150 const float curv_radius = (r1 + r2) / 2;
155 current_primitives.push_back(prim);
160 return motion_primitives;
const CyclicVecFloat< 3, 2 > & getMotion(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
void reset(const float linear_resolution, const float angular_resolution, const int range)
float angle_resolution_aspect_
const std::pair< float, float > & getRadiuses(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
static std::vector< std::vector< Vec > > build(const costmap_cspace_msgs::MapMetaData3D &map_info, const CostCoeff &cc, const int range)