30 #ifndef _MIRA_PILOT_METRICPLANNERBASE_H_ 31 #define _MIRA_PILOT_METRICPLANNERBASE_H_ 35 namespace mira {
namespace pilot {
48 return std::numeric_limits<double>::max();
61 bool persistentDoubleBuffer =
false);
64 template <
typename Reflector>
69 r.member(
"UseDoubleBuffer",
73 r.property(
"PersistentDoubleBuffer",
76 "Do NOT invalidate double buffer when a new goal is set",
79 "Whether getCarrot should be performed on the DoubleBuffer, if active and valid.",
82 "How long should we plan until we decide that we can not plan a path",
85 "If the planner has no path since the specified time (but had one before) XPathLost is thrown",
87 r.property(
"Navfscale",
mNavfscale,
"The color scaling of the path costs during visualization", 0.02);
97 MIRA_THROW(XNotImplemented,
"MetricPlannerBase::setOnewayMap() not overridden by concrete subclass!")
103 if (!useDoubleBuffer)
133 double getValue(
const Point2f& worldPos,
bool ignoreDoubleBuffer =
false)
const;
176 MIRA_THROW(XLogical,
"No costmap created yet. Call update() first.")
186 MIRA_THROW(XLogical,
"No costmap created yet. Call update() first.")
196 MIRA_THROW(XLogical,
"No costmap created yet. Call update() first.")
206 MIRA_THROW(XLogical,
"No costmap created yet. Call update() first.")
216 MIRA_THROW(XLogical,
"No costmap created yet. Call update() first.")
239 bool clearDoubleBuffer =
true,
bool prepareNew =
true);
243 bool clearDoubleBuffer =
true,
bool prepareNew =
true);
247 bool clearDoubleBuffer =
true,
bool prepareNew =
true);
251 bool clearDoubleBuffer =
true,
bool prepareNew =
true);
255 bool clearDoubleBuffer =
true,
bool prepareNew =
true);
266 virtual void reset();
307 int maxCount,
float maxDistance)
const;
310 double& dx,
double& dy,
double& gx,
double& gy)
const;
349 bool costsInGoalRegion =
true);
379 double ynb,
double diagnb)
const;
Point2f map2world(const Point2i &p) const
Implementation of AbstractMetricPlanner::world2map(const Point2i&)
Definition: MetricPlannerBase.h:184
Point2f map2world(const Point2i &p) const
std::function< float(int x, int y, float r)> CostFn
Type declaration for a cost function to be used with setGoal(const Polygon2i, ...) or setGoal(const P...
Definition: AbstractMetricPlanner.h:198
Rect2i getMapRegion() const
Implementation of AbstractMetricPlanner::getMapRegion()
Definition: MetricPlannerBase.h:214
Point2i mPointGoalCell
Definition: MetricPlannerBase.h:418
virtual maps::CostMap getCurrentNavFunction() const =0
Creates a deep copy of the current navigation function that contains the accumulated costs from each ...
bool havePlan() const
Implementation of AbstractMetricPlanner::havePlan()
Definition: MetricPlannerBase.h:318
virtual void reset()
Re-initialize internal structures.
Base class for implementations of metric planners like Dijkstra and E*.
Definition: MetricPlannerBase.h:55
maps::CostMap getNavFunction(bool ignoreDoubleBuffer=false) const
Implementation of AbstractMetricPlanner::getNavFunction(bool)
Duration mAccumulatedPlanningTime
Definition: MetricPlannerBase.h:401
Time lastValidPlan() const
Implementation of AbstractMetricPlanner::lastValidPlan()
Definition: MetricPlannerBase.h:324
virtual Carrot getCarrot(const Point2f &pos, int maxCount, float maxDistance=1e10f) const
Implementation of AbstractMetricPlanner::getCarrot(const Point2f&, int, float)
virtual void addGoal(const Point2i &p, float cost)=0
Add a goal cell with a certain cost (e.g.
#define MIRA_REFLECT_BASE(reflector, BaseClass)
virtual void resetDoubleBuffer(bool createNew)
Set the entire double buffer to infinity.
void resetPlanningTimeout()
Implementation of AbstractMetricPlanner::resetPlanningTimeout()
bool mHadValidPlanSinceUpdate
Definition: MetricPlannerBase.h:406
Setter< T > setter(void(*f)(const T &))
Interface for metric planners like Dijkstra and E*.
Definition: AbstractMetricPlanner.h:48
Point2f mPointGoal
Definition: MetricPlannerBase.h:417
bool havePlanSinceUpdate() const
Implementation of AbstractMetricPlanner::havePlanSinceUpdate()
Definition: MetricPlannerBase.h:321
virtual Pose2 getCurrentGoal(const Point2f &pos) const
Implementation of AbstractMetricPlanner::getCurrentGoal(const Point2f&)
maps::GridMap< uint8, 3 > dumpNavStatus(bool useDoubleBuffer=false, bool costsInGoalRegion=true)
Implementation of AbstractMetricPlanner::dumpNavStatus(bool, bool)
StatusMap getStatusMap() const
virtual Carrot getCurrentCarrot(const Point2f &pos, int maxCount, float maxDistance=1e10f) const =0
Return the optimal path to the goal, starting at pos, based on the current planner map...
Point2i world2map(const Point2f &p) const
Implementation of AbstractMetricPlanner::world2map(const Point2f&)
Definition: MetricPlannerBase.h:174
#define MIRA_THROW(ex, msg)
void plan(const Point2f &pos, Duration plantime)
Implementation of AbstractMetricPlanner::plan(const Point2f&, Duration)
double filteredCorner(double self, double xnb, double ynb, double diagnb) const
Fix infinite (invalid) values by replacing with finite neighbour values, if available.
std::vector< Point2f > Carrot
Definition: AbstractMetricPlanner.h:53
int computeStableGradientFromMap(const maps::CostMap &map, int ix, int iy, double baseVal, double stepsize, double &dx, double &dy, double &gx, double &gy) const
#define MIRA_ABSTRACT_OBJECT(classIdentifier)
Interface for metric planners like Dijkstra and E*.
virtual double getValueFiltered(const Point2f &worldPos, bool ignoreDoubleBuffer=false) const
Implementation of AbstractMetricPlanner::getValueFiltered(const Point2f&, bool)
Duration getAccumulatedPlanningTime() const
Implementation of AbstractMetricPlanner::getAccumulatedPlanningTime()
Definition: MetricPlannerBase.h:231
float getCellSize() const
Implementation of AbstractMetricPlanner::getCellSize()
Definition: MetricPlannerBase.h:194
void reflect(Reflector &r)
Definition: MetricPlannerBase.h:65
bool mDoubleBufferValid
Definition: MetricPlannerBase.h:430
maps::GridMap< uint8, 3 > showNavFunctionNearGoal()
Implementation of AbstractMetricPlanner::showNavFunctionNearGoal()
MetricPlannerBase(bool useDoubleBuffer=false, bool persistentDoubleBuffer=false)
Time mLastValidPlan
Definition: MetricPlannerBase.h:398
maps::CostMap mDoubleBuffer
Definition: MetricPlannerBase.h:388
Eigen::VectorXf mPointGoalPyrBorder
Definition: MetricPlannerBase.h:419
bool getPersistentDoubleBuffer() const
Persistent double buffer enabled (i.e. not reset on setting goal)?
Definition: MetricPlannerBase.h:226
boost::geometry::model::ring< Point2i > Polygon2i
Rect2i getMapRegion() const
void planSteps(int steps)
Implementation of AbstractMetricPlanner::planSteps(int)
bool mPersistentDoubleBuffer
Definition: MetricPlannerBase.h:437
void setUseDoubleBuffer(bool useDoubleBuffer)
Enable/disable double buffer.
Definition: MetricPlannerBase.h:101
Point2f getGradientMap(const Point2i &mapPos) const
Returns the gradient for a position in map coordinates.
Getter< T > getter(T(*f)())
void prepareNewGoal(bool clearDoubleBuffer)
Call removeGoals() and reset all status and timing data related to planning on the current goal...
virtual void dirtyCell(const Point2i &p, double value)=0
Update a cell's cost map value in the planner's internal cost function representation.
std::list< Rect2i > DirtyRegions
void planTime(Duration plantime)
Implementation of AbstractMetricPlanner::planTime(Duration)
virtual void update(const maps::CostMap &map, const maps::DirtyRegions &dirty)
Implementation of AbstractMetricPlanner::update(const maps::CostMap&, const maps::DirtyRegions&) ...
virtual void freeCell(const Point2i &p)=0
Mark a cell as free in the planner's internal cost function representation.
AbstractMetricPlanner::Carrot getCarrotFromMap(const maps::CostMap &map, const Point2f &pos, int maxCount, float maxDistance) const
Calculate a path through the given costmap, starting at pos and following the gradient computed by co...
virtual Point2f getCurrentGradientMap(const Point2i &mapPos) const
Returns the gradient for a position in map coordinates from current costs.
bool mHasPointGoal
Definition: MetricPlannerBase.h:416
virtual Point2f getGradient(const Point2f &worldPos) const
Implementation of AbstractMetricPlanner::getGradient(const Point2f&)
virtual void copyDoubleBuffer()=0
Copy entire field of internally calculated cost values to mDoubleBuffer.
bool mGetCarrotFromDoubleBuffer
Definition: MetricPlannerBase.h:423
virtual void removeGoals()=0
Remove all set goals.
bool mHadValidPlan
Definition: MetricPlannerBase.h:405
double getValue(const Point2f &worldPos, bool ignoreDoubleBuffer=false) const
Implementation of AbstractMetricPlanner::getValue(const Point2f&, bool)
void setGoal(const Point2f &goal, float radius, bool clearDoubleBuffer=true, bool prepareNew=true)
Implementation of AbstractMetricPlanner::setGoal(const Point2f&, float, bool, bool) ...
virtual Carrot getDoubleBufferCarrot(const Point2f &pos, int maxCount, float maxDistance=1e10f) const
Return the optimal path to the goal, starting at pos, based on the double buffer. ...
float getCellSize() const
Point2i world2map(const Point2f &p, bool roundDown=true) const
double plannerDefaultInfinity()
Definition: MetricPlannerBase.h:39
virtual bool isValid() const
Return whether planner is properly initialized and able to calculate a path (when a goal is set) ...
Size2i mSize
Definition: MetricPlannerBase.h:383
Eigen::VectorXf mPointGoalPyrSlope
Definition: MetricPlannerBase.h:420
virtual double infinity() const
Implementation of AbstractMetricPlanner::infinity().
float defaultCostFn(int x, int y, float r)
A default cost function which is always returning r (radius)
bool mUseDoubleBuffer
Definition: MetricPlannerBase.h:422
bool getUseDoubleBuffer() const
Double buffer enabled?
Definition: MetricPlannerBase.h:221
void setPersistentDoubleBuffer(bool persistentDoubleBuffer)
Enable/disable persistent double buffer (i.e. not reset when setting goal)
Definition: MetricPlannerBase.h:108
Duration mPathLostTimeout
Definition: MetricPlannerBase.h:404
float mNavfscale
Definition: MetricPlannerBase.h:409
boost::geometry::model::ring< Point2f > Polygon2f
Time mLastPlan
Definition: MetricPlannerBase.h:392
Rect2f getRegion() const
Implementation of AbstractMetricPlanner::getRegion()
Definition: MetricPlannerBase.h:204
maps::CostMap mCostMap
Definition: MetricPlannerBase.h:384
Duration mMaxPlanningTime
Definition: MetricPlannerBase.h:403
virtual ~MetricPlannerBase()
Definition: MetricPlannerBase.h:62
virtual Img8U1 getStatusField() const
Return the result of getStatusMap(const Point2i&) over the entire map area.
virtual double getCurrentValueMap(const Point2i &mapPos) const =0
Returns the cost value at position (in map coordinates) in the current planner map.
virtual void setOnewayMap(const maps::OccupancyGrid &onewayMap)
Implementation of AbstractMetricPlanner::setOnewayMap().
Definition: MetricPlannerBase.h:96
bool mPathLostReported
Definition: MetricPlannerBase.h:407
Status::StatusMode getStatus() const
double getValueMap(const Point2i &mapPos, bool ignoreDoubleBuffer=false) const
Returns the cost value at position (in map coordinates) in the planner map.
REFLECT_CTRLFLAG_MEMBER_AS_ROPROPERTY