Robotics Library  0.7.0
Model.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_MDL_MODEL_H
28 #define RL_MDL_MODEL_H
29 
30 #include <memory>
31 #include <string>
32 #include <vector>
33 #include <boost/graph/adjacency_list.hpp>
34 #include <rl/math/Transform.h>
35 #include <rl/math/Unit.h>
36 #include <rl/math/Vector.h>
37 
38 #include "Frame.h"
39 #include "Transform.h"
40 
41 namespace rl
42 {
49  namespace mdl
50  {
51  class Body;
52  class Compound;
53  class Joint;
54 
55  class Model
56  {
57  public:
58  Model();
59 
60  virtual ~Model();
61 
62  void add(Compound* compound, const Frame* a, const Frame* b);
63 
64  void add(Frame* frame);
65 
66  void add(Transform* transform, const Frame* a, const Frame* b);
67 
68  bool areColliding(const ::std::size_t& i, const ::std::size_t& j) const;
69 
70  Model* clone() const;
71 
73 
75 
77 
78  ::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1> getAccelerationUnits() const;
79 
80  ::std::size_t getBodies() const;
81 
82  Body* getBody(const ::std::size_t& i) const;
83 
84  ::std::size_t getDof() const;
85 
86  ::std::size_t getDofPosition() const;
87 
88  const ::rl::math::Transform& getFrame(const ::std::size_t& i) const;
89 
91 
93 
95 
97 
99 
100  Joint* getJoint(const ::std::size_t& i) const;
101 
102  ::std::size_t getJoints() const;
103 
104  const ::rl::math::MotionVector& getOperationalAcceleration(const ::std::size_t& i) const;
105 
106  ::std::size_t getOperationalDof() const;
107 
108  const ::rl::math::ForceVector& getOperationalForce(const ::std::size_t& i) const;
109 
110  const ::rl::math::Transform& getOperationalPosition(const ::std::size_t& i) const;
111 
112  const ::rl::math::MotionVector& getOperationalVelocity(const ::std::size_t& i) const;
113 
114  const ::std::string& getManufacturer() const;
115 
117 
119 
120  const ::std::string& getName() const;
121 
123 
124  ::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1> getPositionUnits() const;
125 
127 
128  ::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1> getTorqueUnits() const;
129 
131 
132  ::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1> getSpeedUnits() const;
133 
135 
136  ::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1> getVelocityUnits() const;
137 
138  bool isColliding(const ::std::size_t& i) const;
139 
140  void replace(Compound* compound, Transform* transform);
141 
142  void replace(Transform* transform, Compound* compound);
143 
144  void remove(Compound* compound);
145 
146  void remove(Frame* frame);
147 
148  void remove(Transform* transform);
149 
151 
153 
155 
157 
158  void setManufacturer(const ::std::string& manufacturer);
159 
160  void setName(const ::std::string& name);
161 
162  void setOperationalVelocity(const ::std::size_t& i, const ::rl::math::MotionVector& v) const;
163 
165 
167 
169 
170  ::rl::math::Transform& tool(const ::std::size_t& i = 0);
171 
172  const ::rl::math::Transform& tool(const ::std::size_t& i = 0) const;
173 
174  virtual void update();
175 
177 
179 
180  protected:
181  friend class Compound;
182 
183  typedef ::boost::adjacency_list<
184  ::boost::listS,
185  ::boost::listS,
186  ::boost::bidirectionalS,
187  ::boost::property<
188  ::boost::vertex_color_t, Compound*,
189  ::std::shared_ptr<Frame>
190  >,
191  ::boost::property<
192  ::boost::edge_weight_t, Compound*,
193  ::std::shared_ptr<Transform>
194  >,
195  ::boost::no_property,
196  ::boost::listS
197  > Tree;
198 
199  typedef ::boost::graph_traits<Tree>::edge_descriptor Edge;
200 
201  typedef ::boost::graph_traits<Tree>::edge_iterator EdgeIterator;
202 
203  typedef ::std::pair<EdgeIterator, EdgeIterator> EdgeIteratorPair;
204 
205  typedef ::boost::graph_traits<Tree>::in_edge_iterator InEdgeIterator;
206 
207  typedef ::std::pair<InEdgeIterator, InEdgeIterator> InEdgeIteratorPair;
208 
209  typedef ::boost::graph_traits<Tree>::out_edge_iterator OutEdgeIterator;
210 
211  typedef ::std::pair<OutEdgeIterator, OutEdgeIterator> OutEdgeIteratorPair;
212 
213  typedef ::boost::graph_traits<Tree>::vertex_descriptor Vertex;
214 
215  typedef ::boost::graph_traits<Tree>::vertex_iterator VertexIterator;
216 
217  typedef ::std::pair<VertexIterator, VertexIterator> VertexIteratorPair;
218 
219  void update(const Vertex& u);
220 
221  ::std::vector<Body*> bodies;
222 
223  ::std::vector<Element*> elements;
224 
225  ::std::vector<Frame*> frames;
226 
228 
230 
232 
234 
236 
237  ::std::vector<Joint*> joints;
238 
239  ::std::vector<Vertex> leaves;
240 
241  ::std::string manufacturer;
242 
243  ::std::string name;
244 
246 
247  ::std::vector<Edge> tools;
248 
249  ::std::vector<Transform*> transforms;
250 
252 
253  private:
254 
255  };
256  }
257 }
258 
259 #endif // RL_MDL_MODEL_H
rl::mdl::Model::getDofPosition
::std::size_t getDofPosition() const
Definition: Model.cpp:199
rl::math::Matrix
::Eigen::Matrix< Real, ::Eigen::Dynamic, ::Eigen::Dynamic > Matrix
Definition: Matrix.h:42
rl::mdl::Model::getHomePosition
::rl::math::Vector getHomePosition() const
Definition: Model.cpp:244
rl::mdl::Model::getPosition
::rl::math::Vector getPosition() const
Definition: Model.cpp:340
rl::mdl::Model::getSpeedUnits
::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1 > getSpeedUnits() const
Definition: Model.cpp:405
rl::mdl::Model::OutEdgeIterator
::boost::graph_traits< Tree >::out_edge_iterator OutEdgeIterator
Definition: Model.h:209
rl::mdl::Model::getGammaVelocity
const ::rl::math::Matrix & getGammaVelocity() const
Definition: Model.cpp:226
rl::mdl::Model::clone
Model * clone() const
Definition: Model.cpp:110
rl::math::Transform
::Eigen::Transform< Real, 3, ::Eigen::Affine > Transform
Rigid transformation in 3D.
Definition: Transform.h:46
rl::mdl::Model::setManufacturer
void setManufacturer(const ::std::string &manufacturer)
Definition: Model.cpp:539
rl::mdl::Model::getGammaPosition
const ::rl::math::Matrix & getGammaPosition() const
Definition: Model.cpp:220
rl::mdl::Model::getJoint
Joint * getJoint(const ::std::size_t &i) const
Definition: Model.cpp:250
rl::mdl::Model::VertexIteratorPair
::std::pair< VertexIterator, VertexIterator > VertexIteratorPair
Definition: Model.h:217
rl::mdl::Model::getSpeed
::rl::math::Vector getSpeed() const
Definition: Model.cpp:392
rl::mdl::Model::joints
::std::vector< Joint * > joints
Definition: Model.h:237
rl::mdl::Transform
Definition: Transform.h:43
rl::mdl::Model::getMaximum
::rl::math::Vector getMaximum() const
Definition: Model.cpp:308
Transform.h
rl::mdl::Model::getOperationalDof
::std::size_t getOperationalDof() const
Definition: Model.cpp:272
Frame.h
rl::mdl::Model::getTorqueUnits
::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1 > getTorqueUnits() const
Definition: Model.cpp:379
rl::mdl::Model::gammaPosition
::rl::math::Matrix gammaPosition
Definition: Model.h:227
rl::mdl::Model::setGammaVelocity
void setGammaVelocity(const ::rl::math::Matrix &gammaVelocity)
Definition: Model.cpp:518
rl::mdl::Model::Vertex
::boost::graph_traits< Tree >::vertex_descriptor Vertex
Definition: Model.h:213
rl::mdl::Model::update
virtual void update()
Definition: Model.cpp:604
rl::mdl::Model::Edge
::boost::graph_traits< Tree >::edge_descriptor Edge
Definition: Model.h:199
rl::math::MotionVector
spatial::MotionVector< Real > MotionVector
Definition: Spatial.h:56
rl::mdl::Model::getDof
::std::size_t getDof() const
Definition: Model.cpp:186
rl::math::Vector
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:42
rl::mdl::Model::getGammaPositionInverse
const ::rl::math::Matrix & getGammaPositionInverse() const
Definition: Model.cpp:232
rl::mdl::Model::add
void add(Compound *compound, const Frame *a, const Frame *b)
Definition: Model.cpp:63
rl::mdl::Model::getTorque
::rl::math::Vector getTorque() const
Definition: Model.cpp:366
rl::mdl::Model::transforms
::std::vector< Transform * > transforms
Definition: Model.h:249
Vector.h
rl::mdl::Model::Model
Model()
Definition: Model.cpp:38
rl::mdl::Model::root
Vertex root
Definition: Model.h:245
rl::mdl::Joint
Definition: Joint.h:40
rl::mdl::Model::isColliding
bool isColliding(const ::std::size_t &i) const
Definition: Model.cpp:444
rl::mdl::Model::setOperationalVelocity
void setOperationalVelocity(const ::std::size_t &i, const ::rl::math::MotionVector &v) const
Definition: Model.cpp:551
rl::mdl::Model::replace
void replace(Compound *compound, Transform *transform)
Definition: Model.cpp:452
rl::mdl::Model::generatePositionGaussian
::rl::math::Vector generatePositionGaussian(const ::rl::math::Vector &rand, const ::rl::math::Vector &mean, const ::rl::math::Vector &sigma) const
Definition: Model.cpp:116
rl::mdl::Model::getName
const ::std::string & getName() const
Definition: Model.cpp:334
rl::mdl::Model::tools
::std::vector< Edge > tools
Definition: Model.h:247
rl::mdl::Model::setGammaPosition
void setGammaPosition(const ::rl::math::Matrix &gammaPosition)
Definition: Model.cpp:503
rl::mdl::Model::setHomePosition
void setHomePosition(const ::rl::math::Vector &home)
Definition: Model.cpp:533
rl::mdl::Model::getFrame
const ::rl::math::Transform & getFrame(const ::std::size_t &i) const
Definition: Model.cpp:212
rl::mdl::Model::getGammaVelocityInverse
const ::rl::math::Matrix & getGammaVelocityInverse() const
Definition: Model.cpp:238
rl::mdl::Model::InEdgeIteratorPair
::std::pair< InEdgeIterator, InEdgeIterator > InEdgeIteratorPair
Definition: Model.h:207
rl::mdl::Model::leaves
::std::vector< Vertex > leaves
Definition: Model.h:239
rl::mdl::Model::home
::rl::math::Vector home
Definition: Model.h:231
rl::mdl::Body
Definition: Body.h:39
rl::mdl::Model::name
::std::string name
Definition: Model.h:243
rl::mdl::Model::getOperationalVelocity
const ::rl::math::MotionVector & getOperationalVelocity(const ::std::size_t &i) const
Definition: Model.cpp:294
rl::mdl::Compound
Definition: Compound.h:42
rl::mdl::Model::world
::rl::math::Transform & world()
Definition: Model.cpp:672
rl::mdl::Model::EdgeIteratorPair
::std::pair< EdgeIterator, EdgeIterator > EdgeIteratorPair
Definition: Model.h:203
rl::mdl::Model::tool
::rl::math::Transform & tool(const ::std::size_t &i=0)
Definition: Model.cpp:588
rl::mdl::Model::getOperationalPosition
const ::rl::math::Transform & getOperationalPosition(const ::std::size_t &i) const
Definition: Model.cpp:286
rl::mdl::Model::invGammaVelocity
::rl::math::Matrix invGammaVelocity
Definition: Model.h:235
rl::mdl::Model::getPositionUnits
::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1 > getPositionUnits() const
Definition: Model.cpp:353
rl::mdl::Model::getVelocity
::rl::math::Vector getVelocity() const
Definition: Model.cpp:418
rl::mdl::Model::frames
::std::vector< Frame * > frames
Definition: Model.h:225
rl::mdl::Model::generatePositionUniform
::rl::math::Vector generatePositionUniform(const ::rl::math::Vector &rand) const
Definition: Model.cpp:133
rl::mdl::Model::tree
Tree tree
Definition: Model.h:251
rl::mdl::Model::bodies
::std::vector< Body * > bodies
Definition: Model.h:221
rl::mdl::Model
Definition: Model.h:56
rl::mdl::Model::getBody
Body * getBody(const ::std::size_t &i) const
Definition: Model.cpp:178
rl::mdl::Model::getAcceleration
::rl::math::Vector getAcceleration() const
Definition: Model.cpp:146
rl::mdl::Model::getOperationalAcceleration
const ::rl::math::MotionVector & getOperationalAcceleration(const ::std::size_t &i) const
Definition: Model.cpp:264
rl::mdl::Model::elements
::std::vector< Element * > elements
Definition: Model.h:223
rl::mdl::Model::getJoints
::std::size_t getJoints() const
Definition: Model.cpp:258
rl::mdl::Model::InEdgeIterator
::boost::graph_traits< Tree >::in_edge_iterator InEdgeIterator
Definition: Model.h:205
rl::mdl::Model::manufacturer
::std::string manufacturer
Definition: Model.h:241
rl::math::ForceVector
spatial::ForceVector< Real > ForceVector
Definition: Spatial.h:54
rl::mdl::Model::getOperationalForce
const ::rl::math::ForceVector & getOperationalForce(const ::std::size_t &i) const
Definition: Model.cpp:278
rl::mdl::Model::OutEdgeIteratorPair
::std::pair< OutEdgeIterator, OutEdgeIterator > OutEdgeIteratorPair
Definition: Model.h:211
rl::mdl::Model::setName
void setName(const ::std::string &name)
Definition: Model.cpp:545
rl::mdl::Model::setPosition
void setPosition(const ::rl::math::Vector &q)
Definition: Model.cpp:557
rl::mdl::Model::EdgeIterator
::boost::graph_traits< Tree >::edge_iterator EdgeIterator
Definition: Model.h:201
rl::mdl::Model::gammaVelocity
::rl::math::Matrix gammaVelocity
Definition: Model.h:229
rl::mdl::Model::~Model
virtual ~Model()
Definition: Model.cpp:58
rl::mdl::Model::getVelocityUnits
::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1 > getVelocityUnits() const
Definition: Model.cpp:431
rl::mdl::Model::areColliding
bool areColliding(const ::std::size_t &i, const ::std::size_t &j) const
Definition: Model.cpp:94
rl::mdl::Model::VertexIterator
::boost::graph_traits< Tree >::vertex_iterator VertexIterator
Definition: Model.h:215
rl::mdl::Model::invGammaPosition
::rl::math::Matrix invGammaPosition
Definition: Model.h:233
Transform.h
rl::mdl::Model::getBodies
::std::size_t getBodies() const
Definition: Model.cpp:172
rl::mdl::Model::setVelocity
void setVelocity(const ::rl::math::Vector &qd)
Definition: Model.cpp:577
rl::mdl::Model::setAcceleration
void setAcceleration(const ::rl::math::Vector &qdd)
Definition: Model.cpp:492
rl::mdl::Model::Tree
::boost::adjacency_list< ::boost::listS, ::boost::listS, ::boost::bidirectionalS, ::boost::property< ::boost::vertex_color_t, Compound *, ::std::shared_ptr< Frame > >, ::boost::property< ::boost::edge_weight_t, Compound *, ::std::shared_ptr< Transform > >, ::boost::no_property, ::boost::listS > Tree
Definition: Model.h:197
rl::mdl::Frame
Definition: Frame.h:42
rl::mdl::Model::getAccelerationUnits
::Eigen::Matrix< ::rl::math::Unit, ::Eigen::Dynamic, 1 > getAccelerationUnits() const
Definition: Model.cpp:159
rl::mdl::Model::getManufacturer
const ::std::string & getManufacturer() const
Definition: Model.cpp:302
rl::mdl::Model::remove
void remove(Compound *compound)
Definition: Model.cpp:466
Unit.h
rl::mdl::Model::setTorque
void setTorque(const ::rl::math::Vector &tau)
Definition: Model.cpp:568
rl::mdl::Model::getMinimum
::rl::math::Vector getMinimum() const
Definition: Model.cpp:321
rl
Robotics Library.
Definition: AnalogInput.cpp:30