1 #ifndef PPL_COMPOSITE_STATE_H_
2 #define PPL_COMPOSITE_STATE_H_
25 template <
typename GraphType>
35 typedef typename GraphType::CfgType
CfgType;
100 virtual
VID GetVID(const
size_t _index) const noexcept;
166 virtual
void VerifyIndex(const
size_t _robotIndex) const noexcept;
170 virtual
bool IsLocalCfg(const
size_t _robotIndex) const noexcept;
191 template <
typename GraphType>
196 template <
typename GraphType>
215 template <
typename GraphType>
228 template <
typename GraphType>
233 if(m_group != _other.m_group)
237 if(m_groupMap != _other.m_groupMap)
241 for(
size_t i = 0; i < m_vids.size(); ++i) {
242 const VID thisVID = m_vids[i],
243 otherVID = _other.m_vids[i];
246 if(thisVID != otherVID)
249 else if(GetRobotCfg(i) != _other.GetRobotCfg(i))
257 template <
typename GraphType>
261 return !(*
this == _other);
266 template <
typename GraphType>
270 return m_group ? m_group->Size() : 0;
274 template <
typename GraphType>
275 const std::vector<Robot*>&
278 return m_group->GetRobots();
282 template <
typename GraphType>
285 GetRobot(
const size_t _index)
const {
288 Robot*
const robot = m_group->GetRobot(_index);
299 template <
typename GraphType>
306 template <
typename GraphType>
311 if(m_group != _newGraph->
GetGroup())
316 m_groupMap = _newGraph;
320 template <
typename GraphType>
323 GetVID(
const size_t _index)
const noexcept {
325 return m_vids[_index];
328 template <
typename GraphType>
332 const size_t index = m_groupMap->GetGroup()->GetGroupIndex(_robot);
333 return GetVID(index);
338 template <
typename GraphType>
345 const size_t index = m_groupMap->GetGroup()->GetGroupIndex(_robot);
346 SetRobotCfg(index, _vid);
350 template <
typename GraphType>
358 m_vids[_index] = _vid;
362 template <
typename GraphType>
366 const size_t index = m_group->GetGroupIndex(_robot);
367 SetRobotCfg(index, std::move(_cfg));
371 template <
typename GraphType>
377 m_localCfgs[_index] = std::move(_cfg);
382 template <
typename GraphType>
390 template <
typename GraphType>
394 const size_t index = m_group->GetGroupIndex(_robot);
395 return GetRobotCfg(index);
399 template <
typename GraphType>
405 const VID vid = GetVID(_index);
407 return m_groupMap->GetIndividualGraph(_index)->GetVertex(vid);
409 InitializeLocalCfgs();
410 return m_localCfgs[_index];
415 template <
typename GraphType>
419 const size_t index = m_group->GetGroupIndex(_robot);
420 return GetRobotCfg(index);
424 template <
typename GraphType>
432 const VID vid = GetVID(_index);
434 return m_groupMap->GetIndividualGraph(_index)->GetVertex(vid);
437 return m_localCfgs.at(_index);
439 catch(
const std::out_of_range&) {
442 <<
", but no roadmap or local cfg exists.";
448 template <
typename GraphType>
452 VerifyIndex(
const size_t _robotIndex)
const noexcept {
453 if(_robotIndex >= GetNumRobots())
455 <<
", but the group has only " << GetNumRobots()
461 template <
typename GraphType>
470 for(
size_t i = 0; i < _compositeState.
GetNumRobots(); ++i)
478 template <
typename GraphType>
481 IsLocalCfg(
const size_t _robotIndex)
const noexcept {
487 template <
typename GraphType>
493 const size_t numRobots = GetNumRobots();
494 if(m_localCfgs.size() == numRobots)
498 m_localCfgs.resize(numRobots);
500 for(
size_t i = 0; i < numRobots; ++i)
501 m_localCfgs[i] =
CfgType(this->GetRobot(i));
std::ostream & operator<<(std::ostream &, const CompositeState< GraphType > &)
Definition: CompositeState.h:463
#define INVALID_VID
Definition: GenericStateGraph.h:23
#define WHERE
Macro for retrieving info about file, function, and line number.
Definition: RuntimeUtils.h:32
Definition: CompositeEdge.h:23
Definition: CompositeGraph.h:27
virtual RobotGroup * GetGroup()
Get the robot group.
Definition: CompositeGraph.h:190
Definition: CompositeState.h:26
std::vector< CfgType > m_localCfgs
Individual states not in a map.
Definition: CompositeState.h:185
GraphType::CfgType CfgType
The indiv. graph vertex type.
Definition: CompositeState.h:35
std::vector< VID > VIDSet
A set of VIDs from indiv. graphs.
Definition: CompositeState.h:34
virtual void SetGroupGraph(GroupGraphType *_newGraph)
Set the composite graph that this composite state exists within.
Definition: CompositeState.h:309
CompositeEdge< GraphType > CompositeEdgeType
Definition: CompositeState.h:37
size_t VID
A VID in an individual graph.
Definition: CompositeState.h:33
virtual Robot * GetRobot(const size_t _index) const
Definition: CompositeState.h:285
GraphType IndividualGraph
Definition: CompositeState.h:40
virtual bool IsLocalCfg(const size_t _robotIndex) const noexcept
Definition: CompositeState.h:481
void ClearLocalCfgs()
Clear the Local Cfg information.
Definition: CompositeState.h:385
virtual void SetRobotCfg(Robot *const _robot, const VID _vid)
Definition: CompositeState.h:341
virtual void VerifyIndex(const size_t _robotIndex) const noexcept
Definition: CompositeState.h:452
virtual bool operator!=(const CompositeState &_other) const noexcept
Definition: CompositeState.h:260
virtual GroupGraphType * GetGroupGraph() const noexcept
Get the group graph this composite state is with respect to.
Definition: CompositeState.h:302
GroupGraphType * m_groupMap
The group graph.
Definition: CompositeState.h:179
virtual VID GetVID(const size_t _index) const noexcept
Definition: CompositeState.h:323
VIDSet m_vids
The individual VIDs in this aggregate state.
Definition: CompositeState.h:183
virtual const std::vector< Robot * > & GetRobots() const noexcept
Get the full vector of robot pointers.
Definition: CompositeState.h:277
virtual size_t GetNumRobots() const noexcept
Get the number of robots in this composite state.
Definition: CompositeState.h:269
virtual CfgType & GetRobotCfg(Robot *const _robot)
Definition: CompositeState.h:393
RobotGroup * m_group
The robot group for this state.
Definition: CompositeState.h:181
CompositeState(GroupGraphType *const _groupGraph=nullptr)
Definition: CompositeState.h:198
virtual bool operator==(const CompositeState &_other) const noexcept
Definition: CompositeState.h:231
virtual void InitializeLocalCfgs() noexcept
Initialize the set of local configurations if not already done.
Definition: CompositeState.h:490
CompositeGraph< CompositeState, CompositeEdgeType > GroupGraphType
Definition: CompositeState.h:38
A group of one or more robots.
Definition: RobotGroup.h:17
Definition: PMPLExceptions.h:62