selfdriving
CostEvaluatorCostMap.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * SelfDriving C++ library based on PTGs and mrpt-nav
3  * Copyright (C) 2019-2022 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
7 #pragma once
8 
10 #include <mrpt/containers/CDynamicGrid.h>
11 #include <mrpt/maps/CPointsMap.h>
12 
13 namespace mpp
14 {
15 /** Defines higher costs to paths that pass closer to obstacles.
16  *
17  */
19 {
20  DEFINE_MRPT_OBJECT(CostEvaluatorCostMap, mpp)
21 
22  public:
23  CostEvaluatorCostMap() = default;
25 
26  struct Parameters
27  {
28  Parameters();
29  ~Parameters();
30 
31  static Parameters FromYAML(const mrpt::containers::yaml& c);
32 
33  double resolution = 0.05; //!< [m]
34  double preferredClearanceDistance = 0.4; //!< [m]
35  double maxCost = 2.0;
36 
37  /** If enabled, the cost of a path segment (MoveEdgeSE2_TPS) will be the
38  * average of the set of pointwise evaluations along it.
39  * Otherwise (default) the maximum cost (more conservative) will be kept
40  * instead.
41  */
42  bool useAverageOfPath = false;
43 
44  /** If !=0, defines the costmap only around a given maximum squared ROI
45  * around the current robot pose. Otherwise, the limits are given by the
46  * obstacle points. */
47  double maxRadiusFromRobot = .0;
48 
49  mrpt::containers::yaml as_yaml();
50  void load_from_yaml(const mrpt::containers::yaml& c);
51  };
52 
53  static CostEvaluatorCostMap::Ptr FromStaticPointObstacles(
54  const mrpt::maps::CPointsMap& obsPts,
55  const Parameters& p = Parameters(),
56  const std::optional<mrpt::math::TPose2D>& curRobotPose = std::nullopt);
57 
58  /** Evaluate cost of move-tree edge */
59  double operator()(const MoveEdgeSE2_TPS& edge) const override;
60 
61  mrpt::opengl::CSetOfObjects::Ptr get_visualization() const override;
62 
63  using cost_gridmap_t = mrpt::containers::CDynamicGrid<double>;
64 
65  const cost_gridmap_t cost_gridmap() const { return costmap_; }
66 
67  const Parameters& params() const { return params_; }
68 
69  private:
72 
73  double eval_single_pose(const mrpt::math::TPose2D& p) const;
74 };
75 
76 } // namespace mpp
Definition: CostEvaluatorCostMap.h:26
Definition: bestTrajectory.h:15
Parameters params_
Definition: CostEvaluatorCostMap.h:71
cost_gridmap_t costmap_
Definition: CostEvaluatorCostMap.h:70
double maxRadiusFromRobot
Definition: CostEvaluatorCostMap.h:47
double operator()(const MoveEdgeSE2_TPS &edge) const override
double resolution
[m]
Definition: CostEvaluatorCostMap.h:33
Definition: CostEvaluator.h:17
static Parameters FromYAML(const mrpt::containers::yaml &c)
bool useAverageOfPath
Definition: CostEvaluatorCostMap.h:42
mrpt::containers::CDynamicGrid< double > cost_gridmap_t
Definition: CostEvaluatorCostMap.h:63
double preferredClearanceDistance
[m]
Definition: CostEvaluatorCostMap.h:34
static CostEvaluatorCostMap::Ptr FromStaticPointObstacles(const mrpt::maps::CPointsMap &obsPts, const Parameters &p=Parameters(), const std::optional< mrpt::math::TPose2D > &curRobotPose=std::nullopt)
const cost_gridmap_t cost_gridmap() const
Definition: CostEvaluatorCostMap.h:65
const Parameters & params() const
Definition: CostEvaluatorCostMap.h:67
Definition: MoveEdgeSE2_TPS.h:19
double eval_single_pose(const mrpt::math::TPose2D &p) const
double maxCost
Definition: CostEvaluatorCostMap.h:35
void load_from_yaml(const mrpt::containers::yaml &c)
Definition: CostEvaluatorCostMap.h:18
mrpt::containers::yaml as_yaml()
mrpt::opengl::CSetOfObjects::Ptr get_visualization() const override