Klamp't  0.8.1
MultiPath.h
1 #ifndef MULTI_PATH_H
2 #define MULTI_PATH_H
3 
4 #include "DynamicPath.h"
5 #include <Klampt/Contact/Hold.h>
6 #include <Klampt/Contact/Stance.h>
7 #include <KrisLibrary/planning/GeneralizedBezierCurve.h>
8 #include <KrisLibrary/utils/PropertyMap.h>
9 #include <KrisLibrary/math/vector.h>
10 using namespace std;
11 
12 class TiXmlElement;
13 
29 class MultiPath
30 {
31  public:
32  bool Load(const string& fn);
33  bool Save(const string& fn) const;
34  bool Load(TiXmlElement* in);
35  bool Save(TiXmlElement* out) const;
36  size_t NumSections() const { return sections.size(); }
38  bool IsValid() const;
41  bool IsContinuous(Real tol=0.0) const;
43  bool HasTiming(int section=0) const;
45  bool HasVelocity(int section=0) const;
47  bool HasConstraints(int section=0) const;
49  bool HasContacts(int section=0) const;
51  void GetMilestones(vector<Vector>& milestones,int section=0) const;
54  void GetTimedMilestones(vector<Real>& times,vector<Vector>& milestones,int section=0) const;
57  bool GetDynamicPath(ParabolicRamp::DynamicPath& path,int section=0) const;
60  void SetMilestones(const vector<Vector>& milestones,int section=0);
63  void SetTimedMilestones(const vector<Real>& times,const vector<Vector>& milestones,int section=0);
66  void SetDynamicPath(const ParabolicRamp::DynamicPath& path,int section=0);
68  Real StartTime() const;
70  Real EndTime() const;
72  Real Duration() const;
77  void SetDuration(Real duration,bool uniformSectionTimes=true);
81  void SetSmoothTiming(Real duration,bool uniformSectionTimes=true);
86  void Concat(const MultiPath& suffix,bool relative=true);
88  void GetIKProblem(vector<IKGoal>& goals,int section=0) const;
91  void SetIKProblem(const vector<IKGoal>& goals,int section=0);
93  void GetStance(Stance& stance,int section=0) const;
96  void SetStance(const Stance& stance,int section=0);
98  void SetHold(const string& str,const Hold& h);
100  bool GetHold(const string& str,Hold& h) const;
103  int TimeToSection(Real time) const;
104 
105  enum InterpPolicy { InterpLinear, InterpCubic };
108  int Evaluate(Real time,GeneralizedCubicBezierCurve& curve,Real& duration,Real& u,InterpPolicy policy=InterpCubic) const;
109  int Evaluate(Real time,Vector& q,InterpPolicy policy=InterpCubic) const;
110  int Evaluate(Real time,Vector& q,Vector& v,InterpPolicy policy=InterpCubic) const;
111 
112  struct PathSection
113  {
114  PropertyMap settings;
115 
116  //section-specific constraints
117  vector<IKGoal> ikGoals;
118  vector<Hold> holds;
119  vector<int> holdIndices; //indexes into the holdSet array
120  vector<string> holdNames; //indexes into the holdSet array
121 
122  vector<Real> times;
123  vector<Vector> milestones;
124  vector<Vector> velocities;
125  };
126 
127  //typically store things like name, robot, scenario, etc
128  PropertyMap settings;
129  vector<PathSection> sections;
130  vector<Hold> holdSet;
131  vector<string> holdSetNames;
132 };
133 
134 ostream& operator << (ostream& out,const MultiPath& path);
135 
136 #endif
A single contact between the robot and the environment.
Definition: Hold.h:26
A very general multi-section path container.
Definition: MultiPath.h:29
A collection of holds.
Definition: Stance.h:19
A bounded-velocity, bounded-acceleration trajectory consisting of parabolic ramps.
Definition: DynamicPath.h:114
Structures defining the finalized contacts used in stances.
Definition: MultiPath.h:112