Planner2D.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 #include <Eigen/Geometry>
9 
10 #include <VirtualRobot/VirtualRobot.h>
11 
13 {
14 
15  class Planner2D
16  {
17  public:
18  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
19  /**
20  Initialize Planner with robot and obstacles.
21  \param robot The robot
22  \param obstacles The obstacles which should be considered by the planner
23  */
25  VirtualRobot::SceneObjectSetPtr obstacles = VirtualRobot::SceneObjectSetPtr());
26 
27  virtual ~Planner2D() = default;
28 
29  // planners implement this method
30  virtual std::vector<Eigen::Vector2f> plan(const Eigen::Vector2f& start,
31  const Eigen::Vector2f& goal) = 0;
32 
33  /// Update obstacles
34  void setObstacles(VirtualRobot::SceneObjectSetPtr obstacles);
35 
36  /// update robot
38 
39  /// set name of RobotNode which should be used for collision detection
40  void setRobotColModel(const std::string& robotColModelName);
41 
42  Eigen::Matrix4f positionToMatrix4f(Eigen::Vector2f pos);
43 
44  /// set a float parameter that is identified with a string
45  void setParameter(const std::string& s, float p);
46 
47  /// check if a parameter is set
48  bool hasParameter(const std::string& s);
49 
50  /// get the corresponding float parameter (0 is returned when parameter string is not present)
51  float getParameter(const std::string& s);
52 
53  struct point2D
54  {
55  float x;
56  float y;
57  float dirX;
58  float dirY;
59  };
60 
61  virtual std::vector<point2D>
62  getGridVisu(float xdist, float ydist, Eigen::Vector2f goal)
63  {
64  return std::vector<point2D>();
65  }
66 
67  protected:
68  std::string robotColModelName;
69  //local copy of the robot's collision model that can be moved around without moving the robot
70  VirtualRobot::CollisionModelPtr robotCollisionModel;
72  VirtualRobot::SceneObjectSetPtr obstacles;
73  Eigen::Vector2f sceneBoundsMin;
74  Eigen::Vector2f sceneBoundsMax;
75 
76  std::map<std::string, float> parameters;
77  };
78 
79  using Planner2DPtr = std::shared_ptr<Planner2D>;
80 
81 } // namespace armarx::navigation::algorithm::astar
armarx::navigation::algorithm::astar::Planner2D::plan
virtual std::vector< Eigen::Vector2f > plan(const Eigen::Vector2f &start, const Eigen::Vector2f &goal)=0
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::navigation::algorithm::astar::Planner2D::point2D::x
float x
Definition: Planner2D.h:55
armarx::navigation::algorithm::astar::Planner2DPtr
std::shared_ptr< Planner2D > Planner2DPtr
Definition: Planner2D.h:79
armarx::navigation::algorithm::astar::Planner2D::obstacles
VirtualRobot::SceneObjectSetPtr obstacles
Definition: Planner2D.h:72
armarx::navigation::algorithm::astar::Planner2D::setRobot
void setRobot(VirtualRobot::RobotPtr robot)
update robot
Definition: Planner2D.cpp:43
armarx::navigation::algorithm::astar::Planner2D::~Planner2D
virtual ~Planner2D()=default
armarx::navigation::algorithm::astar::Planner2D::robot
VirtualRobot::RobotPtr robot
Definition: Planner2D.h:71
armarx::navigation::algorithm::astar::Planner2D::sceneBoundsMax
Eigen::Vector2f sceneBoundsMax
Definition: Planner2D.h:74
armarx::navigation::algorithm::astar::Planner2D::robotColModelName
std::string robotColModelName
Definition: Planner2D.h:68
armarx::navigation::algorithm::astar::Planner2D::point2D::dirX
float dirX
Definition: Planner2D.h:57
armarx::navigation::algorithm::astar::Planner2D::positionToMatrix4f
Eigen::Matrix4f positionToMatrix4f(Eigen::Vector2f pos)
Definition: Planner2D.cpp:55
armarx::navigation::algorithm::astar::Planner2D::getGridVisu
virtual std::vector< point2D > getGridVisu(float xdist, float ydist, Eigen::Vector2f goal)
Definition: Planner2D.h:62
armarx::navigation::algorithm::astar
Definition: AStarPlanner.cpp:32
armarx::navigation::algorithm::astar::Planner2D::setRobotColModel
void setRobotColModel(const std::string &robotColModelName)
set name of RobotNode which should be used for collision detection
Definition: Planner2D.cpp:49
armarx::navigation::algorithm::astar::Planner2D::setObstacles
void setObstacles(VirtualRobot::SceneObjectSetPtr obstacles)
Update obstacles.
Definition: Planner2D.cpp:26
armarx::navigation::algorithm::astar::Planner2D::point2D
Definition: Planner2D.h:53
armarx::navigation::algorithm::astar::Planner2D::hasParameter
bool hasParameter(const std::string &s)
check if a parameter is set
Definition: Planner2D.cpp:70
armarx::navigation::algorithm::astar::Planner2D::sceneBoundsMin
Eigen::Vector2f sceneBoundsMin
Definition: Planner2D.h:73
armarx::navigation::algorithm::astar::Planner2D::Planner2D
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Planner2D(VirtualRobot::RobotPtr robot, VirtualRobot::SceneObjectSetPtr obstacles=VirtualRobot::SceneObjectSetPtr())
Initialize Planner with robot and obstacles.
Definition: Planner2D.cpp:17
armarx::navigation::algorithm::astar::Planner2D::getParameter
float getParameter(const std::string &s)
get the corresponding float parameter (0 is returned when parameter string is not present)
Definition: Planner2D.cpp:76
armarx::navigation::algorithm::astar::Planner2D::point2D::y
float y
Definition: Planner2D.h:56
armarx::navigation::algorithm::astar::Planner2D::setParameter
void setParameter(const std::string &s, float p)
set a float parameter that is identified with a string
Definition: Planner2D.cpp:64
armarx::navigation::algorithm::astar::Planner2D
Definition: Planner2D.h:15
armarx::navigation::algorithm::astar::Planner2D::point2D::dirY
float dirY
Definition: Planner2D.h:58
armarx::navigation::algorithm::astar::Planner2D::parameters
std::map< std::string, float > parameters
Definition: Planner2D.h:76
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::navigation::algorithm::astar::Planner2D::robotCollisionModel
VirtualRobot::CollisionModelPtr robotCollisionModel
Definition: Planner2D.h:70