hpp-pinocchio 4.14.0
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
Loading...
Searching...
No Matches
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
35#include <hpp/pinocchio/fwd.hh>
36
37namespace hpp {
38namespace pinocchio {
41 public:
44
46 ModelConstPtr_t modelPtr() const { return model_; }
48 ModelPtr_t modelPtr() { return model_; }
50 const Model& model() const {
51 assert(model_);
52 return *model_;
53 }
56 assert(model_);
57 return *model_;
58 }
59
61 GeomModelConstPtr_t geomModelPtr() const { return geomModel_; }
63 GeomModelPtr_t geomModelPtr() { return geomModel_; }
65 const GeomModel& geomModel() const {
66 assert(geomModel_);
67 return *geomModel_;
68 }
71 assert(geomModel_);
72 return *geomModel_;
73 }
74
76 DataConstPtr_t dataPtr() const { return d().data_; }
78 DataPtr_t dataPtr() { return d().data_; }
80 const Data& data() const {
81 assert(d().data_);
82 return *d().data_;
83 }
86 assert(d().data_);
87 return *d().data_;
88 }
89
91 GeomDataConstPtr_t geomDataPtr() const { return d().geomData_; }
93 GeomDataPtr_t geomDataPtr() { return d().geomData_; }
95 const GeomData& geomData() const {
96 assert(d().geomData_);
97 return *d().geomData_;
98 }
101 assert(d().geomData_);
102 return *d().geomData_;
103 }
104
106 // -----------------------------------------------------------------------
109
112 return d().currentConfiguration_;
113 }
117 virtual bool currentConfiguration(ConfigurationIn_t configuration);
118
120 const vector_t& currentVelocity() const { return d().currentVelocity_; }
121
124
127 return d().currentAcceleration_;
128 }
129
131 bool currentAcceleration(vectorIn_t acceleration);
133 // -----------------------------------------------------------------------
136
138 const value_type& mass() const;
139
142
145
147 // -----------------------------------------------------------------------
150
154 virtual void controlComputation(const Computation_t& flag);
156 Computation_t computationFlag() const { return d().computationFlag_; }
158 void computeForwardKinematics() { d().computeForwardKinematics(modelPtr()); }
162 d().computeFramesForwardKinematics(modelPtr());
163 }
166 d().updateGeometryPlacements(modelPtr(), geomModelPtr());
167 }
169 // -----------------------------------------------------------------------
170 protected:
173
174 virtual DeviceData& d() = 0;
175 virtual DeviceData const& d() const = 0;
176
177 // Pinocchio objects
180}; // class AbstractDevice
181
205 public:
209 DeviceSync(const DevicePtr_t& device, bool lock = true);
210
213 virtual ~DeviceSync();
214
218 assert(isLocked());
219 return *d_;
220 }
223 DeviceData const& d() const {
224 assert(isLocked());
225 return *d_;
226 }
227
229 void lock();
231 bool isLocked() const { return d_ != NULL; }
233 void unlock();
234
235 private:
236 DevicePtr_t device_;
237 DeviceData* d_;
238}; // class DeviceSync
239} // namespace pinocchio
240} // namespace hpp
241
242#endif // HPP_PINOCCHIO_DEVICE_SYNC_HH
Abstract class representing a Device.
Definition: device-sync.hh:40
virtual DeviceData & d()=0
ModelPtr_t model_
Definition: device-sync.hh:178
void computeFramesForwardKinematics()
Definition: device-sync.hh:161
const vector_t & currentVelocity() const
Get current velocity.
Definition: device-sync.hh:120
const value_type & mass() const
Get mass of robot.
GeomData & geomData()
Access to Pinocchio geomData/.
Definition: device-sync.hh:100
virtual bool currentConfiguration(ConfigurationIn_t configuration)
GeomDataPtr_t geomDataPtr()
Access to Pinocchio geomData/.
Definition: device-sync.hh:93
void computeForwardKinematics()
Compute forward kinematics.
Definition: device-sync.hh:158
GeomModelConstPtr_t geomModelPtr() const
Access to pinocchio geomModel.
Definition: device-sync.hh:61
const GeomData & geomData() const
Access to Pinocchio geomData/.
Definition: device-sync.hh:95
void updateGeometryPlacements()
Update the geometry placement to the currentConfiguration.
Definition: device-sync.hh:165
ModelConstPtr_t modelPtr() const
Access to pinocchio model.
Definition: device-sync.hh:46
const Configuration_t & currentConfiguration() const
Get current configuration.
Definition: device-sync.hh:111
Model & model()
Access to pinocchio model.
Definition: device-sync.hh:55
Data & data()
Access to Pinocchio data/.
Definition: device-sync.hh:85
GeomDataConstPtr_t geomDataPtr() const
Access to Pinocchio geomData/.
Definition: device-sync.hh:91
const vector3_t & positionCenterOfMass() const
Get position of center of mass.
const GeomModel & geomModel() const
Access to pinocchio geomModel.
Definition: device-sync.hh:65
GeomModel & geomModel()
Access to pinocchio geomModel.
Definition: device-sync.hh:70
AbstractDevice(const ModelPtr_t &m, const GeomModelPtr_t &gm)
DataPtr_t dataPtr()
Access to Pinocchio data/.
Definition: device-sync.hh:78
DataConstPtr_t dataPtr() const
Access to Pinocchio data/.
Definition: device-sync.hh:76
bool currentVelocity(vectorIn_t velocity)
Set current velocity.
GeomModelPtr_t geomModelPtr()
Access to pinocchio geomModel.
Definition: device-sync.hh:63
const Model & model() const
Access to pinocchio model.
Definition: device-sync.hh:50
GeomModelPtr_t geomModel_
Definition: device-sync.hh:179
virtual DeviceData const & d() const =0
const ComJacobian_t & jacobianCenterOfMass() const
Get Jacobian of center of mass with respect to configuration.
virtual void controlComputation(const Computation_t &flag)
ModelPtr_t modelPtr()
Access to pinocchio model.
Definition: device-sync.hh:48
bool currentAcceleration(vectorIn_t acceleration)
Set current acceleration.
Computation_t computationFlag() const
Get computation flag.
Definition: device-sync.hh:156
const Data & data() const
Access to Pinocchio data/.
Definition: device-sync.hh:80
const vector_t & currentAcceleration() const
Get current acceleration.
Definition: device-sync.hh:126
Definition: device-sync.hh:204
DeviceData const & d() const
Definition: device-sync.hh:223
void lock()
Lock the current DeviceData.
DeviceData & d()
Definition: device-sync.hh:217
bool isLocked() const
Check if the current DeviceData is locked.
Definition: device-sync.hh:231
DeviceSync(const DevicePtr_t &device, bool lock=true)
void unlock()
Unlock the current DeviceData.
#define HPP_PINOCCHIO_DLLAPI
Definition: config.hh:64
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
shared_ptr< GeomModel > GeomModelPtr_t
Definition: fwd.hh:133
::pinocchio::ModelTpl< value_type, 0, JointCollectionTpl > Model
Definition: fwd.hh:76
::pinocchio::GeometryData GeomData
Definition: fwd.hh:79
Eigen::Matrix< value_type, Eigen::Dynamic, 1 > vector_t
Definition: fwd.hh:87
shared_ptr< const Data > DataConstPtr_t
Definition: fwd.hh:131
shared_ptr< GeomData > GeomDataPtr_t
Definition: fwd.hh:135
Eigen::Matrix< value_type, 3, 1 > vector3_t
Definition: fwd.hh:98
shared_ptr< const Model > ModelConstPtr_t
Definition: fwd.hh:129
double value_type
Definition: fwd.hh:50
vector_t Configuration_t
Definition: fwd.hh:88
::pinocchio::DataTpl< value_type, 0, JointCollectionTpl > Data
Definition: fwd.hh:77
::pinocchio::GeometryModel GeomModel
Definition: fwd.hh:78
shared_ptr< const GeomModel > GeomModelConstPtr_t
Definition: fwd.hh:134
Eigen::Matrix< value_type, 3, Eigen::Dynamic > ComJacobian_t
Definition: fwd.hh:101
shared_ptr< Model > ModelPtr_t
Definition: fwd.hh:128
Eigen::Ref< const vector_t > vectorIn_t
Definition: fwd.hh:92
shared_ptr< Data > DataPtr_t
Definition: fwd.hh:130
Eigen::Ref< const Configuration_t > ConfigurationIn_t
Definition: fwd.hh:89
Utility functions.
Definition: body.hh:39
Definition: collision-object.hh:40
Definition: device-data.hh:51