libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
smoothing.hpp
1 /*
2  * smoothing.hpp
3  *
4  * Created on: Jun 26, 2009
5  * Author: jmainpri
6  */
7 
8 #ifndef BASEOPTIMIZATION_HPP_
9 #define BASEOPTIMIZATION_HPP_
10 
11 #undef Trajectory
12 
13 #include "API/Trajectory/trajectory.hpp"
14 
15 extern std::vector< std::pair<double,double> > traj_convergence_with_time;
16 
21 namespace API
22 {
23  class Smoothing : public Trajectory
24  {
25  public:
29  Smoothing();
30  Smoothing(const Trajectory& T);
31  Smoothing(Robot* R,traj* t);
32 
33  ~Smoothing();
34 
38  int getRunId() { return m_runId; }
39 
43  void setRunId(int id) { m_runId = id; }
44 
48  void setStep( double step );
49 
53  void resetStep();
54 
58  double getTime() { return m_time; }
59 
63  int getIteration() { return m_Iteration; }
64 
68  void setContextName(std::string name) { m_ContextName = name; }
69 
73  void saveOptimToFile( std::string str );
74 
78  void removeRedundantNodes();
79 
83  void setSortedIndex();
84 
88  confPtr_t getRandConfAlongTraj(double& randDist, bool use_bias);
89 
93  bool oneLoopShortCut();
94 
100 
105  void runShortCut(int nbIteration, int idRun = 0);
106 
107  int removeUselessNodes();
108 
109  protected:
110 
114  bool checkStopConditions( unsigned int iter );
115 
119  std::vector<confPtr_t> get2RandomConf( double step, double& secondDist, double& firstDist);
120 
124  std::vector<confPtr_t> getConfAtStepAlongTraj( double step, double firstDist, double secondDist );
125 
129  bool partialShortcut();
130 
134  bool isLowerCostLargePortion( double lFirst , double lSecond , std::vector<LocalPath*>& paths);
135 
139  double interpolateOneDoF( unsigned int ithActiveDoF , double init , double goal , double alpha );
140 
144  void changeIthActiveDofValueOnConf( Configuration& q, unsigned int ithActiveDoF, double value );
145 
149  void debugShowTraj(double lPrev,double lNext);
150 
151 
156  double getBiasedParamOnTraj();
157 
162  double closestResolutionToStep(double length,double step);
163 
168  double gainOfLastIterations( unsigned int n );
169 
171  void computeStats();
172 
175  void storeCostAndGain( double NewCost, double CurCost );
176 
177  int m_runId;
178 
179  std::string m_ContextName;
180  std::vector<double> m_Selected;
181  int m_nbBiased;
182  int m_nbReallyBiased;
183 
184  double m_currentCost;
185 
186  double m_time;
187 
188  bool m_useAutoStep;
189  double m_step;
190 
191  std::vector< std::pair<double,std::vector<confPtr_t> > > m_convergence_trajs;
192  std::vector< std::pair<double,TrajectoryStatistics> > m_convergence_rate;
193  std::vector<double> m_OptimCost;
194  std::vector<double> m_GainCost;
195 
196  int m_Iteration;
197  bool m_IterationSucceded;
198  std::vector<double> m_GainOfIterations;
199  unsigned int m_MaxNumberOfIterations;
200 
201  private:
202  std::vector<uint> m_IdSorted;
203  bool m_ShortCutBiased;
204  };
205 }
206 
207 #endif /* SHORTCUT_HPP_ */
bool partialShortcut()
PatialShortCut : intependently shortcut each DoFs.
Definition: smoothing.cpp:232
void setSortedIndex()
Set the sorted indexes by cost.
Definition: smoothing.cpp:723
void debugShowTraj(double lPrev, double lNext)
Show the trajectory while being deformed.
Definition: smoothing.cpp:525
void computeStats()
compute the stats
Definition: smoothing.cpp:881
void changeIthActiveDofValueOnConf(Configuration &q, unsigned int ithActiveDoF, double value)
Change the Ith Active Dof on Conf.
Definition: smoothing.cpp:419
Smoothing()
Class constructors and destructors.
Definition: smoothing.cpp:31
void removeRedundantNodes()
Go through all nodes in a deterministic manner.
Definition: smoothing.cpp:453
void setRunId(int id)
Set the run Id.
Definition: smoothing.hpp:43
int getIteration()
Get iteration.
Definition: smoothing.hpp:63
int removeUselessNodes()
Deterministic shortcut.
Definition: smoothing.cpp:1055
std::vector< confPtr_t > get2RandomConf(double step, double &secondDist, double &firstDist)
gets randomly two random configurations
Definition: smoothing.cpp:635
double gainOfLastIterations(unsigned int n)
Compute the gain of the last n succueded iterations.
Definition: smoothing.cpp:855
bool oneLoopShortCut()
One loop of the random shortcut.
Definition: smoothing.cpp:86
Definition: smoothing.hpp:23
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
void setStep(double step)
Set a fixed deformation step.
Definition: smoothing.cpp:72
void runShortCut(int nbIteration, int idRun=0)
Runs the shortcut method for a certain number of iterations.
Definition: smoothing.cpp:961
void saveOptimToFile(std::string str)
Save the optimization to a file.
Definition: smoothing.cpp:921
Definition: trajectory.hpp:40
bool isLowerCostLargePortion(double lFirst, double lSecond, std::vector< LocalPath * > &paths)
Compute the subportion of with entire outer localpaths.
Definition: smoothing.cpp:335
double getBiasedParamOnTraj()
Get a parameter on the trajectory which is biased to the high cost parts of the trajectory.
Definition: smoothing.cpp:752
void resetStep()
Use automatic step computation.
Definition: smoothing.cpp:78
void storeCostAndGain(double NewCost, double CurCost)
Store the cost and gain of the iteration in double vectors.
Definition: smoothing.cpp:896
Classe représentant une Configuration d'un Robot.
Definition: configuration.hpp:25
int getRunId()
Get the run Id.
Definition: smoothing.hpp:38
double closestResolutionToStep(double length, double step)
Compute the resolution of a path.
Definition: smoothing.cpp:577
std::vector< confPtr_t > getConfAtStepAlongTraj(double step, double firstDist, double secondDist)
gets randomly n configurations on the traj between firstDist and secondDist
Definition: smoothing.cpp:593
confPtr_t getRandConfAlongTraj(double &randDist, bool use_bias)
Get a random confiruation along the trajectroy that can be biased.
Definition: smoothing.cpp:778
double interpolateOneDoF(unsigned int ithActiveDoF, double init, double goal, double alpha)
Interpolates a Configuration.
Definition: smoothing.cpp:380
double getTime()
Get the time spent in optimization.
Definition: smoothing.hpp:58
void setContextName(std::string name)
Set Context name.
Definition: smoothing.hpp:68
bool oneLoopShortCutRecompute()
One loop of the random shortcut with recomputation of the trajectory cost.
Definition: smoothing.cpp:144
bool checkStopConditions(unsigned int iter)
stops the trajectory optimization
Definition: smoothing.cpp:797