Buran Motion Planning Framework
scene.h
1 #pragma once
2 
3 #include "base/robot.h"
4 
5 #include <Eigen/Dense>
6 #include <vector>
7 #include <cstdlib>
8 #include <cmath>
9 #include <memory>
10 
11 namespace bmpf {
12 
16  class Scene {
17  public:
18 
22  Scene() = default;
23 
28  explicit Scene(const std::vector<std::shared_ptr<bmpf::BaseRobot>> &robot);
29 
33  ~Scene() = default;
34 
40  unsigned long getActiveRobotCnt() const;
41 
47  unsigned long addObject(std::string path);
48 
55  unsigned long addObject(std::string path, std::vector<double> &transformVector);
56 
61  void deleteRobot(long robotNum);
62 
67  void saveToFile(const std::string &path);
68 
73  void loadFromFile(const std::string &path);
74 
79  std::vector<std::pair<long, long>> getJointIndexRanges() { return _jointIndexRanges; }
80 
85  unsigned long getJointCnt() const { return _jointCnt; }
86 
91  bool isSingleActiveRobot() const { return getActiveRobotCnt() == 1; };
92 
97  std::vector<std::shared_ptr<bmpf::JointParams>> getJointParamsList() { return _jointParams; }
98 
103  std::vector<double> getMaxSpeedModules() { return _maxSpeedModules; }
104 
109  std::vector<double> getMaxAccelerationModules() { return _maxAccelerationModules; }
110 
115  std::vector<std::shared_ptr<bmpf::Link>> getLinks() const { return _links; }
116 
123  std::vector<Eigen::Matrix4d> getTransformMatrices(const std::vector<double> &state);
124 
131  std::vector<double> getEndEffectorPositions(const std::vector<double> &state);
132 
139  std::vector<double> getEndEffectorDiffPositions(const std::vector<double>& state, int iVal);
140 
148  std::vector<double> getEndEffectorDiff2Positions(const std::vector<double>& state, int iVal, int jVal);
149 
155  std::vector<Eigen::Matrix4d> getEndEffectorTransformMatrices(const std::vector<double>& state);
156 
164  std::vector<Eigen::Matrix4d> getEndEffectorDiffTransformMatrices(const std::vector<double>& state, int iVal);
165 
174  std::vector<Eigen::Matrix4d>
175  getEndEffectorDiff2TransformMatrices(const std::vector<double>& state, int iVal, int jVal);
176 
182  std::vector<double> getEndEffectorRGVectors(const std::vector<double> &state);
183 
191  std::vector<double> getEndEffectorDiffRGVector(const std::vector<double> &state, int iVal);
192 
201  std::vector<double> getEndEffectorDiff2RGVector(const std::vector<double> &state, int iVal, int jVal);
202 
208  std::vector<double> getAllLinkPositions(const std::vector<double> &state);
209 
216  std::vector<double> getAllLinkRGVectors(const std::vector<double> &state);
217 
223  bool isStateEnabled(const std::vector<double> &state);
224 
232  bool isStateEnabled(std::vector<double> state, unsigned long robotNum);
233 
238  std::vector<double> getRandomState();
239 
244  const std::vector<std::shared_ptr<bmpf::BaseRobot>> &getRobots() const { return _objects; }
245 
250  std::string getScenePath() const { return _path; }
251 
256  std::vector<std::shared_ptr<Scene>> getSingleRobotScenes() { return _singleRobotScenes; }
257 
264  std::vector<double> getSingleObjectState(const std::vector<double> &state, unsigned long objectNum);
265 
270  std::vector<std::vector<double>> getGroupedTranslation() const;
271 
276  std::vector<std::vector<double>> getGroupedRotation() const;
277 
282  std::vector<std::vector<double>> getGroupedScale() const;
283 
288  std::vector<std::vector<double>> getGroupedTransformVector() const;
289 
295  std::vector<std::vector<std::string>> getGroupedModelPaths() const;
296 
301  void setGroupedTranslation(std::vector<std::vector<double>> groupedTranslation);
302 
307  void setGroupedRotation(std::vector<std::vector<double>> groupedRotation);
308 
313  void setGroupedScale(std::vector<std::vector<double>> groupedScale);
314 
319  void setGroupedTransformVector(std::vector<std::vector<double>> transformVectors);
320 
326  static std::vector<double> concatenateStates(const std::vector<std::vector<double>> &states);
327 
333  template<typename ...ArgsT>
334  std::vector<double> concatenateStates(ArgsT ... states) { return concatenateStates({states...}); }
335 
341  static std::vector<double> concatenateStates(std::initializer_list<std::vector<double>> states);
342 
348  template<typename ...ArgsT>
349  std::vector<int> concatenateCoords(ArgsT ... states) { return concatenateCoords({states...}); }
350 
356  static std::vector<int> concatenateCoords(const std::vector<std::vector<int>> &coords);
357 
362  std::vector<bool> areObjectsJointed() { return _areObjectsJointed; }
363 
368  std::vector<int> getJointedObjectIndexes() { return _jointedObjectIndexes; }
369 
374  std::vector<int> getNotJointedObjectIndexes() { return _notJointedObjectIndexes; }
375 
376  protected:
380  void _initObjects();
381 
382  private:
386  std::vector<double> _maxSpeedModules;
390  std::vector<double> _maxAccelerationModules;
394  std::vector<std::pair<long, long>> _jointIndexRanges;
398  unsigned int _jointCnt{};
402  std::vector<std::shared_ptr<bmpf::JointParams>> _jointParams;
408  std::vector<std::shared_ptr<bmpf::Link>> _links;
412  std::vector<std::shared_ptr<bmpf::BaseRobot>> _objects;
416  std::string _path;
421  std::vector<std::shared_ptr<Scene>> _singleRobotScenes;
425  std::vector<bool> _areObjectsJointed;
429  std::vector<int> _notJointedObjectIndexes;
433  std::vector<int> _jointedObjectIndexes;
434  };
435 
436 
437 }
bmpf::Scene::addObject
unsigned long addObject(std::string path)
Definition: scene.cpp:75
bmpf::Scene::isStateEnabled
bool isStateEnabled(const std::vector< double > &state)
Definition: scene.cpp:499
bmpf::Scene::getRobots
const std::vector< std::shared_ptr< bmpf::BaseRobot > > & getRobots() const
Definition: scene.h:244
bmpf::Scene::getJointedObjectIndexes
std::vector< int > getJointedObjectIndexes()
Definition: scene.h:368
bmpf::Scene::getGroupedTranslation
std::vector< std::vector< double > > getGroupedTranslation() const
Definition: scene.cpp:534
bmpf::Scene::getEndEffectorPositions
std::vector< double > getEndEffectorPositions(const std::vector< double > &state)
получить список положений (x,y,z) рабочих инструментов всех роботов получить список положений (x,...
Definition: scene.cpp:332
bmpf::Scene::_initObjects
void _initObjects()
Definition: scene.cpp:107
bmpf::Scene::getLinks
std::vector< std::shared_ptr< bmpf::Link > > getLinks() const
Definition: scene.h:115
bmpf::Scene::getEndEffectorRGVectors
std::vector< double > getEndEffectorRGVectors(const std::vector< double > &state)
Definition: scene.cpp:402
bmpf::Scene::getGroupedTransformVector
std::vector< std::vector< double > > getGroupedTransformVector() const
Definition: scene.cpp:567
bmpf::Scene::getSingleRobotScenes
std::vector< std::shared_ptr< Scene > > getSingleRobotScenes()
Definition: scene.h:256
bmpf::Scene::getJointCnt
unsigned long getJointCnt() const
Definition: scene.h:85
bmpf::Scene::deleteRobot
void deleteRobot(long robotNum)
Definition: scene.cpp:146
bmpf::Scene::setGroupedTransformVector
void setGroupedTransformVector(std::vector< std::vector< double >> transformVectors)
Definition: scene.cpp:643
bmpf::Scene::setGroupedTranslation
void setGroupedTranslation(std::vector< std::vector< double >> groupedTranslation)
Definition: scene.cpp:590
bmpf::Scene::getMaxAccelerationModules
std::vector< double > getMaxAccelerationModules()
Definition: scene.h:109
bmpf::Scene::getGroupedRotation
std::vector< std::vector< double > > getGroupedRotation() const
Definition: scene.cpp:545
bmpf::Scene::getEndEffectorDiff2Positions
std::vector< double > getEndEffectorDiff2Positions(const std::vector< double > &state, int iVal, int jVal)
Definition: scene.cpp:374
bmpf::Scene::concatenateStates
std::vector< double > concatenateStates(ArgsT ... states)
Definition: scene.h:334
bmpf::Scene::getEndEffectorDiffRGVector
std::vector< double > getEndEffectorDiffRGVector(const std::vector< double > &state, int iVal)
Definition: scene.cpp:420
bmpf::Scene::getAllLinkPositions
std::vector< double > getAllLinkPositions(const std::vector< double > &state)
Definition: scene.cpp:455
bmpf::Scene::isSingleActiveRobot
bool isSingleActiveRobot() const
Definition: scene.h:91
bmpf::Scene::getRandomState
std::vector< double > getRandomState()
Definition: scene.cpp:519
bmpf::Scene::getMaxSpeedModules
std::vector< double > getMaxSpeedModules()
Definition: scene.h:103
bmpf::Scene::saveToFile
void saveToFile(const std::string &path)
Definition: scene.cpp:155
bmpf::Scene::getGroupedModelPaths
std::vector< std::vector< std::string > > getGroupedModelPaths() const
Definition: scene.cpp:579
bmpf::Scene::concatenateCoords
std::vector< int > concatenateCoords(ArgsT ... states)
Definition: scene.h:349
bmpf::Scene::Scene
Scene()=default
bmpf::Scene::setGroupedRotation
void setGroupedRotation(std::vector< std::vector< double >> groupedRotation)
Definition: scene.cpp:608
bmpf::Scene::getAllLinkRGVectors
std::vector< double > getAllLinkRGVectors(const std::vector< double > &state)
Definition: scene.cpp:472
bmpf::Scene::concatenateStates
static std::vector< double > concatenateStates(const std::vector< std::vector< double >> &states)
Definition: scene.cpp:51
bmpf::Scene::getEndEffectorDiffPositions
std::vector< double > getEndEffectorDiffPositions(const std::vector< double > &state, int iVal)
Definition: scene.cpp:350
bmpf::Scene::getJointIndexRanges
std::vector< std::pair< long, long > > getJointIndexRanges()
Definition: scene.h:79
bmpf::Scene::getSingleObjectState
std::vector< double > getSingleObjectState(const std::vector< double > &state, unsigned long objectNum)
Definition: scene.cpp:240
bmpf::Scene::getEndEffectorDiff2TransformMatrices
std::vector< Eigen::Matrix4d > getEndEffectorDiff2TransformMatrices(const std::vector< double > &state, int iVal, int jVal)
Definition: scene.cpp:315
bmpf::Scene::getEndEffectorDiffTransformMatrices
std::vector< Eigen::Matrix4d > getEndEffectorDiffTransformMatrices(const std::vector< double > &state, int iVal)
Definition: scene.cpp:295
bmpf::Scene::getTransformMatrices
std::vector< Eigen::Matrix4d > getTransformMatrices(const std::vector< double > &state)
получить список матриц преобразований всех звеньев получить список матриц преобразований всех звеньев...
Definition: scene.cpp:254
bmpf::Scene::getEndEffectorTransformMatrices
std::vector< Eigen::Matrix4d > getEndEffectorTransformMatrices(const std::vector< double > &state)
Definition: scene.cpp:277
bmpf::Scene::getEndEffectorDiff2RGVector
std::vector< double > getEndEffectorDiff2RGVector(const std::vector< double > &state, int iVal, int jVal)
Definition: scene.cpp:439
bmpf::Scene::loadFromFile
void loadFromFile(const std::string &path)
Definition: scene.cpp:185
bmpf::Scene::getActiveRobotCnt
unsigned long getActiveRobotCnt() const
посчитать количество активных роботов посчитать количество активных роботов на сцене (объектов с пере...
Definition: scene.cpp:25
bmpf::Scene::setGroupedScale
void setGroupedScale(std::vector< std::vector< double >> groupedScale)
Definition: scene.cpp:626
bmpf::Scene
Definition: scene.h:16
bmpf::Scene::getNotJointedObjectIndexes
std::vector< int > getNotJointedObjectIndexes()
Definition: scene.h:374
bmpf::Scene::~Scene
~Scene()=default
bmpf::Scene::areObjectsJointed
std::vector< bool > areObjectsJointed()
Definition: scene.h:362
bmpf::Scene::getJointParamsList
std::vector< std::shared_ptr< bmpf::JointParams > > getJointParamsList()
Definition: scene.h:97
bmpf::Scene::getGroupedScale
std::vector< std::vector< double > > getGroupedScale() const
Definition: scene.cpp:556
bmpf::Scene::getScenePath
std::string getScenePath() const
Definition: scene.h:250