37 #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,
62 , euclid_cost_coef_(euclid_cost_coef)
64 1.0
f / map_info.linear_resolution,
65 1.0
f / map_info.linear_resolution,
66 1.0
f / map_info.angular_resolution)
67 , local_range_(local_range)
68 , cost_estim_cache_(cost_estim_cache)
77 costmap_cspace_msgs::MapMetaData3D map_info_linear(
map_info_);
78 map_info_linear.angle = 1;
81 map_info_linear.linear_resolution,
82 map_info_linear.angular_resolution,
124 for (
int rootsum = 0;
135 while (angle > static_cast<int>(
map_info_.angle) / 2)
136 angle -=
static_cast<int>(
map_info_.angle);
137 while (angle < -static_cast<int>(
map_info_.angle) / 2)
138 angle += static_cast<int>(
map_info_.angle);
145 for (
int i = 0; i < 2; ++i)
146 rootsum += v[i] * v[i];
154 const Vec& cur,
const Vec& next,
const std::vector<VecWithCost>& start,
const Vec& goal)
const 156 Vec d_raw = next - cur;
161 if (d[0] == 0 && d[1] == 0)
165 const int dir = d[2] < 0 ? -1 : 1;
167 for (
int i = 0; i < std::abs(d[2]); i++)
172 else if (pos[2] >= static_cast<int>(
map_info_.angle))
174 const auto c =
cm_[pos];
189 const float dist = motion.
len();
199 const float aspect = motion[0] / motion[1];
203 int sum = 0, sum_hyst = 0;
204 Vec d_index(d[0], d[1], next[2]);
210 const int num = cache_page->second.getMotion().size();
211 for (
const auto& pos_diff : cache_page->second.getMotion())
214 cur[0] + pos_diff[0], cur[1] + pos_diff[1], pos_diff[2]);
215 const auto c =
cm_[pos];
223 const float distf = cache_page->second.getDistance();
230 const float r1 = radiuses.first;
231 const float r2 = radiuses.second;
232 const float curv_radius = (r1 + r2) / 2;
247 int sum = 0, sum_hyst = 0;
248 Vec d_index(d[0], d[1], next[2]);
254 const int num = cache_page->second.getMotion().size();
255 for (
const auto& pos_diff : cache_page->second.getMotion())
258 cur[0] + pos_diff[0], cur[1] + pos_diff[1], pos_diff[2]);
259 const auto c =
cm_[pos];
267 const float distf = cache_page->second.getDistance();
277 const Vec& cur,
const Vec& goal)
const 279 Vec s2(cur[0], cur[1], 0);
281 if (cost == std::numeric_limits<float>::max())
282 return std::numeric_limits<float>::max();
284 int diff = cur[2] - goal[2];
285 while (diff > static_cast<int>(
map_info_.angle) / 2)
286 diff -=
static_cast<int>(
map_info_.angle);
287 while (diff < -static_cast<int>(
map_info_.angle) / 2)
288 diff += static_cast<int>(
map_info_.angle);
296 const std::vector<VecWithCost>& ss,
300 for (
const VecWithCost&
s : ss)
302 const Vec ds =
s.v_ - p;
304 if (ds.
sqlen() < local_range_sq)
313 const Vec& cur,
const Vec& next,
const std::vector<VecWithCost>& start,
const Vec& goal)
const 317 float cost = base_->euclidCostRough(d);
320 const auto cache_page = base_->motion_cache_linear_.find(0, d);
321 if (cache_page == base_->motion_cache_linear_.end(0))
323 const int num = cache_page->second.getMotion().size();
324 for (
const auto& pos_diff : cache_page->second.getMotion())
326 const Vec pos(cur[0] + pos_diff[0], cur[1] + pos_diff[1], 0);
327 const auto c = base_->cm_rough_[pos];
332 const float distf = cache_page->second.getDistance();
333 cost += sum * base_->map_info_.linear_resolution *
334 distf * base_->cc_.weight_costmap_ / (100.0 * num);
339 const Vec& cur,
const Vec& goal)
const 341 const Vec d = goal - cur;
342 const float cost = base_->euclidCostRough(d);
347 const Vec& cur,
const std::vector<VecWithCost>& start,
const Vec& goal)
const 349 return base_->search_list_rough_;
std::array< float, 1024 > euclid_cost_lin_cache_
void cycle(const int res, const ArgList &...rest)
float cost(const Vec &cur, const Vec &next, const std::vector< VecWithCost > &start, const Vec &goal) const final
float costEstim(const Vec &cur, const Vec &goal) const final
const std::vector< Vec > & searchGrids(const Vec &p, const std::vector< VecWithCost > &ss, const Vec &es) const override
const Cache::const_iterator end(const int start_yaw) const
const CyclicVecInt< 3, 2 > & getMaxRange() const
float weight_costmap_turn_
virtual std::function< void(CyclicVecInt< DIM, NONCYCLIC >, size_t &, size_t &)> getAddressor() const =0
void cycleUnsigned(const int res, const ArgList &...rest)
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
std::vector< std::vector< Vec > > motion_primitives_
BlockMemGridmapBase< char, 3, 2 > & cm_
GridAstarModel3D(const costmap_cspace_msgs::MapMetaData3D &map_info, const Vecf &euclid_cost_coef, const int local_range, BlockMemGridmapBase< float, 3, 2 > &cost_estim_cache, BlockMemGridmapBase< char, 3, 2 > &cm, BlockMemGridmapBase< char, 3, 2 > &cm_hyst, BlockMemGridmapBase< char, 3, 2 > &cm_rough, const CostCoeff &cc, const int range)
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
BlockMemGridmapBase< float, 3, 2 > & cost_estim_cache_
std::vector< Vec > search_list_rough_
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, const std::function< void(CyclicVecInt< 3, 2 >, size_t &, size_t &)> gm_addr)
BlockMemGridmapBase< char, 3, 2 > & cm_hyst_
void reset(const float linear_resolution, const float angular_resolution, const int range)
float cost(const Vec &cur, const Vec &next, const std::vector< VecWithCost > &start, const Vec &goal) const override
void enableHysteresis(const bool enable)
float euclidCost(const Vec &v) const
float costEstim(const Vec &cur, const Vec &goal) const override
MotionCache motion_cache_
const std::vector< Vec > & searchGrids(const Vec &cur, const std::vector< VecWithCost > &start, const Vec &goal) const final
PathInterpolator path_interpolator_
void reset(const float angular_resolution, const int range)
BlockMemGridmapBase< char, 3, 2 > & cm_rough_
const std::pair< float, float > & getRadiuses(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
MotionCache motion_cache_linear_
static std::vector< std::vector< Vec > > build(const costmap_cspace_msgs::MapMetaData3D &map_info, const CostCoeff &cc, const int range)
void createEuclidCostCache()
costmap_cspace_msgs::MapMetaData3D map_info_
float euclidCostRough(const Vec &v) const
const Cache::const_iterator find(const int start_yaw, const CyclicVecInt< 3, 2 > &goal) const