hpp-pinocchio  4.9.1
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
device-sync.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016 CNRS
3 // Author: NMansard from Florent Lamiraux
4 //
5 //
6 // This file is part of hpp-pinocchio
7 // hpp-pinocchio is free software: you can redistribute it
8 // and/or modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation, either version
10 // 3 of the License, or (at your option) any later version.
11 //
12 // hpp-pinocchio is distributed in the hope that it will be
13 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Lesser Public License for more details. You should have
16 // received a copy of the GNU Lesser General Public License along with
17 // hpp-pinocchio If not, see
18 // <http://www.gnu.org/licenses/>.
19 
20 #ifndef HPP_PINOCCHIO_DEVICE_SYNC_HH
21 #define HPP_PINOCCHIO_DEVICE_SYNC_HH
22 
23 # include <hpp/pinocchio/fwd.hh>
25 
26 namespace hpp {
27  namespace pinocchio {
29  class HPP_PINOCCHIO_DLLAPI AbstractDevice
30  {
31  public:
34 
36  ModelConstPtr_t modelPtr() const { return model_; }
38  ModelPtr_t modelPtr() { return model_; }
40  const Model& model() const { assert(model_); return *model_; }
42  Model& model() { assert(model_); return *model_; }
43 
45  GeomModelConstPtr_t geomModelPtr() const { return geomModel_; }
47  GeomModelPtr_t geomModelPtr() { return geomModel_; }
49  const GeomModel & geomModel() const { assert(geomModel_); return *geomModel_; }
51  GeomModel & geomModel() { assert(geomModel_); return *geomModel_; }
52 
54  DataConstPtr_t dataPtr() const { return d().data_; }
56  DataPtr_t dataPtr() { return d().data_; }
58  const Data & data() const { assert(d().data_); return *d().data_; }
60  Data & data() { assert(d().data_); return *d().data_; }
61 
63  GeomDataConstPtr_t geomDataPtr() const { return d().geomData_; }
65  GeomDataPtr_t geomDataPtr() { return d().geomData_; }
67  const GeomData& geomData() const { assert(d().geomData_); return *d().geomData_; }
69  GeomData& geomData() { assert(d().geomData_); return *d().geomData_; }
70 
72  // -----------------------------------------------------------------------
75 
77  const Configuration_t& currentConfiguration () const { return d().currentConfiguration_; }
81  virtual bool currentConfiguration (ConfigurationIn_t configuration);
82 
84  const vector_t& currentVelocity () const { return d().currentVelocity_; }
85 
87  bool currentVelocity (vectorIn_t velocity);
88 
90  const vector_t& currentAcceleration () const { return d().currentAcceleration_; }
91 
93  bool currentAcceleration (vectorIn_t acceleration);
95  // -----------------------------------------------------------------------
98 
100  const value_type& mass () const;
101 
103  const vector3_t& positionCenterOfMass () const;
104 
106  const ComJacobian_t& jacobianCenterOfMass () const;
107 
109  // -----------------------------------------------------------------------
112 
116  virtual void controlComputation (const Computation_t& flag);
118  Computation_t computationFlag () const { return d().computationFlag_; }
120  void computeForwardKinematics () { d().computeForwardKinematics(modelPtr()); }
123  void computeFramesForwardKinematics () { d().computeFramesForwardKinematics(modelPtr()); }
125  void updateGeometryPlacements () { d().updateGeometryPlacements(modelPtr(), geomModelPtr()); }
127  // -----------------------------------------------------------------------
128  protected:
129  AbstractDevice ();
130  AbstractDevice (const ModelPtr_t& m, const GeomModelPtr_t& gm);
131 
132  virtual DeviceData & d () = 0;
133  virtual DeviceData const& d () const = 0;
134 
135  // Pinocchio objects
138  }; // class AbstractDevice
139 
162  class HPP_PINOCCHIO_DLLAPI DeviceSync : public AbstractDevice
163  {
164  public:
168  DeviceSync (const DevicePtr_t& device, bool lock = true);
169 
172  virtual ~DeviceSync ();
173 
176  DeviceData & d () { assert (isLocked()); return *d_; }
179  DeviceData const& d () const { assert (isLocked()); return *d_; }
180 
182  void lock ();
184  bool isLocked () const { return d_ != NULL; }
186  void unlock ();
187 
188  private:
189  DevicePtr_t device_;
190  DeviceData* d_;
191  }; // class DeviceSync
192  } // namespace pinocchio
193 } // namespace hpp
194 
195 #endif // HPP_PINOCCHIO_DEVICE_SYNC_HH
const Data & data() const
Access to Pinocchio data/.
Definition: device-sync.hh:58
boost::shared_ptr< Data > DataPtr_t
Definition: fwd.hh:116
const Model & model() const
Access to pinocchio model.
Definition: device-sync.hh:40
void computeForwardKinematics()
Compute forward kinematics.
Definition: device-sync.hh:120
boost::shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:104
DeviceData const & d() const
Definition: device-sync.hh:179
const GeomData & geomData() const
Access to Pinocchio geomData/.
Definition: device-sync.hh:67
Utility functions.
const vector_t & currentAcceleration() const
Get current acceleration.
Definition: device-sync.hh:90
GeomModel & geomModel()
Access to pinocchio geomModel.
Definition: device-sync.hh:51
Definition: device-data.hh:41
boost::shared_ptr< const Model > ModelConstPtr_t
Definition: fwd.hh:115
ModelConstPtr_t modelPtr() const
Access to pinocchio model.
Definition: device-sync.hh:36
boost::shared_ptr< const GeomData > GeomDataConstPtr_t
Definition: fwd.hh:122
ModelPtr_t model_
Definition: device-sync.hh:136
boost::shared_ptr< GeomData > GeomDataPtr_t
Definition: fwd.hh:121
GeomDataPtr_t geomDataPtr()
Access to Pinocchio geomData/.
Definition: device-sync.hh:65
boost::shared_ptr< Model > ModelPtr_t
Definition: fwd.hh:114
Eigen::Matrix< value_type, 3, Eigen::Dynamic > ComJacobian_t
Definition: fwd.hh:89
GeomData & geomData()
Access to Pinocchio geomData/.
Definition: device-sync.hh:69
Eigen::Matrix< value_type, Eigen::Dynamic, 1 > vector_t
Definition: fwd.hh:75
const Configuration_t & currentConfiguration() const
Get current configuration.
Definition: device-sync.hh:77
GeomModelPtr_t geomModel_
Definition: device-sync.hh:137
DataConstPtr_t dataPtr() const
Access to Pinocchio data/.
Definition: device-sync.hh:54
Computation_t
Definition: device-data.hh:30
DataPtr_t dataPtr()
Access to Pinocchio data/.
Definition: device-sync.hh:56
Abstract class representing a Device.
Definition: device-sync.hh:29
void updateGeometryPlacements()
Update the geometry placement to the currentConfiguration.
Definition: device-sync.hh:125
DeviceData & d()
Definition: device-sync.hh:176
GeomModelConstPtr_t geomModelPtr() const
Access to pinocchio geomModel.
Definition: device-sync.hh:45
FCL_REAL d
double value_type
Definition: fwd.hh:40
Eigen::Ref< const Configuration_t > ConfigurationIn_t
Definition: fwd.hh:77
Model & model()
Access to pinocchio model.
Definition: device-sync.hh:42
ModelPtr_t modelPtr()
Access to pinocchio model.
Definition: device-sync.hh:38
Data & data()
Access to Pinocchio data/.
Definition: device-sync.hh:60
boost::shared_ptr< const GeomModel > GeomModelConstPtr_t
Definition: fwd.hh:120
bool isLocked() const
Check if the current DeviceData is locked.
Definition: device-sync.hh:184
const vector_t & currentVelocity() const
Get current velocity.
Definition: device-sync.hh:84
Eigen::Ref< const vector_t > vectorIn_t
Definition: fwd.hh:80
const GeomModel & geomModel() const
Access to pinocchio geomModel.
Definition: device-sync.hh:49
void computeFramesForwardKinematics()
Definition: device-sync.hh:123
GeomModelPtr_t geomModelPtr()
Access to pinocchio geomModel.
Definition: device-sync.hh:47
Computation_t computationFlag() const
Get computation flag.
Definition: device-sync.hh:118
boost::shared_ptr< GeomModel > GeomModelPtr_t
Definition: fwd.hh:119
vector_t Configuration_t
Definition: fwd.hh:76
Definition: device-sync.hh:162
boost::shared_ptr< const Data > DataConstPtr_t
Definition: fwd.hh:117
GeomDataConstPtr_t geomDataPtr() const
Access to Pinocchio geomData/.
Definition: device-sync.hh:63
Eigen::Matrix< value_type, 3, 1 > vector3_t
Definition: fwd.hh:86