hpp-pinocchio  6.0.0
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 
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are
9 // met:
10 //
11 // 1. Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the 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 FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 
31 #ifndef HPP_PINOCCHIO_DEVICE_SYNC_HH
32 #define HPP_PINOCCHIO_DEVICE_SYNC_HH
33 
36 #include <hpp/pinocchio/fwd.hh>
37 
38 namespace hpp {
39 namespace pinocchio {
42  public:
45 
47  ModelConstPtr_t modelPtr() const { return model_; }
49  ModelPtr_t modelPtr() { return model_; }
51  const Model& model() const {
52  assert(model_);
53  return *model_;
54  }
56  Model& model() {
57  assert(model_);
58  return *model_;
59  }
60 
62  GeomModelConstPtr_t geomModelPtr() const { return geomModel_; }
64  GeomModelPtr_t geomModelPtr() { return geomModel_; }
66  const GeomModel& geomModel() const {
67  assert(geomModel_);
68  return *geomModel_;
69  }
72  assert(geomModel_);
73  return *geomModel_;
74  }
75 
77  DataConstPtr_t dataPtr() const { return d().data_; }
79  DataPtr_t dataPtr() { return d().data_; }
81  const Data& data() const {
82  assert(d().data_);
83  return *d().data_;
84  }
86  Data& data() {
87  assert(d().data_);
88  return *d().data_;
89  }
90 
92  GeomDataConstPtr_t geomDataPtr() const { return d().geomData_; }
94  GeomDataPtr_t geomDataPtr() { return d().geomData_; }
96  const GeomData& geomData() const {
97  assert(d().geomData_);
98  return *d().geomData_;
99  }
102  assert(d().geomData_);
103  return *d().geomData_;
104  }
105 
107  // -----------------------------------------------------------------------
110 
113  return d().currentConfiguration_;
114  }
118  virtual bool currentConfiguration(ConfigurationIn_t configuration);
119 
121  const vector_t& currentVelocity() const { return d().currentVelocity_; }
122 
124  bool currentVelocity(vectorIn_t velocity);
125 
127  const vector_t& currentAcceleration() const {
128  return d().currentAcceleration_;
129  }
130 
132  bool currentAcceleration(vectorIn_t acceleration);
134  // -----------------------------------------------------------------------
137 
139  const value_type& mass() const;
140 
143 
146 
148  // -----------------------------------------------------------------------
151 
157  return COMPUTE_ALL;
158  }
164  void computeForwardKinematics(int flag) {
165  d().computeForwardKinematics(modelPtr(), flag);
166  }
170  d().computeFramesForwardKinematics(modelPtr());
171  }
174  d().updateGeometryPlacements(modelPtr(), geomModelPtr());
175  }
177  // -----------------------------------------------------------------------
178  protected:
181 
182  virtual DeviceData& d() = 0;
183  virtual DeviceData const& d() const = 0;
184 
185  // Pinocchio objects
188 }; // class AbstractDevice
189 
213  public:
217  DeviceSync(const DevicePtr_t& device, bool lock = true);
218 
221  virtual ~DeviceSync();
222 
226  assert(isLocked());
227  return *d_;
228  }
231  DeviceData const& d() const {
232  assert(isLocked());
233  return *d_;
234  }
235 
237  void lock();
239  bool isLocked() const { return d_ != NULL; }
241  void unlock();
242 
243  private:
244  DevicePtr_t device_;
245  DeviceData* d_;
246 }; // class DeviceSync
247 } // namespace pinocchio
248 } // namespace hpp
249 
250 #endif // HPP_PINOCCHIO_DEVICE_SYNC_HH
Abstract class representing a Device.
Definition: device-sync.hh:41
ModelPtr_t model_
Definition: device-sync.hh:186
void computeFramesForwardKinematics()
Definition: device-sync.hh:169
Model & model()
Access to pinocchio model.
Definition: device-sync.hh:56
const ComJacobian_t & jacobianCenterOfMass() const
Get Jacobian of center of mass with respect to configuration.
const vector_t & currentVelocity() const
Get current velocity.
Definition: device-sync.hh:121
virtual bool currentConfiguration(ConfigurationIn_t configuration)
GeomDataPtr_t geomDataPtr()
Access to Pinocchio geomData/.
Definition: device-sync.hh:94
void computeForwardKinematics()
Compute forward kinematics computing everything.
Definition: device-sync.hh:160
GeomModelConstPtr_t geomModelPtr() const
Access to pinocchio geomModel.
Definition: device-sync.hh:62
const Configuration_t & currentConfiguration() const
Get current configuration.
Definition: device-sync.hh:112
void updateGeometryPlacements()
Update the geometry placement to the currentConfiguration.
Definition: device-sync.hh:173
const GeomData & geomData() const
Access to Pinocchio geomData/.
Definition: device-sync.hh:96
ModelConstPtr_t modelPtr() const
Access to pinocchio model.
Definition: device-sync.hh:47
GeomDataConstPtr_t geomDataPtr() const
Access to Pinocchio geomData/.
Definition: device-sync.hh:92
const vector_t & currentAcceleration() const
Get current acceleration.
Definition: device-sync.hh:127
virtual DeviceData & d()=0
AbstractDevice(const ModelPtr_t &m, const GeomModelPtr_t &gm)
HPP_PINOCCHIO_DEPRECATED void controlComputation(const Computation_t &)
Definition: device-sync.hh:154
virtual DeviceData const & d() const =0
DataPtr_t dataPtr()
Access to Pinocchio data/.
Definition: device-sync.hh:79
DataConstPtr_t dataPtr() const
Access to Pinocchio data/.
Definition: device-sync.hh:77
void computeForwardKinematics(int flag)
Definition: device-sync.hh:164
GeomData & geomData()
Access to Pinocchio geomData/.
Definition: device-sync.hh:101
const Data & data() const
Access to Pinocchio data/.
Definition: device-sync.hh:81
Data & data()
Access to Pinocchio data/.
Definition: device-sync.hh:86
const vector3_t & positionCenterOfMass() const
Get position of center of mass.
bool currentVelocity(vectorIn_t velocity)
Set current velocity.
HPP_PINOCCHIO_DEPRECATED Computation_t computationFlag() const
Definition: device-sync.hh:156
GeomModel & geomModel()
Access to pinocchio geomModel.
Definition: device-sync.hh:71
GeomModelPtr_t geomModelPtr()
Access to pinocchio geomModel.
Definition: device-sync.hh:64
const Model & model() const
Access to pinocchio model.
Definition: device-sync.hh:51
const value_type & mass() const
Get mass of robot.
GeomModelPtr_t geomModel_
Definition: device-sync.hh:187
ModelPtr_t modelPtr()
Access to pinocchio model.
Definition: device-sync.hh:49
bool currentAcceleration(vectorIn_t acceleration)
Set current acceleration.
const GeomModel & geomModel() const
Access to pinocchio geomModel.
Definition: device-sync.hh:66
Definition: device-sync.hh:212
DeviceData const & d() const
Definition: device-sync.hh:231
DeviceData & d()
Definition: device-sync.hh:225
void lock()
Lock the current DeviceData.
bool isLocked() const
Check if the current DeviceData is locked.
Definition: device-sync.hh:239
DeviceSync(const DevicePtr_t &device, bool lock=true)
void unlock()
Unlock the current DeviceData.
#define HPP_PINOCCHIO_DLLAPI
Definition: config.hh:88
shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:118
shared_ptr< const GeomData > GeomDataConstPtr_t
Definition: fwd.hh:136
Computation_t
Definition: device-data.hh:40
@ COMPUTE_ALL
Definition: device-data.hh:46
shared_ptr< GeomModel > GeomModelPtr_t
Definition: fwd.hh:133
::pinocchio::ModelTpl< value_type, 0, JointCollectionTpl > Model
Definition: fwd.hh:77
::pinocchio::GeometryData GeomData
Definition: fwd.hh:80
Eigen::Matrix< value_type, Eigen::Dynamic, 1 > vector_t
Definition: fwd.hh:88
shared_ptr< const Data > DataConstPtr_t
Definition: fwd.hh:131
shared_ptr< Configuration_t > ConfigurationPtr_t HPP_PINOCCHIO_DEPRECATED
Definition: fwd.hh:92
shared_ptr< GeomData > GeomDataPtr_t
Definition: fwd.hh:135
Eigen::Matrix< value_type, 3, 1 > vector3_t
Definition: fwd.hh:99
shared_ptr< const Model > ModelConstPtr_t
Definition: fwd.hh:129
double value_type
Definition: fwd.hh:51
vector_t Configuration_t
Definition: fwd.hh:89
::pinocchio::DataTpl< value_type, 0, JointCollectionTpl > Data
Definition: fwd.hh:78
::pinocchio::GeometryModel GeomModel
Definition: fwd.hh:79
shared_ptr< const GeomModel > GeomModelConstPtr_t
Definition: fwd.hh:134
Eigen::Matrix< value_type, 3, Eigen::Dynamic > ComJacobian_t
Definition: fwd.hh:102
shared_ptr< Model > ModelPtr_t
Definition: fwd.hh:128
Eigen::Ref< const vector_t > vectorIn_t
Definition: fwd.hh:93
shared_ptr< Data > DataPtr_t
Definition: fwd.hh:130
Eigen::Ref< const Configuration_t > ConfigurationIn_t
Definition: fwd.hh:90
Utility functions.
Definition: body.hh:39
Definition: collision-object.hh:40
Definition: device-data.hh:51