selfdriving
CostEvaluatorPreferredWaypoint.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/CSimplePointsMap.h>
12 
13 namespace mpp
14 {
15 /** Defines lower (negative) costs to paths that pass closer to one or more
16  * "preferred waypoints" defined by 2D coordinates (x,y)
17  */
19 {
20  DEFINE_MRPT_OBJECT(CostEvaluatorPreferredWaypoint, mpp)
21 
22  public:
25 
26  struct Parameters
27  {
28  Parameters();
29  ~Parameters();
30 
31  static Parameters FromYAML(const mrpt::containers::yaml& c);
32 
33  double waypointInfluenceRadius = 1.5; //!< [m]
34  double costScale = 10.0;
35 
36  /** If enabled (default), the cost of a path segment (MoveEdgeSE2_TPS)
37  * will be the average of the set of pointwise evaluations along it.
38  * Otherwise the maximum (negative) cost will be kept instead.
39  */
40  bool useAverageOfPath = true;
41 
42  mrpt::containers::yaml as_yaml();
43  void load_from_yaml(const mrpt::containers::yaml& c);
44  };
45 
46  /** Method parameters. Can be freely modified at any time after
47  * construction. */
49 
50  /** The preferred waypoints must be defined by means of this method. */
51  void setPreferredWaypoints(const std::vector<mrpt::math::TPoint2D>& pts);
52 
53  /** Evaluate cost of move-tree edge */
54  double operator()(const MoveEdgeSE2_TPS& edge) const override;
55 
56  mrpt::opengl::CSetOfObjects::Ptr get_visualization() const override;
57 
58  const Parameters& params() const { return params_; }
59 
60  private:
61  double eval_single_pose(const mrpt::math::TPose2D& p) const;
62 
63  mrpt::maps::CSimplePointsMap waypoints_;
64 };
65 
66 } // namespace mpp
bool useAverageOfPath
Definition: CostEvaluatorPreferredWaypoint.h:40
double operator()(const MoveEdgeSE2_TPS &edge) const override
Definition: CostEvaluatorPreferredWaypoint.h:26
Definition: bestTrajectory.h:15
double waypointInfluenceRadius
[m]
Definition: CostEvaluatorPreferredWaypoint.h:33
void setPreferredWaypoints(const std::vector< mrpt::math::TPoint2D > &pts)
void load_from_yaml(const mrpt::containers::yaml &c)
Definition: CostEvaluator.h:17
Definition: MoveEdgeSE2_TPS.h:19
static Parameters FromYAML(const mrpt::containers::yaml &c)
const Parameters & params() const
Definition: CostEvaluatorPreferredWaypoint.h:58
Parameters params_
Definition: CostEvaluatorPreferredWaypoint.h:48
double costScale
Definition: CostEvaluatorPreferredWaypoint.h:34
mrpt::maps::CSimplePointsMap waypoints_
Definition: CostEvaluatorPreferredWaypoint.h:63
double eval_single_pose(const mrpt::math::TPose2D &p) const
Definition: CostEvaluatorPreferredWaypoint.h:18
mrpt::opengl::CSetOfObjects::Ptr get_visualization() const override