INOS
cinosmovepathinterpolator.h
Go to the documentation of this file.
1 //******************************************************************************
26 //******************************************************************************
27 #ifndef INC_CINOSMOVEPATHINTERPOLATOR_H
28 #define INC_CINOSMOVEPATHINTERPOLATOR_H
29 //------------------------------------------------------------------------------
30 // defines
31 //------------------------------------------------------------------------------
32 //
33 //------------------------------------------------------------------------------
34 // includes
35 //------------------------------------------------------------------------------
36 //
37 #include <map>
38 #include <functional>
39 //
40 // system
41 #include <inos.h>
42 #include <cinosbaseramp.h>
43 //
44 // C++
45 //
46 // project
47 //
48 //------------------------------------------------------------------------------
49 // type definitions
50 //------------------------------------------------------------------------------
51 //
52 //
53 //------------------------------------------------------------------------------
54 // macros
55 //------------------------------------------------------------------------------
56 //
57 #define SECURE_INC(index) \
58  if (index<(DF_INOS_MOVEPATH_MAX_POINTS-1)){ \
59  index++; \
60  } \
61  else { \
62  return INOS_MOVEPATH_ERROR_ITP_MAX_SEGMENTS; \
63  }
64 
65 
66 #define INOS_REGISTER_MOVEPATH_INTERPOLATOR(aName, aClass ) \
67  static int aClass##RegistrationRet = CINOSMovePathInterpolator::AddInterpolator(aName, ([](CINOSMovePathCurve* c, CINOSMovePath* p){return new aClass(c, p);}));
68 
69 //------------------------------------------------------------------------------
70 // forwards
71 //------------------------------------------------------------------------------
72 //
73 class CINOSMovePathCurve;
74 class CINOSMovePath;
75 class CINOSMovePathInterpolatorSegment;
76 //
77 //------------------------------------------------------------------------------
78 // class definition
79 //------------------------------------------------------------------------------
80 //
82 {
83 
84  //--- user interface -------------------------------------------------------
85 
86  // public member functions
87  public :
88 
89  // position handling
90 
92  virtual void GetPosition(double adP, CINOSMovePathSegment*& opSegment,
93  TINOSMovePathVec& ovPos);
95  virtual void GetDirection(double adP,
96  TINOSMovePathVec& ovDir);
98  virtual void GetDirectionLast(TINOSMovePathVec& ovDir);
100  virtual void GetDerivative(uint32 auLevel, double adP,
101  TINOSMovePathVec& ovDer);
103  virtual void GetD2max(double adBgn, double adEnd, TINOSMovePathVec& aD2max);
105  virtual void GetD3max(double adBgn, double adEnd, TINOSMovePathVec& aD3max);
106 
108  virtual double GetCurveLength();
109 
111  virtual bool IsCurveContinuous(uint32 auLevel)
112  {
113  // assume no
114  return false;
115  }
116 
118  virtual uint32 Prepare();
119 
120  CINOSMovePathInterpolatorSegment* GetFirstSegment() {
121  return m_pFirstSegment;
122  }
123 
124  CINOSMovePathInterpolatorSegment* GetLastSegment() {
125  return m_pLastSegment;
126  }
127 
128  void AddSegment(CINOSMovePathInterpolatorSegment* apSegment);
129 
130  virtual uint32 ConnectSegments(CINOSMovePathInterpolator* apOther);
131  // trajectory interface
132 
133 
134 
135  static CINOSMovePathInterpolator* CreateInterpolator(
136  const char* apInterpolatorType,
137  CINOSMovePathCurve* apCurve,
138  CINOSMovePath* apMovePath);
139 
140  typedef std::function<CINOSMovePathInterpolator* (CINOSMovePathCurve*, CINOSMovePath*)> TINOSInterpolatorConstructor;
141 
143  static int AddInterpolator(const char* apInterpolatorType, const TINOSInterpolatorConstructor& constructor_call);
144 
146  static bool CheckInterpolatorType(const char* apInterpolatorType);
147 
148  //--- internals ------------------------------------------------------------
149 
150  friend class CINOSMovePath;
153  BaseCleanup();
154  };
155 
156  // constructor / destructor
157  protected :
160  CINOSMovePathCurve* apCurve,
161  class CINOSMovePath* apPath = NULL);
162 
164  virtual void Cleanup();
165 
168  { return m_pPath; };
170  void SetPath(class CINOSMovePath* apPath)
171  { m_pPath = apPath; };
173  class CINOSMovePathCurve* GetCurve();
174 
176  bool IsContinuous(CINOSMovePathSegment* apSegment1,
177  CINOSMovePathSegment* apSegment2, uint32 auLevel);
178 
180  bool IsBlendingRequired(CINOSMovePathSegment* apSegment1,
181  CINOSMovePathSegment* apSegment2);
183  bool IsBlendingAllowed(CINOSMovePathSegment* apSegment1,
184  CINOSMovePathSegment* apSegment2);
185 
187  virtual CINCOObject* RequestRegister();
188 
189 
191  void ReleaseRegister();
192 
194  CINCOObject* GetRegister()
195  {
196  return m_pRegister;
197  }
198 
199  typedef std::map<std::string, TINOSInterpolatorConstructor> TINOSInterpolatorMap;
201  static TINOSInterpolatorMap& GetInterpolatorsMap();
202 
203 
204  private:
206  void BaseCleanup();
207 
208 
209  // protected members
210  protected :
212  inosName32 m_cType;
216  char m_cSpeedSet[64];
220  double m_dTolerance;
222  double m_dCycleTime;
225 
227  uint32 m_uRegisterCnt = 0;
229  CINCOObject* m_pRegister = nullptr;
230 
231  CINOSMovePathCurve* m_pCurve;
232 
234  class CINOSMovePathInterpolatorSegment* m_pFirstSegment = nullptr;
235  class CINOSMovePathInterpolatorSegment* m_pLastSegment = nullptr;
236 
237  // dynamic
239 };
240 
241 //------------------------------------------------------------------------------
242 // end of file
243 //------------------------------------------------------------------------------
244 
245 #endif // INC_CINOSMOVEPATHINTERPOLATOR_H
CINOSMovePathInterpolator::m_pFirstSegment
class CINOSMovePathInterpolatorSegment * m_pFirstSegment
array of interpolator segments
Definition: cinosmovepathinterpolator.h:234
CINOSMovePathInterpolator::IsBlendingAllowed
bool IsBlendingAllowed(CINOSMovePathSegment *apSegment1, CINOSMovePathSegment *apSegment2)
return true if blending between segment 1 and 2 allowed
CINOSMovePathInterpolator::GetD3max
virtual void GetD3max(double adBgn, double adEnd, TINOSMovePathVec &aD3max)
get max D3 vector of given range
CINOSMovePathInterpolator::GetInterpolatorsMap
static TINOSInterpolatorMap & GetInterpolatorsMap()
get interpolatos map, to avoid inserting before initialization
CINOSMovePathInterpolator::IsCurveContinuous
virtual bool IsCurveContinuous(uint32 auLevel)
check if curve continuous
Definition: cinosmovepathinterpolator.h:111
CINOSMovePathInterpolator::GetD2max
virtual void GetD2max(double adBgn, double adEnd, TINOSMovePathVec &aD2max)
get max D2 vector of given range
CINOSMovePathInterpolator::m_cType
inosName32 m_cType
interpolator type
Definition: cinosmovepathinterpolator.h:212
CINOSMovePathInterpolator::CINOSMovePathInterpolator
CINOSMovePathInterpolator(CINOSMovePathCurve *apCurve, class CINOSMovePath *apPath=NULL)
constructor
CINOSMovePathInterpolator::IsContinuous
bool IsContinuous(CINOSMovePathSegment *apSegment1, CINOSMovePathSegment *apSegment2, uint32 auLevel)
return true if segment 1 and 2 are auLevel continuous
cinosbaseramp.h
Short comment.
CINOSMovePathInterpolator::GetRegister
CINCOObject * GetRegister()
get pointer to inco registration (if any)
Definition: cinosmovepathinterpolator.h:194
CINOSMovePathInterpolator::RequestRegister
virtual CINCOObject * RequestRegister()
return pointer to inco registration
CINOSMovePathInterpolator::GetPath
class CINOSMovePath * GetPath()
get pointer to my path
Definition: cinosmovepathinterpolator.h:167
CINOSMovePathInterpolator::m_pPath
class CINOSMovePath * m_pPath
pointer to my path
Definition: cinosmovepathinterpolator.h:214
CINOSMovePathInterpolator::GetDerivative
virtual void GetDerivative(uint32 auLevel, double adP, TINOSMovePathVec &ovDer)
get auLevel derivative vector at 'adP'
CINOSMovePathInterpolator::~CINOSMovePathInterpolator
virtual ~CINOSMovePathInterpolator()
destructor
Definition: cinosmovepathinterpolator.h:152
CINOSMovePathInterpolator::GetDirectionLast
virtual void GetDirectionLast(TINOSMovePathVec &ovDir)
get direction vector at the end
CINOSMovePathInterpolator::m_pRegister
CINCOObject * m_pRegister
pointer to inco registration
Definition: cinosmovepathinterpolator.h:229
CINOSMovePathInterpolator::IsBlendingRequired
bool IsBlendingRequired(CINOSMovePathSegment *apSegment1, CINOSMovePathSegment *apSegment2)
return true if blending between segment 1 and 2 required
CINOSMovePathInterpolator
Definition: cinosmovepathinterpolator.h:81
CINOSMovePathInterpolator::GetCurveLength
virtual double GetCurveLength()
get curve length
CINOSMovePathInterpolator::m_dCycleTime
double m_dCycleTime
cycle time
Definition: cinosmovepathinterpolator.h:222
CINOSMovePathInterpolator::CheckInterpolatorType
static bool CheckInterpolatorType(const char *apInterpolatorType)
check if an interpolator with the given name is in the interpolators map
CINOSMovePathInterpolator::m_dCycleTime_1
double m_dCycleTime_1
inverse cycle time
Definition: cinosmovepathinterpolator.h:224
CINOSMovePathInterpolator::GetDirection
virtual void GetDirection(double adP, TINOSMovePathVec &ovDir)
get direction vector at 'adP'
CINOSMovePathInterpolator::m_cSpeedSet
char m_cSpeedSet[64]
speedset name
Definition: cinosmovepathinterpolator.h:216
CINOSMovePathInterpolator::SetPath
void SetPath(class CINOSMovePath *apPath)
set pointer to my path
Definition: cinosmovepathinterpolator.h:170
CINOSMovePath
Definition: cinosmovepath.h:565
CINOSMovePathInterpolator::Cleanup
virtual void Cleanup()
cleanup
CINOSMovePathSegment
Definition: cinosmovepathsegment.h:44
CINOSMovePathInterpolator::m_uRegisterCnt
uint32 m_uRegisterCnt
inco tree registration counter
Definition: cinosmovepathinterpolator.h:227
CINOSMovePathCurve
Definition: cinosmovepathcurve.h:55
CINOSMovePathInterpolator::m_sSpeedSet
SINOSRampParam m_sSpeedSet
speedset
Definition: cinosmovepathinterpolator.h:218
CINOSMovePathInterpolator::AddInterpolator
static int AddInterpolator(const char *apInterpolatorType, const TINOSInterpolatorConstructor &constructor_call)
add new interpolator constructor to the interplators map
CINOSMovePathInterpolator::GetCurve
class CINOSMovePathCurve * GetCurve()
get pointer to my curve
CINOSMovePathInterpolator::GetPosition
virtual void GetPosition(double adP, CINOSMovePathSegment *&opSegment, TINOSMovePathVec &ovPos)
get position vector at 'adP'
DECLARE_DYNAMIC
#define DECLARE_DYNAMIC(aClass)
Definition: cinospartitionmemory.h:328
SINOSRampParam
ramp parameters
Definition: cinosbaseramp.h:502
CINOSMovePathInterpolator::ReleaseRegister
void ReleaseRegister()
release inco registration
CINOSMovePathInterpolator::m_dTolerance
double m_dTolerance
requested tolerance
Definition: cinosmovepathinterpolator.h:220
CINOSMovePathInterpolator::Prepare
virtual uint32 Prepare()
do precalculation