Robowflex  v0.1
Making MoveIt Easy
planner.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef ROBOWFLEX_DART_PLANNER_
4 #define ROBOWFLEX_DART_PLANNER_
5 
8 
9 namespace robowflex
10 {
11  namespace darts
12  {
13  /** \cond IGNORE */
14  ROBOWFLEX_CLASS_FORWARD(DARTPlanner);
15  /** \endcond */
16 
17  /** \class robowflex::darts::DARTPlannerPtr
18  \brief A shared pointer wrapper for robowflex::darts::DARTPlanner. */
19 
20  /** \class robowflex::darts::DARTPlannerConstPtr
21  \brief A const shared pointer wrapper for robowflex::darts::DARTPlanner. */
22 
23  /** \brief Wrapper for easy access to DART planning tools via standard Robowflex interface.
24  */
26  {
27  public:
28  /** \brief Constructor.
29  * Takes in a \a robot description and an optional namespace \a name.
30  * If \a name is specified, planner parameters are namespaced under the namespace of \a robot.
31  * \param[in] robot The robot to plan for.
32  * \param[in] name Optional namespace for planner.
33  */
34  DARTPlanner(const robowflex::RobotPtr &robot, const std::string &name = "DARTPlanner");
35 
36  /** \brief This function is called before benchmarking. Here, it is used to setup the DART scene
37  * before the solve method.
38  * \param[in] scene Scene to plan for.
39  * \param[in] request Planning request.
40  */
42  const planning_interface::MotionPlanRequest &request) override;
43 
44  /** \brief Plan a motion given a \a request and a \a scene.
45  * \param[in] scene A planning scene for the same \a robot_ to compute the plan in.
46  * \param[in] request The motion planning request to solve.
47  * \return The motion planning response generated by the planner.
48  */
51  const planning_interface::MotionPlanRequest &request) override;
52 
53  /** \brief Return all planner configurations offered by this planner.
54  * Any of the configurations returned can be set as the planner for a motion planning query sent
55  * to plan(). \return A vector of strings of planner configuration names.
56  */
58 
59  PlanBuilderPtr builder; ///< DART Motion Plan Builder
60 
61  private:
62  /** \brief A funciton that returns an allocated planner
63  */
64  using PlannerAllocator = std::function<ompl::base::PlannerPtr()>;
65 
66  /** \brief Macro for creating and setting up an OMPL planner.
67  * \param[in] args Arguments to pass to the planner.
68  * \tparam[in] T Type of planner.
69  * \return Allocated planner.
70  */
71  template <typename T, typename... Args>
72  PlannerAllocator makePlanner(Args &&... args)
73  {
74  return [&]() -> ompl::base::PlannerPtr {
75  if (builder)
76  {
77  auto p = std::make_shared<T>(builder->info, std::forward<Args>(args)...);
78  p->setup();
79  return p;
80  }
81 
82  return nullptr;
83  };
84  }
85 
86  /** \brief Setup planner allocators.
87  */
88  void setupPlanners();
89 
91  SceneConstPtr scene_; ///< Current planning request scene.
92  StructurePtr dart_scene_; ///< DART version of current planning request scene.
93  RobotPtr dart_robot_; ///< DART version of the robot.
94  WorldPtr world_; ///< DART world containing robot and scene.
95  ompl::base::GoalPtr goal_; ///< Current motion planning goal.
96  };
97  } // namespace darts
98 } // namespace robowflex
99 
100 #endif
#define ROBOWFLEX_CLASS_FORWARD(C)
Macro that forward declares a class and defines two shared ptrs types:
Definition: class_forward.h:16
An abstract interface to a motion planning algorithm.
A shared pointer wrapper for robowflex::Robot.
A const shared pointer wrapper for robowflex::Scene.
Wrapper for easy access to DART planning tools via standard Robowflex interface.
Definition: planner.h:26
std::vector< std::string > getPlannerConfigs() const override
Return all planner configurations offered by this planner. Any of the configurations returned can be ...
Definition: planner.cpp:157
void setupPlanners()
Setup planner allocators.
Definition: planner.cpp:44
RobotPtr dart_robot_
DART version of the robot.
Definition: planner.h:93
DARTPlanner(const robowflex::RobotPtr &robot, const std::string &name="DARTPlanner")
Constructor. Takes in a robot description and an optional namespace name. If name is specified,...
Definition: planner.cpp:34
PlanBuilderPtr builder
DART Motion Plan Builder.
Definition: planner.h:59
StructurePtr dart_scene_
DART version of current planning request scene.
Definition: planner.h:92
void preRun(const robowflex::SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) override
This function is called before benchmarking. Here, it is used to setup the DART scene before the solv...
Definition: planner.cpp:78
PlannerAllocator makePlanner(Args &&... args)
Macro for creating and setting up an OMPL planner.
Definition: planner.h:72
planning_interface::MotionPlanResponse plan(const robowflex::SceneConstPtr &scene, const planning_interface::MotionPlanRequest &request) override
Plan a motion given a request and a scene.
Definition: planner.cpp:102
WorldPtr world_
DART world containing robot and scene.
Definition: planner.h:94
ompl::base::GoalPtr goal_
Current motion planning goal.
Definition: planner.h:95
SceneConstPtr scene_
Current planning request scene.
Definition: planner.h:91
std::map< std::string, PlannerAllocator > planner_allocators_
Named planner allocators.
Definition: planner.h:90
A shared pointer wrapper for robowflex::darts::PlanBuilder.
A shared pointer wrapper for robowflex::darts::Structure.
Definition: structure.h:34
A shared pointer wrapper for robowflex::darts::World.
moveit_msgs::MotionPlanRequest MotionPlanRequest
Functions for loading and animating robots in Blender.
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
Functions for loading and animating scenes in Blender.