Parasol Planning Library (PPL)
GroupCfg.h
Go to the documentation of this file.
1 #ifndef PPL_GROUP_CFG_H_
2 #define PPL_GROUP_CFG_H_
3 
4 #include <cstddef>
5 #include <iostream>
6 #include <vector>
7 
14 
15 #include "nonstd.h"
16 #include "Transformation.h"
17 #include "Vector.h"
18 
19 class Environment;
20 class Robot;
21 class RobotGroup;
22 
23 
38 template <typename GraphType>
39 class GroupCfg final : public CompositeState<GraphType> {
40 
41  public:
42 
45 
48 
49  typedef typename BaseType::VID VID;
51  typedef typename BaseType::CfgType IndividualCfg;
52 
58  typedef std::vector<size_t> Formation;
59 
63 
67  explicit GroupCfg(GroupRoadmapType* const& _groupMap = nullptr);
68 
71  explicit GroupCfg(RobotGroup* const& _group);
72 
76 
80  bool operator==(const GroupCfg& _other) const noexcept;
81 
85  bool operator<(const GroupCfg& _other) const noexcept;
86 
90 
95  GroupCfg operator+(const GroupCfg& _other) const;
96 
101  GroupCfg operator-(const GroupCfg& _other) const;
102 
107  GroupCfg operator*(const double& _other) const;
108 
111  GroupCfg& operator+=(const GroupCfg& _other);
112 
115  GroupCfg& operator-=(const GroupCfg& _other);
116 
119  GroupCfg& operator*=(const double& _val);
120 
126 
128  GroupRoadmapType* GetGroupRoadmap() const noexcept;
129 
135  void SetGroupRoadmap(GroupRoadmapType* const _newRoadmap);
136 
140 
142  bool IsNonholonomic() const noexcept;
143 
145  size_t CompositeDOF() const;
146 
148  double Magnitude() const;
149 
151  double PositionMagnitude() const;
152 
154  double OrientationMagnitude() const;
155 
159 
164  void ConfigureRobot() const;
165 
172  bool WithinResolution(const GroupCfg& _cfg, const double _posRes,
173  const double _oriRes) const;
174 
178 
179  // Note: Using these functions will make this configuration utilize the
180  // local cfgs, which won't be in group/individual roadmaps until added.
181 
182 
192  void RotateFormationAboutLeader(const Formation& _robotList,
193  const mathtool::Orientation& _rotation,
194  const bool _debug = false);
195 
207  void ApplyTransformationForRobots(const Formation& _robotList,
208  const mathtool::Transformation& _transform,
209  const mathtool::Transformation& _relativeTransform
210  = mathtool::Transformation());
211 
212 
219  void AddDofsForRobots(const std::vector<double>& _dofs,
220  const Formation& _robots);
221 
222 
229  void AddDofsForRobots(const mathtool::Vector3d& _dofs,
230  const Formation& _robots);
231 
237  void OverwriteDofsForRobots(const std::vector<double>& _dofs,
238  const Formation& _robots);
239 
240 
246  void OverwriteDofsForRobots(const mathtool::Vector3d& _dofs,
247  const Formation& _robots);
248 
249 
254  void OverwriteDofsForRobots(const GroupCfg& _fromCfg,
255  const Formation& _robots);
256 
258  void OverwriteDofsForRobots(const GroupCfg& _fromCfg,
259  const std::vector<Robot*>& _robots);
260 
261 
265  void SetData(const std::vector<double>& _dofs);
266 
272  void FindIncrement(const GroupCfg& _start, const GroupCfg& _goal,
273  const int _nTicks);
274 
282  void FindIncrement(const GroupCfg& _start, const GroupCfg& _goal,
283  int* const _nTicks, const double _positionRes,
284  const double _orientationRes);
285 
291  bool InBounds(const Boundary* const _b) const noexcept;
293  bool InBounds(const Environment* const _env) const noexcept;
294 
300  void GetRandomGroupCfg(const Boundary* const _b);
301 
305  void GetRandomGroupCfg(Environment* _env);
306 
311  template<typename DistanceMetricPointer>
312  void GetRandomRay(const double _length, DistanceMetricPointer _dm, const bool _norm=true);
313 
315  virtual void NormalizeOrientation(const std::vector<size_t>& _robots = {})
316  noexcept;
317 
321 
322  std::string PrettyPrint(const size_t _precision = 4) const;
323 
325 
326  private:
327 
330 
332  virtual void InitializeLocalCfgs() noexcept override;
333 
335 
336 };
337 
338 template <typename GraphType>
339 GroupCfg<GraphType>::
340 GroupCfg(GroupRoadmapType* const& _groupMap)
341  : CompositeState<GraphType>((GroupGraphType*)_groupMap) {}
342 
343 template <typename GraphType>
345 GroupCfg(RobotGroup* const& _group) : CompositeState<GraphType>(_group) {}
346 
347 /*--------------------------------- Equality ---------------------------------*/
348 
349 template <typename GraphType>
350 bool
352 operator==(const GroupCfg& _other) const noexcept {
353  // If _other is for another group, these are not the same.
354  if(this->m_group != _other.m_group)
355  return false;
356 
357  // If _other is from another map, these are not the same.
358  if(this->m_groupMap != _other.m_groupMap)
359  return false;
360 
361  // Else, compare VIDs if both are valid, or by-value other wise.
362  for(size_t i = 0; i < this->m_vids.size(); ++i) {
363  const VID thisVID = this->m_vids[i],
364  otherVID = _other.m_vids[i];
365 
366  if(thisVID != INVALID_VID and otherVID != INVALID_VID) {
367  if(thisVID != otherVID)
368  return false;
369  }
370  else if(this->GetRobotCfg(i) != _other.GetRobotCfg(i))
371  return false;
372  }
373 
374  return true;
375 }
376 
377 
378 template <typename GraphType>
379 bool
381 operator<(const GroupCfg& _other) const noexcept {
382 
383  const auto& robots = this->GetRobots();
384 
385  for(size_t i = 0; i < robots.size(); i++) {
386  const auto& cfg1 = this->GetRobotCfg(i);
387  const auto& cfg2 = _other.GetRobotCfg(i);
388  if(cfg1 < cfg2)
389  return true;
390  else if(cfg2 < cfg1)
391  return false;
392  }
393 
394  return false;
395 }
396 /*-------------------------------- Arithmetic --------------------------------*/
397 
398 template <typename GraphType>
401 operator+(const GroupCfg& _other) const {
402  GroupCfg newCfg = *this;
403  return (newCfg += _other);
404 }
405 
406 
407 template <typename GraphType>
410 operator-(const GroupCfg& _other) const {
411  GroupCfg newCfg = *this;
412  return (newCfg -= _other);
413 }
414 
415 
416 template <typename GraphType>
419 operator*(const double& _other) const {
420  GroupCfg newCfg = *this;
421  return (newCfg *= _other);
422 }
423 
424 
425 template <typename GraphType>
428 operator+=(const GroupCfg& _other) {
429  // We must require the exact same group, which indicates everything
430  // lines up between the two cfgs (namely the exact robots/order of the group).
431  if(this->m_group != _other.m_group)
432  throw RunTimeException(WHERE, "Cannot add GroupCfgs with different groups!");
433 
434  // We will be using the local cfgs, as we don't want to require any cfgs that
435  // use this operator to have to add cfgs to roadmaps.
436  for(size_t i = 0; i < this->GetNumRobots(); ++i)
437  this->SetRobotCfg(i, this->GetRobotCfg(i) + _other.GetRobotCfg(i));
438 
439  return *this;
440 }
441 
442 
443 template <typename GraphType>
446 operator-=(const GroupCfg& _other) {
447  // We must require the exact same group, which indicates everything
448  // lines up between the two cfgs (namely the exact robots/order of the group).
449  if(this->m_group != _other.m_group)
450  throw RunTimeException(WHERE, "Cannot subtract GroupCfgs with different groups!");
451 
452  // We will be using the local cfgs, as we don't want to require any cfgs that
453  // use this operator to have to add cfgs to roadmaps.
454  for(size_t i = 0; i < this->GetNumRobots(); ++i)
455  this->SetRobotCfg(i, this->GetRobotCfg(i) - _other.GetRobotCfg(i));
456 
457  return *this;
458 }
459 
460 
461 template <typename GraphType>
464 operator*=(const double& _val) {
465  // We will be using the local cfgs, as we don't want to require any cfgs that
466  // use this operator to have to add cfgs to roadmaps.
467  for(size_t i = 0; i < this->GetNumRobots(); ++i)
468  this->SetRobotCfg(i, this->GetRobotCfg(i) * _val);
469 
470  return *this;
471 }
472 
473 /*---------------------------- Roadmap Accessors -----------------------------*/
474 
475 template <typename GraphType>
478 GetGroupRoadmap() const noexcept {
479  return (GroupRoadmapType*)this->m_groupMap;
480 }
481 
482 
483 template <typename GraphType>
484 void
486 SetGroupRoadmap(GroupRoadmapType* const _newRoadmap) {
487  // Check that groups are compatible.
488  if(this->m_group != _newRoadmap->GetGroup())
489  throw RunTimeException(WHERE) << "Trying to change roadmaps on incompatible "
490  << "groups!";
491 
492  // Set the group graph of the composite state.
493  this->m_groupMap = (GroupGraphType*) _newRoadmap;
494 
495  // Put all individual cfgs into the group cfg so that all are local:
496  for(size_t i = 0; i < this->GetNumRobots(); ++i)
497  this->SetRobotCfg(i, IndividualCfg(this->GetRobotCfg(i)));
498 }
499 
500 /*------------------------------ DOF Accessors -------------------------------*/
501 
502 template <typename GraphType>
503 bool
505 IsNonholonomic() const noexcept {
506  for(auto robot : this->GetRobots())
507  if(robot->IsNonholonomic())
508  return true;
509  return false;
510 }
511 
512 
513 template <typename GraphType>
514 size_t
516 CompositeDOF() const {
517  size_t dofSum = 0;
518  for(auto robot : this->GetRobots())
519  dofSum += robot->GetMultiBody()->DOF();
520  return dofSum;
521 }
522 
523 
524 template <typename GraphType>
525 double
527 Magnitude() const {
528  double result = 0;
529  for(size_t i = 0; i < this->GetNumRobots(); ++i) {
530  const double m = this->GetRobotCfg(i).Magnitude();
531  result += m * m;
532  }
533  return std::sqrt(result);
534 }
535 
536 
537 template <typename GraphType>
538 double
540 PositionMagnitude() const {
541  double result = 0;
542  for(size_t i = 0; i < this->GetNumRobots(); ++i) {
543  const double m = this->GetRobotCfg(i).PositionMagnitude();
544  result += m * m;
545  }
546  return std::sqrt(result);
547 }
548 
549 
550 template <typename GraphType>
551 double
553 OrientationMagnitude() const {
554  double result = 0;
555  for(size_t i = 0; i < this->GetNumRobots(); ++i) {
556  const double m = this->GetRobotCfg(i).OrientationMagnitude();
557  result += m * m;
558  }
559  return std::sqrt(result);
560 }
561 
562 /*------------------------- Configuration Helpers ----------------------------*/
563 
564 template <typename GraphType>
565 void
567 ConfigureRobot() const {
568  for(size_t i = 0; i < this->GetNumRobots(); ++i)
569  this->GetRobotCfg(i).ConfigureRobot();
570 }
571 
572 
573 template <typename GraphType>
574 bool
576 WithinResolution(const GroupCfg& _cfg, const double _posRes,
577  const double _oriRes) const {
578  for(size_t i = 0; i < this->GetNumRobots(); ++i)
579  if(!this->GetRobotCfg(i).WithinResolution(_cfg.GetRobotCfg(i), _posRes, _oriRes))
580  return false;
581 
582  return true;
583 }
584 
585 /*------------------------------DOF Modifiers---------------------------------*/
586 
587 template <typename GraphType>
588 void
590 RotateFormationAboutLeader(const Formation& _robotList,
591  const mathtool::Orientation& _rotation, const bool _debug) {
595 
598  ConfigureRobot(); // Configure all individual cfgs.
599 
600  const size_t leaderIndex = _robotList[0];
601 
602  // Get transformation of leader before rotation:
603  const IndividualCfg& leaderCfg = this->GetRobotCfg(leaderIndex);
604 
605  // TODO update this to handle multiple bodies per robot.
606  // Use the multibody's body 0, since we assume each MB just has a single body.
607  mathtool::Transformation initialLeaderTransform = leaderCfg.GetMultiBody()->
608  GetBody(0)->GetWorldTransformation();
609 
610  const mathtool::Transformation rotation(mathtool::Vector3d(0,0,0), _rotation);
611 
612  if(_debug)
613  std::cout << "Rotating bodies " << _robotList << " with rotation = "
614  << rotation << std::endl;
615 
616  // The transform to be applied to all parts (including the first one). We
617  // move the part to its relative world position with A at the world origin,
618  // then the rotation is applied, and we return the part to its relative
619  // position from A.
620  const mathtool::Transformation transform = initialLeaderTransform * rotation;
621 
622  ApplyTransformationForRobots(_robotList, transform, initialLeaderTransform);
623 }
624 
625 
626 template <typename GraphType>
627 void
629 ApplyTransformationForRobots(const Formation& _robotList,
630  const mathtool::Transformation& _transform,
631  const mathtool::Transformation& _relativeTransform) {
632  //Compute each robot's needed transformation and set dofs in cfg.
633  for (const size_t robotIndex : _robotList) {
634  const IndividualCfg& robotCfg = this->GetRobotCfg(robotIndex);
635 
637  if(robotCfg.GetMultiBody()->GetNumBodies() > 1)
638  throw RunTimeException(WHERE) << "Multiple bodies not supported!";
639 
640  // Retrieve current position and rotation of robot:
641  const mathtool::Transformation& initialRobotTransform =
642  robotCfg.GetMultiBody()->GetBody(0)->GetWorldTransformation();
643 
644  // From right to left: apply the inverse relative transform to the initial
645  // robot transform (puts the robot into the desired frame). Then apply
646  // the transform given.
647  const mathtool::Transformation newTransformation = _transform *
648  (-_relativeTransform) *
649  initialRobotTransform;
650 
651  // Extract the transformation. Note: This is assuming 6 DOFs!
652  const std::vector<double>& transformed = newTransformation.GetCfg();
653 
654  OverwriteDofsForRobots(transformed, {robotIndex});
655  }
656 }
657 
658 
659 template <typename GraphType>
660 void
662 AddDofsForRobots(const std::vector<double>& _dofs, const Formation& _robots) {
663  for(const size_t robotIndex : _robots) {
664  if(this->IsLocalCfg(robotIndex)) {
665  // We can simply modify the local values, since it's not a roadmap cfg yet
666  IndividualCfg& cfg = this->GetRobotCfg(robotIndex);
667 
668  // Ensure this robot has the correct number of DOF.
669  if(_dofs.size() != cfg.DOF())
670  throw RunTimeException(WHERE) << "Tried to add " << _dofs.size()
671  << "dofs to robot " << robotIndex
672  << ", which has " << cfg.DOF() << " DOFs.";
673 
674  // Update the robot's cfg.
675  for(unsigned int i = 0; i < _dofs.size(); ++i)
676  cfg[i] += _dofs[i];
677  }
678  else {
679  // Must copy the cfg since it is not local.
680  IndividualCfg cfg = this->GetRobotCfg(robotIndex);
681 
682  // Ensure this robot has the correct number of DOF.
683  if(_dofs.size() != cfg.DOF())
684  throw RunTimeException(WHERE) << "Tried to add " << _dofs.size()
685  << "dofs to robot " << robotIndex
686  << ", which has " << cfg.DOF() << " DOFs.";
687 
688  // Update the robot's cfg.
689  for(unsigned int i = 0; i < _dofs.size(); ++i)
690  cfg[i] += _dofs[i];
691  this->SetRobotCfg(robotIndex, std::move(cfg));
692  }
693  }
694 }
695 
696 
697 template <typename GraphType>
698 void
700 AddDofsForRobots(const mathtool::Vector3d& _dofs, const Formation& _robots) {
701  for(const size_t robotIndex : _robots) {
702  IndividualCfg robotCfg = this->GetRobotCfg(robotIndex);
703  for(size_t i = 0; i < robotCfg.PosDOF(); ++i)
704  robotCfg[i] += _dofs[i];
705  this->SetRobotCfg(robotIndex, std::move(robotCfg));
706  }
707 }
708 
709 
710 template <typename GraphType>
711 void
713 OverwriteDofsForRobots(const std::vector<double>& _dofs,
714  const Formation& _robots) {
715  for(const size_t robotIndex : _robots) {
716  IndividualCfg newIndividualCfg(this->GetRobot(robotIndex));
717  newIndividualCfg.SetData(_dofs);
718  this->SetRobotCfg(robotIndex, std::move(newIndividualCfg));
719  }
720 }
721 
722 
723 template <typename GraphType>
724 void
726 OverwriteDofsForRobots(const mathtool::Vector3d& _dofs,
727  const Formation& _robots) {
728  for(const size_t robotIndex : _robots) {
729  IndividualCfg newIndividualCfg(this->GetRobot(robotIndex));
730  newIndividualCfg.SetLinearPosition(_dofs);
731  this->SetRobotCfg(robotIndex, std::move(newIndividualCfg));
732  }
733 }
734 
735 
736 template <typename GraphType>
737 void
739 OverwriteDofsForRobots(const GroupCfg& _fromCfg, const Formation& _robots) {
740  for(const size_t robotIndex : _robots) {
741  IndividualCfg robotCfg = _fromCfg.GetRobotCfg(robotIndex);
742  this->SetRobotCfg(robotIndex, std::move(robotCfg));
743  }
744 }
745 
746 
747 template <typename GraphType>
748 void
750 OverwriteDofsForRobots(const GroupCfg& _fromCfg,
751  const std::vector<Robot*>& _robots) {
752  auto fromGroup = _fromCfg.GetGroupRoadmap()->GetGroup(),
753  toGroup = this->m_groupMap->GetGroup();
754 
755  for(Robot* const robot : _robots) {
756  const size_t fromIndex = fromGroup->GetGroupIndex(robot),
757  toIndex = toGroup->GetGroupIndex(robot);
758  IndividualCfg robotCfg = _fromCfg.GetRobotCfg(fromIndex);
759  this->SetRobotCfg(toIndex, std::move(robotCfg));
760  }
761 }
762 
763 
764 template <typename GraphType>
765 void
767 SetData(const std::vector<double>& _dofs) {
768  if(_dofs.size() != CompositeDOF())
769  throw RunTimeException(WHERE) << "Tried to set " << _dofs.size()
770  << " DOFs on a robot group with "
771  << CompositeDOF() << " DOFs.";
772 
773  size_t compositeIndex = 0;
774  for(size_t i = 0; i < this->GetNumRobots(); ++i) {
775  const size_t robotDof = this->GetRobot(i)->GetMultiBody()->DOF();
776  IndividualCfg& robotCfg = this->GetRobotCfg(i);
777 
778  for(size_t i = 0; i < robotDof; ++i, ++compositeIndex)
779  robotCfg[i] = _dofs[compositeIndex];
780  }
781 }
782 
783 
784 template <typename GraphType>
785 void
787 FindIncrement(const GroupCfg& _start, const GroupCfg& _goal, const int _nTicks) {
788  // Need positive number of ticks.
789  if(_nTicks <= 0)
790  throw RunTimeException(WHERE) << "Divide by 0";
791  if(_start.m_group != _goal.m_group)
792  throw RunTimeException(WHERE) << "Cannot use two different groups "
793  << "with this operation currently!";
794 
795  // For each robot in the group, find the increment for the individual cfg
796  // given the number of ticks found.
797  for(size_t i = 0; i < this->GetNumRobots(); ++i) {
798  IndividualCfg incr(this->GetRobot(i));
799  incr.FindIncrement(_start.GetRobotCfg(i), _goal.GetRobotCfg(i), _nTicks);
800  this->SetRobotCfg(i, std::move(incr));
801  }
802 }
803 
804 
805 template <typename GraphType>
806 void
808 FindIncrement(const GroupCfg& _start, const GroupCfg& _goal, int* const _nTicks,
809  const double _positionRes, const double _orientationRes) {
810  const GroupCfg<GraphType> diff = _goal - _start;
811 
812  *_nTicks = std::max(1., std::ceil(std::max(
813  diff.PositionMagnitude() / _positionRes,
814  diff.OrientationMagnitude() / _orientationRes)));
815 
816  FindIncrement(_start, _goal, *_nTicks);
817 }
818 
819 
820 template <typename GraphType>
821 bool
823 InBounds(const Boundary* const _b) const noexcept {
824  for(size_t i = 0; i < this->GetNumRobots(); ++i)
825  if(!this->GetRobotCfg(i).InBounds(_b))
826  return false;
827 
828  return true;
829 }
830 
831 
832 template <typename GraphType>
833 bool
835 InBounds(const Environment* const _env) const noexcept {
836  return InBounds(_env->GetBoundary());
837 }
838 
839 template <typename GraphType>
840 void
842 GetRandomGroupCfg(const Boundary* const _b) {
843  std::set<Robot*> found;
844  auto group = this->m_group;
845 
846  for(size_t i = 0; i < this->GetNumRobots(); i++) {
847  this->m_vids[i] = INVALID_VID;
848  }
849  InitializeLocalCfgs();
850 
851  auto robots = group->GetRobots();
852  for(size_t i = 0; i < robots.size(); i++) {
853  auto robot = robots[i];
854 
855  // Check if robot cfg was set by formation sampling.
856  if(found.count(robot))
857  continue;
858 
859  // If not, get a random configuration for it.
860  Cfg cfg(robot);
861  cfg.GetRandomCfg(_b);
862 
863  // Save cfg to local cfgs.
864  this->m_localCfgs[i] = cfg;
865  }
866 }
867 
868 template <typename GraphType>
869 void
872  GetRandomGroupCfg(_env->GetBoundary());
873 }
874 
875 template <typename GraphType>
876 void
878 NormalizeOrientation(const std::vector<size_t>& _robots) noexcept {
879  if(_robots.empty()) // Do all robots in this case.
880  for(size_t i = 0; i < this->GetNumRobots(); ++i)
881  this->GetRobotCfg(i).NormalizeOrientation();
882  else
883  for(size_t i : _robots)
884  this->GetRobotCfg(i).NormalizeOrientation();
885 }
886 
887 /*------------------------------ Output Helpers ------------------------------*/
888 
889 template <typename GraphType>
890 std::string
892 PrettyPrint(const size_t _precision) const {
893  std::ostringstream oss;
894  oss.precision(_precision);
895  oss << "{ ";
896  for(size_t i = 0; i < this->GetNumRobots(); ++i) {
897  const IndividualCfg& robotCfg = this->GetRobotCfg(i);
898  if(this->IsLocalCfg(i))
899  oss << "Local: ";
900  oss << robotCfg.PrettyPrint(_precision) << ", ";
901  }
902  oss << " }";
903 
904  return oss.str();
905 }
906 
907 /*----------------------------------------------------------------------------*/
908 
909 template <typename GraphType>
910 void
912 InitializeLocalCfgs() noexcept {
913  // We will assume the local cfgs are initialized if the container size is
914  // correct.
915  const size_t numRobots = this->GetNumRobots();
916  if(this->m_localCfgs.size() == numRobots)
917  return;
918 
919  this->m_localCfgs.clear();
920  this->m_localCfgs.resize(numRobots);
921 
922  for(size_t i = 0; i < numRobots; ++i)
923  this->m_localCfgs[i] = IndividualCfg(this->GetRobot(i));
924 }
925 
926 template <typename GraphType>
927 template <class DistanceMetricPointer>
928 void
930 GetRandomRay(const double _length, DistanceMetricPointer _dm, const bool _norm) {
931  // Randomly sample DOFs.
932 
933  for(size_t j = 0; j < this->GetNumRobots(); ++j) {
934  for(size_t i = 0; i < this->GetRobotCfg(j).DOF(); ++i)
935  this->GetRobotCfg(j)[i] = GRand();
936  }
937  // Scale to appropriate length.
938  _dm->ScaleCfg(_length, *this);
939 
940  // Normalize if requested.
941  if(_norm)
942  NormalizeOrientation();
943 }
944 
945 /*----------------------------------------------------------------------------*/
946 
947 template <typename GraphType>
948 std::ostream&
949 operator<<(std::ostream& _os, const GroupCfg<GraphType>& _groupCfg) {
950  // Might not need to be hidden behind GROUP_MAP, but doing for consistency
951 #ifdef GROUP_MAP
952  _os << "0 ";
953 #endif
954 
955  // Loop through all robots in the group and print each one's cfg in order.
956  for(size_t i = 0; i < _groupCfg.GetNumRobots(); ++i)
957  _os << _groupCfg.GetRobotCfg(i);
958 
959  return _os;
960 }
961 
962 #endif
#define INVALID_VID
Definition: GenericStateGraph.h:23
std::ostream & operator<<(std::ostream &_os, const GroupCfg< GraphType > &_groupCfg)
Definition: GroupCfg.h:949
double GRand(bool _reset)
Definition: MPUtils.cpp:13
#define WHERE
Macro for retrieving info about file, function, and line number.
Definition: RuntimeUtils.h:32
Definition: Boundary.h:30
Definition: Cfg.h:38
virtual void GetRandomCfg(const Boundary *const _b)
Definition: Cfg.cpp:902
Definition: CompositeGraph.h:27
virtual RobotGroup * GetGroup()
Get the robot group.
Definition: CompositeGraph.h:190
Definition: CompositeState.h:26
GraphType::CfgType CfgType
The indiv. graph vertex type.
Definition: CompositeState.h:35
size_t VID
A VID in an individual graph.
Definition: CompositeState.h:33
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
Definition: Environment.h:137
Boundary * GetBoundary() const noexcept
Get the single boundary of the environemnt.
Definition: Environment.cpp:622
Definition: GroupCfg.h:39
CompositeState< GraphType > BaseType
Definition: GroupCfg.h:46
void ApplyTransformationForRobots(const Formation &_robotList, const mathtool::Transformation &_transform, const mathtool::Transformation &_relativeTransform=mathtool::Transformation())
Definition: GroupCfg.h:629
void FindIncrement(const GroupCfg &_start, const GroupCfg &_goal, const int _nTicks)
Definition: GroupCfg.h:787
void GetRandomGroupCfg(const Boundary *const _b)
Definition: GroupCfg.h:842
bool operator==(const GroupCfg &_other) const noexcept
Definition: GroupCfg.h:352
void SetGroupRoadmap(GroupRoadmapType *const _newRoadmap)
Definition: GroupCfg.h:486
bool InBounds(const Boundary *const _b) const noexcept
Definition: GroupCfg.h:823
GroupCfg & operator*=(const double &_val)
Definition: GroupCfg.h:464
GroupCfg operator*(const double &_other) const
Definition: GroupCfg.h:419
GroupRoadmapType * GetGroupRoadmap() const noexcept
Get the group roadmap this group cfg is with respect to.
Definition: GroupCfg.h:478
double Magnitude() const
Compute the composite magnitude.
Definition: GroupCfg.h:527
BaseType::CfgType IndividualCfg
Definition: GroupCfg.h:51
BaseType::GroupGraphType GroupGraphType
Definition: GroupCfg.h:50
GroupCfg operator-(const GroupCfg &_other) const
Definition: GroupCfg.h:410
void SetData(const std::vector< double > &_dofs)
Definition: GroupCfg.h:767
double PositionMagnitude() const
Compute the composite manitude of the positional components.
Definition: GroupCfg.h:540
size_t CompositeDOF() const
Compute the total DOF for this robot group.
Definition: GroupCfg.h:516
GroupRoadmap< GroupCfg, GroupLocalPlan< GraphType > > GroupRoadmapType
Definition: GroupCfg.h:47
GroupCfg operator+(const GroupCfg &_other) const
Definition: GroupCfg.h:401
bool IsNonholonomic() const noexcept
Check if there is a nonholonomic robot in the group.
Definition: GroupCfg.h:505
bool WithinResolution(const GroupCfg &_cfg, const double _posRes, const double _oriRes) const
Definition: GroupCfg.h:576
double OrientationMagnitude() const
Compute the composite magnitude of the orientation components.
Definition: GroupCfg.h:553
std::vector< size_t > Formation
Definition: GroupCfg.h:58
void GetRandomRay(const double _length, DistanceMetricPointer _dm, const bool _norm=true)
Definition: GroupCfg.h:930
virtual void NormalizeOrientation(const std::vector< size_t > &_robots={}) noexcept
Normalize Orientation DOFs for a Group Cfg.
Definition: GroupCfg.h:878
bool operator<(const GroupCfg &_other) const noexcept
Definition: GroupCfg.h:381
void AddDofsForRobots(const std::vector< double > &_dofs, const Formation &_robots)
Definition: GroupCfg.h:662
GroupCfg & operator-=(const GroupCfg &_other)
Definition: GroupCfg.h:446
GroupCfg(GroupRoadmapType *const &_groupMap=nullptr)
Definition: GroupCfg.h:340
void RotateFormationAboutLeader(const Formation &_robotList, const mathtool::Orientation &_rotation, const bool _debug=false)
Definition: GroupCfg.h:590
std::string PrettyPrint(const size_t _precision=4) const
Definition: GroupCfg.h:892
GroupCfg & operator+=(const GroupCfg &_other)
Definition: GroupCfg.h:428
void ConfigureRobot() const
Definition: GroupCfg.h:567
BaseType::VID VID
Definition: GroupCfg.h:49
void OverwriteDofsForRobots(const std::vector< double > &_dofs, const Formation &_robots)
Definition: GroupCfg.h:713
Definition: GroupRoadmap.h:25
A group of one or more robots.
Definition: RobotGroup.h:17
size_t GetGroupIndex(Robot *const _robot) const noexcept
Definition: RobotGroup.cpp:108
Definition: Robot.h:31
Definition: Cfg.h:23
Definition: PMPLExceptions.h:62