Parasol Planning Library (PPL)
Path.h
Go to the documentation of this file.
1 #ifndef PMPL_PATH_H_
2 #define PMPL_PATH_H_
3 
7 
8 // #include "MPLibrary/MPLibrary.h"
10 
11 // #include <algorithm>
12 // #include <vector>
13 
14 class MPLibrary;
15 
16 
23 class Path final {
24 
25  public:
26 
29 
31  typedef typename RoadmapType::VID VID;
32 
36 
39  Path(RoadmapType* const _r = nullptr);
40 
44 
46  Robot* GetRobot() const noexcept;
47 
49  RoadmapType* GetRoadmap() const noexcept;
50 
52  size_t Size() const noexcept;
53 
55  bool Empty() const noexcept;
56 
58  double Length() const;
59 
61  const std::vector<VID>& VIDs() const noexcept;
62 
64  const std::pair<std::vector<VID>,std::vector<size_t>> VIDsWaiting() const noexcept;
65 
69  const std::vector<Cfg>& Cfgs() const;
70 
77  const std::vector<Cfg> FullCfgs(MPLibrary* const _lib) const;
78 
85  const std::vector<Cfg> FullCfgsWithWait(MPLibrary* const _lib) const;
86 
89  size_t TimeSteps() const;
90 
92  void SetTimeSteps(size_t _timesteps);
93 
95  void ResetTimeSteps();
96 
99  Path& operator+=(const Path& _p);
100 
103  Path operator+(const Path& _p) const;
104 
107  Path& operator+=(const std::vector<VID>& _vids);
108 
111  Path operator+(const std::vector<VID>& _vids) const;
112 
114  Path& operator=(const Path& _p);
115 
117  void Clear();
118 
120  void FlushCache();
121 
124  void SetFinalWaitTimeSteps(const size_t& _timeSteps);
125 
127  const size_t GetFinalWaitTimeSteps() const;
128 
131  void SetWaitTimes(std::vector<size_t> _waitTimes);
132 
134  std::vector<size_t> GetWaitTimes();
135 
139  std::pair<std::pair<size_t,size_t>,std::pair<size_t,size_t>>
140  GetEdgeAtTimestep(size_t _timestep);
141 
143 
144  private:
145 
148 
149  void AssertSameMap(const Path& _p) const noexcept;
150 
154 
155  RoadmapType* const m_roadmap;
156  std::vector<VID> m_vids;
157  std::vector<size_t> m_waitingTimesteps;
158 
159  mutable std::vector<Cfg> m_cfgs;
160  mutable bool m_cfgsCached{false};
161 
162  mutable double m_length{0};
163  mutable bool m_lengthCached{false};
164 
165  size_t m_finalWaitTimeSteps{0};
166 
167  mutable size_t m_timesteps{0};
168  mutable bool m_timestepsCached{false};
169 
171 };
172 
173 #endif
Definition: Cfg.h:38
Definition: GenericStateGraph.h:67
STAPLGraph::vertex_descriptor VID
Definition: GenericStateGraph.h:83
Definition: MPLibrary.h:47
Definition: Path.h:23
double Length() const
Get the total edge weight.
Definition: Path.cpp:45
std::vector< size_t > GetWaitTimes()
Get the wait time at each vertex index in the path.
Definition: Path.cpp:248
std::pair< std::pair< size_t, size_t >, std::pair< size_t, size_t > > GetEdgeAtTimestep(size_t _timestep)
Definition: Path.cpp:255
void ResetTimeSteps()
Reset the number of timesteps to 0.
Definition: Path.cpp:143
const std::vector< Cfg > & Cfgs() const
Definition: Path.cpp:84
size_t TimeSteps() const
Definition: Path.cpp:101
void SetFinalWaitTimeSteps(const size_t &_timeSteps)
Definition: Path.cpp:221
RoadmapType * GetRoadmap() const noexcept
Get the roadmap used by this path.
Definition: Path.cpp:24
void Clear()
Clear all data in the path.
Definition: Path.cpp:203
void SetWaitTimes(std::vector< size_t > _waitTimes)
Definition: Path.cpp:235
const std::vector< VID > & VIDs() const noexcept
Get the VIDs in the path.
Definition: Path.cpp:70
size_t Size() const noexcept
Get the number of cfgs in the path.
Definition: Path.cpp:31
GenericStateGraph< Cfg, DefaultWeight< Cfg > > RoadmapType
Definition: Path.h:30
const std::pair< std::vector< VID >, std::vector< size_t > > VIDsWaiting() const noexcept
Get the VIDs and timesteps waiting in the path.
Definition: Path.cpp:77
void SetTimeSteps(size_t _timesteps)
Hardcode number of timesteps in the path.
Definition: Path.cpp:135
const std::vector< Cfg > FullCfgs(MPLibrary *const _lib) const
Definition: Path.cpp:289
bool Empty() const noexcept
Check if the path is empty.
Definition: Path.cpp:38
const std::vector< Cfg > FullCfgsWithWait(MPLibrary *const _lib) const
Definition: Path.cpp:314
RoadmapType::VID VID
Definition: Path.h:31
Path(RoadmapType *const _r=nullptr)
Definition: Path.cpp:11
const size_t GetFinalWaitTimeSteps() const
Get the number of timesteps to wait after traversal of the path.
Definition: Path.cpp:228
Robot * GetRobot() const noexcept
Get the robot which travels this path.
Definition: Path.cpp:17
void FlushCache()
Clear cached data, but leave the VIDs.
Definition: Path.cpp:212
Definition: Robot.h:31