PreviewControl.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2006, 2007, 2008, 2009, 2010,
3  *
4  * Florent Lamiraux
5  * Mathieu Poirier
6  * Olivier Stasse
7  *
8  * JRL, CNRS/AIST
9  *
10  * This file is part of walkGenJrl.
11  * walkGenJrl is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * walkGenJrl is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Lesser Public License for more details.
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with walkGenJrl. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * Research carried out within the scope of the
24  * Joint Japanese-French Robotics Laboratory (JRL)
25  */
26 
27 /* \doc Object to perform preview control on a cart model */
28 #ifndef _PREVIEW_CONTROL_H_
29 #define _PREVIEW_CONTROL_H_
30 
31 #include <deque>
32 #include <iostream>
33 #include <string>
34 #include <vector>
35 
36 using namespace ::std;
37 
39 #include <SimplePlugin.hh>
40 #include <jrl/walkgen/pgtypes.hh>
41 
42 namespace PatternGeneratorJRL {
43 
48 class PreviewControl : public SimplePlugin {
49  public:
52  SimplePluginManager *lSPM,
53  unsigned int defaultMode = OptimalControllerSolver::MODE_WITH_INITIALPOS,
54  bool computeWeightsAutomatically = false);
55 
58 
62  void ReadPrecomputedFile(string aFileName);
63 
66  Eigen::MatrixXd &x, Eigen::MatrixXd &y, double &sxzmp, double &syzmp,
67  deque<PatternGeneratorJRL::ZMPPosition> &ZMPPositions,
68  unsigned long int lindex, double &zmpx2, double &zmpy2, bool Simulation);
69 
72  int OneIterationOfPreview1D(Eigen::MatrixXd &x, double &sxzmp,
73  deque<double> &ZMPPositions,
74  unsigned long int lindex, double &zmpx2,
75  bool Simulation);
76 
87  int OneIterationOfPreview1D(Eigen::MatrixXd &x, double &sxzmp,
88  vector<double> &ZMPPositions,
89  unsigned long int lindex, double &zmpx2,
90  bool Simulation);
91 
96  double SamplingPeriod() const;
97 
99  double PreviewControlTime() const;
100 
102  double GetHeightOfCoM() const;
103 
105  void SetSamplingPeriod(double lSamplingPeriod);
106 
108  void SetPreviewControlTime(double lPreviewControlTime);
109 
111  void SetHeightOfCoM(double lZc);
113  bool IsCoherent();
114 
123  void ComputeOptimalWeights(unsigned int mode);
124 
126  void print();
127 
129  virtual void CallMethod(std::string &Method, std::istringstream &astrm);
130 
131  private:
133  Eigen::MatrixXd m_A;
134  Eigen::MatrixXd m_B;
135  Eigen::MatrixXd m_C;
136 
141  Eigen::MatrixXd m_Kx;
143  double m_Ks;
145  Eigen::MatrixXd m_F;
147 
148  /* \name Preview parameters. */
151  double m_PreviewControlTime;
152 
154  double m_SamplingPeriod;
155 
157  long unsigned int m_SizeOfPreviewWindow;
158 
160  double m_Zc;
162 
164  bool m_Coherent;
165 
167  bool m_AutoComputeWeights;
168 
170  unsigned int m_DefaultWeightComputationMode;
171 };
172 } // namespace PatternGeneratorJRL
173 #include <ZMPRefTrajectoryGeneration/ZMPDiscretization.hh>
174 #endif /* _PREVIEW_CONTROL_H_ */
PatternGeneratorJRL::PreviewControl::ReadPrecomputedFile
void ReadPrecomputedFile(string aFileName)
Read the file of parameters aFileName and set the sampling period, the preview control time,...
Definition: PreviewControl.cpp:112
PatternGeneratorJRL::PreviewControl
Class to implement the preview control.
Definition: PreviewControl.hh:48
PatternGeneratorJRL::PreviewControl::GetHeightOfCoM
double GetHeightOfCoM() const
Definition: PreviewControl.cpp:78
PatternGeneratorJRL::PreviewControl::OneIterationOfPreview
int OneIterationOfPreview(Eigen::MatrixXd &x, Eigen::MatrixXd &y, double &sxzmp, double &syzmp, deque< PatternGeneratorJRL::ZMPPosition > &ZMPPositions, unsigned long int lindex, double &zmpx2, double &zmpy2, bool Simulation)
One iteration of the preview control.
Definition: PreviewControl.cpp:287
PatternGeneratorJRL::PreviewControl::ComputeOptimalWeights
void ComputeOptimalWeights(unsigned int mode)
Compute optimal weights.
Definition: PreviewControl.cpp:165
PatternGeneratorJRL::PreviewControl::SetPreviewControlTime
void SetPreviewControlTime(double lPreviewControlTime)
Definition: PreviewControl.cpp:89
OptimalControllerSolver.hh
x
doublereal * x
Definition: qld.cpp:386
PatternGeneratorJRL::PreviewControl::print
void print()
Overloading of << operator.
Definition: PreviewControl.cpp:421
PatternGeneratorJRL::OptimalControllerSolver::MODE_WITH_INITIALPOS
static const unsigned int MODE_WITH_INITIALPOS
Definition: OptimalControllerSolver.hh:147
PatternGeneratorJRL::PreviewControl::SetSamplingPeriod
void SetSamplingPeriod(double lSamplingPeriod)
Setter for the sampling period.
Definition: PreviewControl.cpp:80
pgtypes.hh
PatternGeneratorJRL::PreviewControl::IsCoherent
bool IsCoherent()
Indicates if the weights are coherent with the parameters.
Definition: PreviewControl.cpp:110
PatternGeneratorJRL::PreviewControl::SetHeightOfCoM
void SetHeightOfCoM(double lZc)
Definition: PreviewControl.cpp:98
PatternGeneratorJRL::PreviewControl::PreviewControlTime
double PreviewControlTime() const
Definition: PreviewControl.cpp:74
PatternGeneratorJRL::PreviewControl::CallMethod
virtual void CallMethod(std::string &Method, std::istringstream &astrm)
Overloading method of SimplePlugin.
Definition: PreviewControl.cpp:435
PatternGeneratorJRL::PreviewControl::~PreviewControl
~PreviewControl()
Definition: PreviewControl.cpp:70
PatternGeneratorJRL
\doc Simulate a rigid body
Definition: patterngeneratorinterface.hh:41
PatternGeneratorJRL::PreviewControl::SamplingPeriod
double SamplingPeriod() const
Getter for the sampling period.
Definition: PreviewControl.cpp:72
PatternGeneratorJRL::PreviewControl::OneIterationOfPreview1D
int OneIterationOfPreview1D(Eigen::MatrixXd &x, double &sxzmp, deque< double > &ZMPPositions, unsigned long int lindex, double &zmpx2, bool Simulation)
One iteration of the preview control along one axis (using queues)
Definition: PreviewControl.cpp:328
PatternGeneratorJRL::PreviewControl::PreviewControl
PreviewControl(SimplePluginManager *lSPM, unsigned int defaultMode=OptimalControllerSolver::MODE_WITH_INITIALPOS, bool computeWeightsAutomatically=false)
Definition: PreviewControl.cpp:38