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