Buran Motion Planning Framework
robot.h
1 #pragma once
2 
3 #include <vector>
4 #include <string>
5 #include <memory>
6 #include <Eigen/Dense>
7 #include <utility>
8 
9 #include "log.h"
10 #include "matrix_math.h"
11 #include "link.h"
12 #include "joint_params.h"
13 #include "joint.h"
14 
15 namespace bmpf {
19  class BaseRobot {
20  public:
24  virtual ~BaseRobot() = default;
25 
29  BaseRobot();
30 
38  virtual void loadFromFile(std::string path) = 0;
39 
45  virtual std::vector<Eigen::Vector3d> getJointAxes(std::vector<double> state);
46 
52  virtual std::vector<Eigen::Matrix4d> getTransformMatrices(std::vector<double> state);
53 
59  virtual Eigen::Matrix4d getEndEffectorTransformMatrix(std::vector<double> state);
60 
69  Eigen::Matrix4d getEndEffectorDiffTransformMatrix(std::vector<double> state, int iVal);
70 
80  Eigen::Matrix4d getEndEffectorDiff2TransformMatrix(std::vector<double> state, int iVal, int jVal);
81 
87  bool isStateEnabled(std::vector<double> state);
88 
93  std::vector<double> getWorldTranslation() const {
94  return {_worldTransformVector.begin(), _worldTransformVector.begin() + 3};
95  }
96 
101  std::vector<double> getWorldRotation() const {
102  return {_worldTransformVector.begin() + 3, _worldTransformVector.begin() + 6};
103  }
104 
109  std::vector<double> getWorldScale() const {
110  return {_worldTransformVector.begin() + 6, _worldTransformVector.begin() + 9};
111  }
112 
117  std::vector<double> getWorldTransformVector() const { return _worldTransformVector; }
118 
123  const std::shared_ptr<Eigen::Matrix4d> &getWorldTransformMatrix() const { return _worldTransformMatrix; }
124 
129  unsigned long getJointCnt() const { return _jointParams.size(); }
130 
131 
136  std::vector<double> getMaxSpeedModules() { return _maxSpeedModules; }
137 
142  std::vector<double> getMaxAccelerationModules() { return _maxAccelerationModules; }
143 
148  unsigned long getLinkCnt() const { return _links.size(); }
149 
154  std::vector<std::shared_ptr<JointParams>> getJointParamsList() const { return _jointParams; }
155 
160  std::vector<std::shared_ptr<Link>> getLinks() const { return _links; }
161 
166  std::string getPath() const { return _path; }
167 
172  void setWorldTranslation(const std::vector<double> &translation);
173 
178  void setWorldRotation(const std::vector<double> &rotation);
179 
184  void setWorldScale(const std::vector<double> &scale);
185 
190  void setWorldTransformVector(const std::vector<double> &vec);
191 
196  std::vector<std::string> getModelPaths() const;
197 
203  std::vector<double> getEndEffectorPos(std::vector<double> state);
204 
211  std::vector<double> getEndEffectorDiffPos(std::vector<double> state, int iVal);
212 
220  std::vector<double> getEndEffectorDiff2Pos(std::vector<double> state, int iVal, int jVal);
221 
227  std::vector<double> getEndEffectorRGVector(std::vector<double> state);
228 
236  std::vector<double> getEndEffectorDiffRGVector(std::vector<double> state, int iVal);
237 
246  std::vector<double> getEndEffectorDiff2RGVector(std::vector<double> state, int iVal, int jVal);
247 
253  std::vector<double> getAllLinkPositions(std::vector<double> state);
254 
260  std::vector<double> getAllLinkRGVectors(std::vector<double> state);
261 
268  std::vector<double> getMassCenterAbsolutePositions(std::vector<double> state);
269 
275  virtual std::vector<double> getMassCenterLocalPositions();
276 
281  virtual std::vector<Eigen::Matrix3d> getInertias();
282 
287  std::vector<double> getRandomState();
288 
289  protected:
294 
301  template<typename F>
302  void _forEachJoint(std::vector<double> state, const F &consumer);
303 
312  template<typename F>
313  void _forEachDiffJoint(std::vector<double> state, int iVal, const F &consumer);
314 
325  template<typename F>
326  void _forEachDiff2Joint(std::vector<double> state, int iVal, int jVal, const F &consumer);
327 
331  std::vector<std::shared_ptr<Joint>> _joints;
335  std::vector<std::shared_ptr<JointParams>> _jointParams;
339  std::vector<double> _maxSpeedModules;
343  std::vector<double> _maxAccelerationModules;
348  std::vector<std::shared_ptr<Link>> _links;
352  std::vector<std::shared_ptr<Link>> _nonHierarchicalLinks;
356  std::string _path;
361  std::vector<double> _worldTransformVector;
365  std::shared_ptr<Eigen::Matrix4d> _worldTransformMatrix;
366 
367  };
368 }
bmpf::BaseRobot::_path
std::string _path
Definition: robot.h:356
bmpf::BaseRobot::getPath
std::string getPath() const
Definition: robot.h:166
bmpf::BaseRobot::getAllLinkRGVectors
std::vector< double > getAllLinkRGVectors(std::vector< double > state)
Definition: robot.cpp:422
bmpf::BaseRobot::getInertias
virtual std::vector< Eigen::Matrix3d > getInertias()
Definition: robot.cpp:478
bmpf::BaseRobot::~BaseRobot
virtual ~BaseRobot()=default
bmpf::BaseRobot::getLinks
std::vector< std::shared_ptr< Link > > getLinks() const
Definition: robot.h:160
bmpf::BaseRobot::getEndEffectorDiff2RGVector
std::vector< double > getEndEffectorDiff2RGVector(std::vector< double > state, int iVal, int jVal)
Definition: robot.cpp:397
bmpf::BaseRobot::getEndEffectorRGVector
std::vector< double > getEndEffectorRGVector(std::vector< double > state)
Definition: robot.cpp:372
bmpf::BaseRobot::getMassCenterLocalPositions
virtual std::vector< double > getMassCenterLocalPositions()
Definition: robot.cpp:437
bmpf::BaseRobot::setWorldScale
void setWorldScale(const std::vector< double > &scale)
Definition: robot.cpp:290
bmpf::BaseRobot::getJointParamsList
std::vector< std::shared_ptr< JointParams > > getJointParamsList() const
Definition: robot.h:154
bmpf::BaseRobot::_worldTransformVector
std::vector< double > _worldTransformVector
Definition: robot.h:361
bmpf::BaseRobot::getEndEffectorDiffRGVector
std::vector< double > getEndEffectorDiffRGVector(std::vector< double > state, int iVal)
Definition: robot.cpp:384
bmpf::BaseRobot::getEndEffectorTransformMatrix
virtual Eigen::Matrix4d getEndEffectorTransformMatrix(std::vector< double > state)
Definition: robot.cpp:189
bmpf::BaseRobot::getWorldTranslation
std::vector< double > getWorldTranslation() const
Definition: robot.h:93
bmpf::BaseRobot::getRandomState
std::vector< double > getRandomState()
Definition: robot.cpp:489
bmpf::BaseRobot::_nonHierarchicalLinks
std::vector< std::shared_ptr< Link > > _nonHierarchicalLinks
Definition: robot.h:352
bmpf::BaseRobot::getWorldTransformVector
std::vector< double > getWorldTransformVector() const
Definition: robot.h:117
bmpf::BaseRobot::_forEachDiffJoint
void _forEachDiffJoint(std::vector< double > state, int iVal, const F &consumer)
Definition: robot.cpp:93
bmpf::BaseRobot::_fillWorldTransformMatrix
void _fillWorldTransformMatrix()
Definition: robot.cpp:327
bmpf::BaseRobot
Definition: robot.h:19
bmpf::BaseRobot::_forEachJoint
void _forEachJoint(std::vector< double > state, const F &consumer)
Definition: robot.cpp:67
bmpf::BaseRobot::_joints
std::vector< std::shared_ptr< Joint > > _joints
Definition: robot.h:331
bmpf::BaseRobot::loadFromFile
virtual void loadFromFile(std::string path)=0
загрузить параметры робота из файла
bmpf::BaseRobot::getEndEffectorDiffPos
std::vector< double > getEndEffectorDiffPos(std::vector< double > state, int iVal)
Definition: robot.cpp:350
bmpf::BaseRobot::getWorldScale
std::vector< double > getWorldScale() const
Definition: robot.h:109
bmpf::BaseRobot::_maxSpeedModules
std::vector< double > _maxSpeedModules
Definition: robot.h:339
bmpf::BaseRobot::getEndEffectorDiff2Pos
std::vector< double > getEndEffectorDiff2Pos(std::vector< double > state, int iVal, int jVal)
Definition: robot.cpp:362
bmpf::BaseRobot::getMaxAccelerationModules
std::vector< double > getMaxAccelerationModules()
Definition: robot.h:142
bmpf::BaseRobot::getJointAxes
virtual std::vector< Eigen::Vector3d > getJointAxes(std::vector< double > state)
Definition: robot.cpp:171
bmpf::BaseRobot::getEndEffectorDiff2TransformMatrix
Eigen::Matrix4d getEndEffectorDiff2TransformMatrix(std::vector< double > state, int iVal, int jVal)
Definition: robot.cpp:233
bmpf::BaseRobot::BaseRobot
BaseRobot()
Definition: robot.cpp:8
bmpf::BaseRobot::getJointCnt
unsigned long getJointCnt() const
Definition: robot.h:129
bmpf::BaseRobot::getWorldTransformMatrix
const std::shared_ptr< Eigen::Matrix4d > & getWorldTransformMatrix() const
Definition: robot.h:123
bmpf::BaseRobot::setWorldTranslation
void setWorldTranslation(const std::vector< double > &translation)
Definition: robot.cpp:252
bmpf::BaseRobot::getWorldRotation
std::vector< double > getWorldRotation() const
Definition: robot.h:101
bmpf::BaseRobot::getModelPaths
std::vector< std::string > getModelPaths() const
Definition: robot.cpp:44
bmpf::BaseRobot::getEndEffectorDiffTransformMatrix
Eigen::Matrix4d getEndEffectorDiffTransformMatrix(std::vector< double > state, int iVal)
Definition: robot.cpp:211
bmpf::BaseRobot::isStateEnabled
bool isStateEnabled(std::vector< double > state)
Definition: robot.cpp:20
bmpf::BaseRobot::getMaxSpeedModules
std::vector< double > getMaxSpeedModules()
Definition: robot.h:136
bmpf::BaseRobot::getMassCenterAbsolutePositions
std::vector< double > getMassCenterAbsolutePositions(std::vector< double > state)
Definition: robot.cpp:451
bmpf::BaseRobot::getEndEffectorPos
std::vector< double > getEndEffectorPos(std::vector< double > state)
Definition: robot.cpp:339
bmpf::BaseRobot::_forEachDiff2Joint
void _forEachDiff2Joint(std::vector< double > state, int iVal, int jVal, const F &consumer)
Definition: robot.cpp:124
bmpf::BaseRobot::getLinkCnt
unsigned long getLinkCnt() const
Definition: robot.h:148
bmpf::BaseRobot::getAllLinkPositions
std::vector< double > getAllLinkPositions(std::vector< double > state)
Definition: robot.cpp:407
bmpf::BaseRobot::_jointParams
std::vector< std::shared_ptr< JointParams > > _jointParams
Definition: robot.h:335
bmpf::BaseRobot::getTransformMatrices
virtual std::vector< Eigen::Matrix4d > getTransformMatrices(std::vector< double > state)
Definition: robot.cpp:152
bmpf::BaseRobot::_worldTransformMatrix
std::shared_ptr< Eigen::Matrix4d > _worldTransformMatrix
Definition: robot.h:365
bmpf::BaseRobot::_links
std::vector< std::shared_ptr< Link > > _links
Definition: robot.h:348
bmpf::BaseRobot::_maxAccelerationModules
std::vector< double > _maxAccelerationModules
Definition: robot.h:343
bmpf::BaseRobot::setWorldTransformVector
void setWorldTransformVector(const std::vector< double > &vec)
Definition: robot.cpp:309
bmpf::BaseRobot::setWorldRotation
void setWorldRotation(const std::vector< double > &rotation)
Definition: robot.cpp:271