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