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, sigtime_t> {
45  protected:
48 
51  boost::function2<Vector &, Vector &, sigtime_t> 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 size_type *Mutex;
63 #endif
64 
65  protected:
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 &, sigtime_t> t,
87  Mutex *mutexref = NULL);
88 
89  /* --- Signal computation --- */
90  virtual const Vector &access(const sigtime_t &t);
91  virtual inline void recompute(const sigtime_t &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 sigtime_t &t) {
98  return access(t);
99  }
100  virtual Signal &operator=(const Vector &t);
101  inline operator const Vector &() const { return accessCopy(); }
102  virtual void getClassName(std::string &aClassName) const {
103  aClassName = typeid(this).name();
104  }
105 };
106 
107 } // namespace internal
108 // Integrates a constant velocity for a given timestep
109 //
110 // Initial and final configurations as well as velocity follow pinocchio
111 // standard
112 // The timestep is the time elapsed since last computation of the output in
113 // microseconds.
114 class SOT_CORE_DLLEXPORT Integrator : public Entity {
115  public:
116  // Time corresponding to incrementing signal velocity by 1
117  static const double dt;
118  static const std::string CLASS_NAME;
119  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
120  Integrator(const std::string &name);
121 
122  // Get pointer to the model
123  ::pinocchio::Model *getModel();
124  // Set pointer to the model
125  void setModel(::pinocchio::Model *model);
126  // Set Initial configuration
127  void setInitialConfig(const Vector &initConfig);
128 
129  PeriodicCall &periodicCallBefore() { return periodicCallBefore_; }
130  PeriodicCall &periodicCallAfter() { return periodicCallAfter_; }
131 
132  private:
135 
136  Vector &integrate(Vector &configuration, sigtime_t time);
137  // Signals
140  // Pointer to pinocchio model
145 }; // class Integrator
146 
147 } // namespace sot
148 } // namespace dynamicgraph
149 #endif // SOT_DYNAMIC_PINOCCHIO_INTEGRATOR_HH
signal-ptr.h
dynamicgraph::Signal
dynamicgraph::sot::internal::Signal::REFERENCE_NON_CONST
@ REFERENCE_NON_CONST
Definition: integrator.hh:46
dynamicgraph::sot::internal::Signal::KEEP_REFERENCE_DEFAULT
const static bool KEEP_REFERENCE_DEFAULT
Definition: integrator.hh:54
dynamicgraph::sot::internal::Signal::get
virtual void get(std::ostream &value) const
Definition: integrator.cpp:50
dynamicgraph::SignalPtr< Vector, sigtime_t >
dynamicgraph
dynamicgraph::sot::internal::Signal
Definition: integrator.hh:44
dynamicgraph::sot::internal::Signal::keepReference
bool keepReference
Definition: integrator.hh:53
dynamicgraph::Entity
dynamicgraph::sot::internal::Signal::setReferenceNonConstant
virtual void setReferenceNonConstant(Vector *t, Mutex *mutexref=NULL)
Definition: integrator.cpp:73
dynamicgraph::sot::internal::Signal::~Signal
virtual ~Signal()
Definition: integrator.hh:75
dynamicgraph::sot::internal::Signal::recompute
virtual void recompute(const sigtime_t &t)
Definition: integrator.hh:91
dynamicgraph::sot::internal::Signal::setReference
virtual void setReference(const Vector *t, Mutex *mutexref=NULL)
Definition: integrator.cpp:69
dynamicgraph::sot::internal::Signal::FUNCTION
@ FUNCTION
Definition: integrator.hh:46
dynamicgraph::sot::Integrator::configuration_
Vector configuration_
Definition: integrator.hh:142
dynamicgraph::sot::internal::Signal::TreferenceNonConst
Vector * TreferenceNonConst
Definition: integrator.hh:50
dynamicgraph::sot::Integrator::periodicCallAfter_
PeriodicCall periodicCallAfter_
Definition: integrator.hh:134
dynamicgraph::sot::internal::Signal::set
virtual void set(std::istringstream &value)
Definition: integrator.cpp:46
dynamicgraph::sot::Integrator::periodicCallBefore_
PeriodicCall periodicCallBefore_
Definition: integrator.hh:133
dynamicgraph::sot::Integrator::lastComputationTime_
sigtime_t lastComputationTime_
Definition: integrator.hh:143
dynamicgraph::sot::internal::Signal::providerMutex
Mutex * providerMutex
Definition: integrator.hh:66
dynamicgraph::sot::internal::Signal::SignalType
SignalType
Definition: integrator.hh:46
dynamicgraph::sot::internal::Signal::Signal
Signal(std::string name)
Definition: integrator.cpp:41
dynamicgraph::sot::internal::Signal::setConstant
virtual void setConstant(const Vector &t)
Definition: integrator.cpp:65
dynamicgraph::sot::internal::Signal::MutexError
size_type * MutexError
Definition: integrator.hh:62
dynamicgraph::sot::internal::Signal::Tfunction
boost::function2< Vector &, Vector &, sigtime_t > Tfunction
Definition: integrator.hh:51
dynamicgraph::sot::internal::Signal::Mutex
size_type * Mutex
Definition: integrator.hh:61
dynamicgraph::sot::internal::Signal::operator()
virtual const Vector & operator()(const sigtime_t &t)
Definition: integrator.hh:97
dynamicgraph::sigtime_t
int64_t sigtime_t
integrate
void integrate(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType > &v, const Eigen::MatrixBase< ReturnType > &qout)
dynamicgraph::sot::Integrator::getClassName
virtual const std::string & getClassName(void) const
Definition: integrator.hh:119
dynamicgraph::sot::internal::Signal::operator=
virtual Signal & operator=(const Vector &t)
Definition: integrator.cpp:107
dynamicgraph::sot::Integrator
Definition: integrator.hh:114
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::internal::Signal::accessCopy
virtual const Vector & accessCopy() const
Definition: integrator.cpp:86
dynamicgraph::sot::Integrator::CLASS_NAME
static const std::string CLASS_NAME
Definition: integrator.hh:118
periodic-call.hh
dynamicgraph::sot::internal::Signal::REFERENCE
@ REFERENCE
Definition: integrator.hh:46
dynamicgraph::sot::internal::Signal::access
virtual const Vector & access(const sigtime_t &t)
Definition: integrator.cpp:88
dynamicgraph::sot::Integrator::model_
::pinocchio::Model * model_
Definition: integrator.hh:141
dynamicgraph::sot::Integrator::dt
static const double dt
Definition: integrator.hh:117
dynamicgraph::sot::internal::Signal::getClassName
virtual void getClassName(std::string &aClassName) const
Definition: integrator.hh:102
dynamicgraph::sot::internal::Signal::CONSTANT
@ CONSTANT
Definition: integrator.hh:46
dynamicgraph::sot::internal::Signal::Treference
const Vector * Treference
Definition: integrator.hh:49
dynamicgraph::sot::Integrator::recursivityLevel_
sigtime_t recursivityLevel_
Definition: integrator.hh:144
dynamicgraph::sot::Integrator::configurationSOUT_
internal::Signal configurationSOUT_
Definition: integrator.hh:139
dynamicgraph::sot::internal::Signal::SIGNAL_TYPE_DEFAULT
static const SignalType SIGNAL_TYPE_DEFAULT
Definition: integrator.hh:47
dynamicgraph::sot::PeriodicCall
Definition: periodic-call.hh:37
dynamicgraph::sot::Integrator::periodicCallBefore
PeriodicCall & periodicCallBefore()
Definition: integrator.hh:129
t
Transform3f t
dynamicgraph::sot::Integrator::periodicCallAfter
PeriodicCall & periodicCallAfter()
Definition: integrator.hh:130
dynamicgraph::sot::Integrator::velocitySIN_
SignalPtr< Vector, sigtime_t > velocitySIN_
Definition: integrator.hh:138
dynamicgraph::sot::internal::Signal::display
virtual std::ostream & display(std::ostream &os) const
Definition: integrator.cpp:112
pinocchio::ModelTpl
dynamicgraph::SignalBase
dynamicgraph::sot::internal::Signal::trace
virtual void trace(std::ostream &os) const
Definition: integrator.cpp:54
compile.name
name
Definition: compile.py:23
dynamicgraph::sot::internal::Signal::setFunction
virtual void setFunction(boost::function2< Vector &, Vector &, sigtime_t > t, Mutex *mutexref=NULL)
Definition: integrator.cpp:77


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31