00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __GT2005HeadPathPlanner_h__
00010 #define __GT2005HeadPathPlanner_h__
00011
00012 #include "Tools/Math/Vector3.h"
00013 #include "Representations/Perception/SensorDataBuffer.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 class GT2005HeadPathPlanner
00024 {
00025 public:
00026
00027
00028
00029
00030
00031
00032
00033 void init(const Vector3<double>* vectors=0, long* durations=0, int numberOfVectors=0,bool optimizeTimings=true);
00034 void oldInit(const Vector3<double>* vectors=0,int numberOfVectors=0, long duration=0)
00035 {
00036 if (numberOfVectors==1)
00037 {
00038 long durations[1]={duration};
00039 init(vectors,durations,1);
00040 }
00041 else
00042 {
00043
00044 if (numberOfVectors!=0)
00045 {
00046
00047 long chunkedDuration = duration / numberOfVectors;
00048 long durations[maxNumberOfPoints+1];
00049
00050 durations[0]=0;
00051 for (int i=1;i<=numberOfVectors;i++)
00052 durations[i]=chunkedDuration;
00053 init(vectors,durations,numberOfVectors);
00054 }
00055 }
00056 }
00057
00058
00059
00060
00061
00062 GT2005HeadPathPlanner(const SensorDataBuffer& sensorDataBuffer):lastNeckTilt(0),lastHeadPan(0),lastHeadTilt(0),currentPoint(0),currentFrame(0),numberOfFrames(0),numberOfPoints(0),sensorDataBuffer(sensorDataBuffer) {}
00063
00064
00065
00066
00067
00068
00069 bool getAngles(double& neckTilt, double& headPan, double& headTilt);
00070
00071
00072
00073
00074
00075 inline bool isLastPathFinished() { return (currentFrame>=numberOfFrames); }
00076
00077
00078
00079 long calculateHeadTiming(Vector3<double> &pos1,Vector3<double> &pos2);
00080
00081
00082 bool headPositionReached(Vector3<double> pos);
00083
00084
00085
00086 static const double minimumHeadSpeed;
00087
00088
00089 double lastNeckTilt;
00090
00091
00092 double lastHeadPan;
00093
00094
00095 double lastHeadTilt;
00096
00097
00098 double headPathSpeedNeckTilt,headPathSpeedHeadPan,headPathSpeedHeadTilt;
00099
00100
00101 const SensorDataBuffer& sensorDataBuffer;
00102
00103
00104 private:
00105
00106
00107
00108
00109
00110 long calculateDurationsSum(long* duration, int durations);
00111
00112
00113
00114 long currentPoint;
00115
00116
00117 long currentFrame;
00118
00119
00120 long numberOfFrames;
00121
00122
00123
00124 enum {maxNumberOfPoints = 20};
00125
00126
00127 long numberOfPoints;
00128
00129
00130 Vector3<double> points[maxNumberOfPoints];
00131
00132
00133 double firstFrame[maxNumberOfPoints];
00134
00135 };
00136
00137
00138 #endif //GT2005HeadPathPlanner