38 #include <costmap_cspace_msgs/MapMetaData3D.h>
51 const costmap_cspace_msgs::MapMetaData3D& map_info,
52 const Vecf& euclid_cost_coef,
53 const int local_range,
60 const float path_interpolation_resolution,
61 const float grid_enumeration_resolution)
64 , euclid_cost_coef_(euclid_cost_coef)
66 1.0
f / map_info.linear_resolution,
67 1.0
f / map_info.linear_resolution,
68 1.0
f / map_info.angular_resolution)
69 , local_range_(local_range)
70 , cost_estim_cache_(cost_estim_cache)
79 costmap_cspace_msgs::MapMetaData3D map_info_linear(
map_info_);
80 map_info_linear.angle = 1;
83 map_info_linear.linear_resolution,
84 map_info_linear.angular_resolution,
87 path_interpolation_resolution,
88 grid_enumeration_resolution);
94 path_interpolation_resolution,
95 grid_enumeration_resolution);
122 const Vecf& euclid_cost_coef,
124 const int local_range)
139 for (
int rootsum = 0;
160 for (
int i = 0; i < 2; ++i)
161 rootsum += v[i] * v[i];
171 const Vec& cur,
const Vec& next,
const std::vector<VecWithCost>& start,
const Vec& goal)
const
173 if ((
cm_[cur] > 99) || (
cm_[next] > 99))
177 Vec d_raw = next - cur;
182 if (
d[0] == 0 &&
d[1] == 0)
186 const int dir =
d[2] < 0 ? -1 : 1;
188 for (
int i = 0; i < std::abs(
d[2]); i++)
190 const auto c =
cm_[pos];
200 else if (pos[2] >=
static_cast<int>(
map_info_.angle))
204 const float turn_heuristic_cost_ratio =
206 const float turn_cost_multiplier =
map_info_.angular_resolution * (turn_cost_ratio + turn_heuristic_cost_ratio);
214 const float dist = motion.
len();
224 const float aspect = motion[0] / motion[1];
228 int sum = 0, sum_hyst = 0;
229 Vec d_index(
d[0],
d[1], next[2]);
235 const int num = cache_page->second.getMotion().size();
236 for (
const auto& pos_diff : cache_page->second.getMotion())
239 cur[0] + pos_diff[0], cur[1] + pos_diff[1], pos_diff[2]);
240 const auto c =
cm_[pos];
248 const float distf = cache_page->second.getDistance();
255 const float r1 = radiuses.first;
256 const float r2 = radiuses.second;
257 const float curv_radius = (r1 + r2) / 2;
272 int sum = 0, sum_turn = 0, sum_hyst = 0;
273 Vec d_index(
d[0],
d[1], next[2]);
279 const int num = cache_page->second.getMotion().size();
280 for (
const auto& pos_diff : cache_page->second.getMotion())
283 cur[0] + pos_diff[0], cur[1] + pos_diff[1], pos_diff[2]);
284 const auto c =
cm_[pos];
296 const float distf = cache_page->second.getDistance();
306 const Vec& cur,
const Vec& goal)
const
308 Vec s2(cur[0], cur[1], 0);
310 if (
cost == std::numeric_limits<float>::max())
311 return std::numeric_limits<float>::max();
313 int diff = cur[2] - goal[2];
314 while (diff >
static_cast<int>(
map_info_.angle) / 2)
315 diff -=
static_cast<int>(
map_info_.angle);
316 while (diff < -
static_cast<int>(
map_info_.angle) / 2)
317 diff +=
static_cast<int>(
map_info_.angle);
325 const std::vector<VecWithCost>& ss,
329 for (
const VecWithCost&
s : ss)
331 const Vec ds =
s.v_ - p;
333 if (ds.
sqlen() < local_range_sq)
347 const Vec& cur,
const Vec& next,
const std::vector<VecWithCost>& start,
const Vec& goal)
const
354 const auto cache_page =
base_->motion_cache_linear_.find(0,
d);
355 if (cache_page ==
base_->motion_cache_linear_.end(0))
357 const int num = cache_page->second.getMotion().size();
358 for (
const auto& pos_diff : cache_page->second.getMotion())
360 const Vec pos(cur[0] + pos_diff[0], cur[1] + pos_diff[1], 0);
361 const auto c =
base_->cm_rough_[pos];
366 const float distf = cache_page->second.getDistance();
367 cost += sum *
base_->map_info_.linear_resolution *
368 distf *
base_->cc_.weight_costmap_ / (100.0 * num);
373 const Vec& cur,
const Vec& goal)
const
375 const Vec d = goal - cur;
381 const Vec& cur,
const std::vector<VecWithCost>& start,
const Vec& goal)
const
383 return base_->search_list_rough_;