Planner2D.cpp
Go to the documentation of this file.
1 #include "Planner2D.h"
2 
3 #include <algorithm>
4 #include <cmath>
5 
6 #include <VirtualRobot/CollisionDetection/CollisionModel.h>
8 
10 {
11 
12  Planner2D::Planner2D(VirtualRobot::RobotPtr robot, VirtualRobot::SceneObjectSetPtr obstacles)
13  {
14  sceneBoundsMin.setZero();
15  sceneBoundsMax.setZero();
16  setRobot(robot);
18  }
19 
20  void
21  Planner2D::setObstacles(VirtualRobot::SceneObjectSetPtr obstacles)
22  {
23  this->obstacles = obstacles;
24  if (obstacles)
25  {
26  for (size_t i = 0; i < obstacles->getCollisionModels().size(); i++)
27  {
28  VirtualRobot::BoundingBox bb = obstacles->getCollisionModels()[i]->getBoundingBox();
29  sceneBoundsMin.x() = std::min(bb.getMin().x(), sceneBoundsMin.x());
30  sceneBoundsMin.y() = std::min(bb.getMin().y(), sceneBoundsMin.y());
31  sceneBoundsMax.x() = std::max(bb.getMax().x(), sceneBoundsMax.x());
32  sceneBoundsMax.y() = std::max(bb.getMax().y(), sceneBoundsMax.y());
33  }
34  }
35  }
36 
37  void
39  {
40  this->robot = robot;
41  }
42 
43  void
44  Planner2D::setRobotColModel(const std::string& robotColModelName)
45  {
46  this->robotColModelName = robotColModelName;
47  }
48 
50  Planner2D::positionToMatrix4f(Eigen::Vector2f pos)
51  {
53  result(0, 3) = pos.x();
54  result(1, 3) = pos.y();
55  return result;
56  }
57 
58  void
59  Planner2D::setParameter(const std::string& s, float p)
60  {
61  parameters[s] = p;
62  }
63 
64  bool
65  Planner2D::hasParameter(const std::string& s)
66  {
67  return (parameters.find(s) != parameters.end());
68  }
69 
70  float
71  Planner2D::getParameter(const std::string& s)
72  {
73  if (!hasParameter(s))
74  {
75  ARMARX_WARNING << "Parameter " << s << " not set, returning 0";
76  return 0.0f;
77  }
78  return parameters[s];
79  }
80 
81 } // namespace armarx::navigation::algorithm::astar
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::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
Planner2D.h
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::navigation::algorithm::astar::Planner2D::positionToMatrix4f
Eigen::Matrix4f positionToMatrix4f(Eigen::Vector2f pos)
Definition: Planner2D.cpp:50
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
max
T max(T t1, T t2)
Definition: gdiam.h:48
armarx::navigation::algorithm::astar::Planner2D::setObstacles
void setObstacles(VirtualRobot::SceneObjectSetPtr obstacles)
Update obstacles.
Definition: Planner2D.cpp:21
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
Logging.h
min
T min(T t1, T t2)
Definition: gdiam.h:42
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
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::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