integrator.hh
Go to the documentation of this file.
1 // BSD 2-Clause License
2 
3 // Copyright (c) 2023, CNRS
4 // Author: Florent Lamiraux
5 
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 
13 // * Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in
15 // the documentation and/or other materials provided with the
16 // distribution.
17 
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 // OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #ifndef SOT_DYNAMIC_PINOCCHIO_INTEGRATOR_HH
32 #define SOT_DYNAMIC_PINOCCHIO_INTEGRATOR_HH
33 
34 #include <pinocchio/algorithm/joint-configuration.hpp>
35 #include <sot/core/config.hh>
36 #include <dynamic-graph/entity.h>
37 #include <dynamic-graph/signal.h>
40 
41 namespace dynamicgraph {
42 namespace sot {
43 namespace internal {
44 class Signal : public ::dynamicgraph::Signal<Vector, int> {
45  protected:
48 
51  boost::function2<Vector &, Vector &, int> Tfunction;
52 
54  const static bool KEEP_REFERENCE_DEFAULT = false;
55 
56  public:
57 #ifdef HAVE_LIBBOOST_THREAD
58  typedef boost::try_mutex Mutex;
59  typedef boost::lock_error MutexError;
60 #else
61  typedef int *Mutex;
62  typedef int *MutexError;
63 #endif
64 
65  protected:
66  Mutex *providerMutex;
68 
69  public:
71 
72  public:
73  /* --- Constructor/destrusctor --- */
74  Signal(std::string name);
75  virtual ~Signal() {}
76 
77  /* --- Generic In/Out function --- */
78  virtual void get(std::ostream &value) const;
79  virtual void set(std::istringstream &value);
80  virtual void trace(std::ostream &os) const;
81 
82  /* --- Generic Set function --- */
83  virtual void setConstant(const Vector &t);
84  virtual void setReference(const Vector *t, Mutex *mutexref = NULL);
85  virtual void setReferenceNonConstant(Vector *t, Mutex *mutexref = NULL);
86  virtual void setFunction(boost::function2<Vector &, Vector &, int> t,
87  Mutex *mutexref = NULL);
88 
89  /* --- Signal computation --- */
90  virtual const Vector &access(const int &t);
91  virtual inline void recompute(const int &t) { access(t); }
92  virtual const Vector &accessCopy() const;
93 
94  virtual std::ostream &display(std::ostream &os) const;
95 
96  /* --- Operators --- */
97  virtual inline const Vector &operator()(const int &t) { return access(t); }
98  virtual Signal &operator=(const Vector &t);
99  inline operator const Vector &() const { return accessCopy(); }
100  virtual void getClassName(std::string &aClassName) const {
101  aClassName = typeid(this).name();
102  }
103 };
104 
105 } // namespace internal
106 // Integrates a constant velocity for a given timestep
107 //
108 // Initial and final configurations as well as velocity follow pinocchio
109 // standard
110 // The timestep is the time elapsed since last computation of the output in
111 // microseconds.
112 class SOT_CORE_DLLEXPORT Integrator : public Entity {
113  public:
114  // Time corresponding to incrementing signal velocity by 1
115  static const double dt;
116  static const std::string CLASS_NAME;
117  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
118  Integrator(const std::string &name);
119 
120  // Get pointer to the model
121  ::pinocchio::Model *getModel();
122  // Set pointer to the model
123  void setModel(::pinocchio::Model *model);
124  // Set Initial configuration
125  void setInitialConfig(const Vector &initConfig);
126 
127  PeriodicCall &periodicCallBefore() { return periodicCallBefore_; }
128  PeriodicCall &periodicCallAfter() { return periodicCallAfter_; }
129 
130  private:
133 
134  Vector &integrate(Vector &configuration, int time);
135  // Signals
138  // Pointer to pinocchio model
143 }; // class Integrator
144 
145 } // namespace sot
146 } // namespace dynamicgraph
147 #endif // SOT_DYNAMIC_PINOCCHIO_INTEGRATOR_HH
Eigen::VectorXd Vector
PeriodicCall & periodicCallBefore()
Definition: integrator.hh:127
void integrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< ReturnType > &qout)
static const SignalType SIGNAL_TYPE_DEFAULT
Definition: integrator.hh:47
virtual void setReference(const Vector *t, Mutex *mutexref=NULL)
Definition: integrator.cpp:68
internal::Signal configurationSOUT_
Definition: integrator.hh:137
::pinocchio::Model * model_
Definition: integrator.hh:139
virtual void setConstant(const Vector &t)
Definition: integrator.cpp:64
PeriodicCall & periodicCallAfter()
Definition: integrator.hh:128
virtual void setReferenceNonConstant(Vector *t, Mutex *mutexref=NULL)
Definition: integrator.cpp:72
virtual const Vector & accessCopy() const
Definition: integrator.cpp:85
virtual void setFunction(boost::function2< Vector &, Vector &, int > t, Mutex *mutexref=NULL)
Definition: integrator.cpp:76
static const double dt
Definition: integrator.hh:115
SignalPtr< Vector, int > velocitySIN_
Definition: integrator.hh:136
virtual const std::string & getClassName(void) const
Definition: integrator.hh:117
virtual std::ostream & display(std::ostream &os) const
Definition: integrator.cpp:111
boost::function2< Vector &, Vector &, int > Tfunction
Definition: integrator.hh:51
static const bool KEEP_REFERENCE_DEFAULT
Definition: integrator.hh:54
virtual Signal & operator=(const Vector &t)
Definition: integrator.cpp:106
Transform3f t
virtual void trace(std::ostream &os) const
Definition: integrator.cpp:53
virtual const Vector & operator()(const int &t)
Definition: integrator.hh:97
value
virtual void recompute(const int &t)
Definition: integrator.hh:91
virtual const Vector & access(const int &t)
Definition: integrator.cpp:87
virtual void getClassName(std::string &aClassName) const
Definition: integrator.hh:100
model
static const std::string CLASS_NAME
Definition: integrator.hh:116


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26