moveit_cpp.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2019, PickNik LLC
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of PickNik LLC nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Henning Kayser
36  Desc: A high level interface that does not require the use of ROS Actions, Services, and Messages to access the
37  core MoveIt functionality
38 */
39 
40 #pragma once
41 
42 #include <ros/ros.h>
47 #include <tf2_ros/buffer.h>
49 
50 namespace moveit_cpp
51 {
52 MOVEIT_CLASS_FORWARD(MoveItCpp); // Defines MoveItCppPtr, ConstPtr, WeakPtr... etc
53 
54 class MoveItCpp
55 {
56 public:
58  struct PlanningSceneMonitorOptions
59  {
60  void load(const ros::NodeHandle& nh)
61  {
62  std::string ns = "planning_scene_monitor_options/";
63  nh.param<std::string>(ns + "name", name, "planning_scene_monitor");
64  nh.param<std::string>(ns + "robot_description", robot_description, "robot_description");
65  nh.param(ns + "joint_state_topic", joint_state_topic,
67  nh.param(ns + "attached_collision_object_topic", attached_collision_object_topic,
69  nh.param(ns + "monitored_planning_scene_topic", monitored_planning_scene_topic,
71  nh.param(ns + "publish_planning_scene_topic", publish_planning_scene_topic,
73  nh.param<double>(ns + "wait_for_initial_state_timeout", wait_for_initial_state_timeout, 0.0);
74  }
75  std::string name;
76  std::string robot_description;
77  std::string joint_state_topic;
80  std::string publish_planning_scene_topic;
82  };
83 
85  struct PlanningPipelineOptions
86  {
87  void load(const ros::NodeHandle& nh)
88  {
89  std::string ns = "planning_pipelines/";
90  nh.getParam(ns + "pipeline_names", pipeline_names);
91  nh.getParam(ns + "namespace", parent_namespace);
92  }
93  std::vector<std::string> pipeline_names;
94  std::string parent_namespace;
95  };
96 
98  struct Options
99  {
100  Options(const ros::NodeHandle& nh)
101  {
104  }
105 
106  PlanningSceneMonitorOptions planning_scene_monitor_options;
108  };
109 
111  MoveItCpp(const ros::NodeHandle& nh, const std::shared_ptr<tf2_ros::Buffer>& tf_buffer = {});
112  MoveItCpp(const Options& options, const ros::NodeHandle& nh, const std::shared_ptr<tf2_ros::Buffer>& tf_buffer = {});
113 
119  MoveItCpp(const MoveItCpp&) = delete;
120  MoveItCpp& operator=(const MoveItCpp&) = delete;
121 
122  MoveItCpp(MoveItCpp&& other) = default;
123  MoveItCpp& operator=(MoveItCpp&& other) = default;
124 
127 
129  moveit::core::RobotModelConstPtr getRobotModel() const;
130 
133 
136  bool getCurrentState(moveit::core::RobotStatePtr& current_state, double wait_seconds);
137 
140  moveit::core::RobotStatePtr getCurrentState(double wait_seconds = 0.0);
141 
143  const std::map<std::string, planning_pipeline::PlanningPipelinePtr>& getPlanningPipelines() const;
144 
147  std::set<std::string> getPlanningPipelineNames(const std::string& group_name = "") const;
148 
150  const planning_scene_monitor::PlanningSceneMonitorPtr& getPlanningSceneMonitor() const;
151  planning_scene_monitor::PlanningSceneMonitorPtr getPlanningSceneMonitorNonConst();
152 
153  const std::shared_ptr<tf2_ros::Buffer>& getTFBuffer() const;
154 
156  const trajectory_execution_manager::TrajectoryExecutionManagerPtr& getTrajectoryExecutionManager() const;
157  trajectory_execution_manager::TrajectoryExecutionManagerPtr getTrajectoryExecutionManagerNonConst();
158 
161  bool execute(const std::string& group_name, const robot_trajectory::RobotTrajectoryPtr& robot_trajectory,
162  bool blocking = true);
163 
164 protected:
165  std::shared_ptr<tf2_ros::Buffer> tf_buffer_;
166  std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
167 
168 private:
169  // Core properties and instances
171  moveit::core::RobotModelConstPtr robot_model_;
172  planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_;
173 
174  // Planning
175  std::map<std::string, planning_pipeline::PlanningPipelinePtr> planning_pipelines_;
176  std::map<std::string, std::set<std::string>> groups_pipelines_map_;
177  std::map<std::string, std::set<std::string>> groups_algorithms_map_;
178 
179  // Execution
180  trajectory_execution_manager::TrajectoryExecutionManagerPtr trajectory_execution_manager_;
181 
183  void clearContents();
184 
187 
189  bool loadPlanningPipelines(const PlanningPipelineOptions& options);
190 };
191 } // namespace moveit_cpp
192 
193 namespace moveit
194 {
196 {
197 using MoveItCpp [[deprecated("use moveit_cpp")]] = moveit_cpp::MoveItCpp;
198 [[deprecated("use moveit_cpp")]] MOVEIT_DECLARE_PTR(MoveItCpp, moveit_cpp::MoveItCpp);
199 } // namespace planning_interface
200 } // namespace moveit
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::publish_planning_scene_topic
std::string publish_planning_scene_topic
Definition: moveit_cpp.h:112
moveit_cpp::MoveItCpp::robot_model_
moveit::core::RobotModelConstPtr robot_model_
Definition: moveit_cpp.h:203
moveit_cpp::MoveItCpp::execute
bool execute(const std::string &group_name, const robot_trajectory::RobotTrajectoryPtr &robot_trajectory, bool blocking=true)
Execute a trajectory on the planning group specified by group_name using the trajectory execution man...
Definition: moveit_cpp.cpp:284
moveit_cpp::MoveItCpp::Options
Parameter container for initializing MoveItCpp.
Definition: moveit_cpp.h:130
moveit_cpp::MoveItCpp::trajectory_execution_manager_
trajectory_execution_manager::TrajectoryExecutionManagerPtr trajectory_execution_manager_
Definition: moveit_cpp.h:212
moveit_cpp::MoveItCpp::Options::Options
Options(const ros::NodeHandle &nh)
Definition: moveit_cpp.h:132
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::joint_state_topic
std::string joint_state_topic
Definition: moveit_cpp.h:109
moveit_cpp::MoveItCpp::planning_scene_monitor_
planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_
Definition: moveit_cpp.h:204
moveit_cpp::MoveItCpp::~MoveItCpp
~MoveItCpp()
Destructor.
Definition: moveit_cpp.cpp:122
moveit_cpp::MoveItCpp::MoveItCpp
MoveItCpp(const ros::NodeHandle &nh, const std::shared_ptr< tf2_ros::Buffer > &tf_buffer={})
Constructor.
Definition: moveit_cpp.cpp:77
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
ros.h
moveit_cpp::MoveItCpp::getPlanningPipelineNames
std::set< std::string > getPlanningPipelineNames(const std::string &group_name="") const
Get the names of all loaded planning pipelines. Specify group_name to filter the results by planning ...
Definition: moveit_cpp.cpp:251
buffer.h
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::monitored_planning_scene_topic
std::string monitored_planning_scene_topic
Definition: moveit_cpp.h:111
moveit_cpp::MoveItCpp::planning_pipelines_
std::map< std::string, planning_pipeline::PlanningPipelinePtr > planning_pipelines_
Definition: moveit_cpp.h:207
robot_state.h
moveit_cpp::MoveItCpp::getPlanningSceneMonitor
const planning_scene_monitor::PlanningSceneMonitorPtr & getPlanningSceneMonitor() const
Get the stored instance of the planning scene monitor.
Definition: moveit_cpp.cpp:264
moveit_cpp::MoveItCpp
Definition: moveit_cpp.h:86
moveit_cpp::MoveItCpp::operator=
MoveItCpp & operator=(const MoveItCpp &)=delete
moveit_cpp
Definition: moveit_cpp.h:50
moveit_cpp::MoveItCpp::getRobotModel
moveit::core::RobotModelConstPtr getRobotModel() const
Get the RobotModel object.
Definition: moveit_cpp.cpp:214
robot_trajectory
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::robot_description
std::string robot_description
Definition: moveit_cpp.h:108
moveit_cpp::MoveItCpp::PlanningPipelineOptions::pipeline_names
std::vector< std::string > pipeline_names
Definition: moveit_cpp.h:125
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions
Specification of options to use when constructing the MoveItCpp class.
Definition: moveit_cpp.h:90
moveit_cpp::MoveItCpp::getTrajectoryExecutionManagerNonConst
trajectory_execution_manager::TrajectoryExecutionManagerPtr getTrajectoryExecutionManagerNonConst()
Definition: moveit_cpp.cpp:279
moveit_cpp::MoveItCpp::PlanningPipelineOptions::load
void load(const ros::NodeHandle &nh)
Definition: moveit_cpp.h:119
moveit_cpp::MoveItCpp::getCurrentState
bool getCurrentState(moveit::core::RobotStatePtr &current_state, double wait_seconds)
Get the current state queried from the current state monitor.
Definition: moveit_cpp.cpp:224
moveit::planning_interface::MOVEIT_DECLARE_PTR
MOVEIT_DECLARE_PTR(MoveItCpp, moveit_cpp::MoveItCpp)
planning_scene_monitor.h
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::attached_collision_object_topic
std::string attached_collision_object_topic
Definition: moveit_cpp.h:110
moveit_cpp::MoveItCpp::clearContents
void clearContents()
Reset all member variables.
Definition: moveit_cpp.cpp:319
moveit_cpp::MoveItCpp::getPlanningSceneMonitorNonConst
planning_scene_monitor::PlanningSceneMonitorPtr getPlanningSceneMonitorNonConst()
Definition: moveit_cpp.cpp:269
moveit_cpp::MoveItCpp::PlanningPipelineOptions
struct contains the the variables used for loading the planning pipeline
Definition: moveit_cpp.h:117
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::wait_for_initial_state_timeout
double wait_for_initial_state_timeout
Definition: moveit_cpp.h:113
moveit_cpp::MoveItCpp::getNodeHandle
const ros::NodeHandle & getNodeHandle() const
Get the ROS node handle of this instance operates on.
Definition: moveit_cpp.cpp:219
moveit_cpp::MoveItCpp::node_handle_
ros::NodeHandle node_handle_
Definition: moveit_cpp.h:202
moveit_cpp::MoveItCpp::Options::planning_pipeline_options
PlanningPipelineOptions planning_pipeline_options
Definition: moveit_cpp.h:139
moveit_cpp::MoveItCpp::groups_algorithms_map_
std::map< std::string, std::set< std::string > > groups_algorithms_map_
Definition: moveit_cpp.h:209
moveit_cpp::MoveItCpp::getPlanningPipelines
const std::map< std::string, planning_pipeline::PlanningPipelinePtr > & getPlanningPipelines() const
Get all loaded planning pipeline instances mapped to their reference names.
Definition: moveit_cpp.cpp:246
transform_listener.h
moveit_cpp::MoveItCpp::tf_listener_
std::shared_ptr< tf2_ros::TransformListener > tf_listener_
Definition: moveit_cpp.h:198
planning_scene_monitor::PlanningSceneMonitor::DEFAULT_JOINT_STATES_TOPIC
static const std::string DEFAULT_JOINT_STATES_TOPIC
The name of the topic used by default for receiving joint states.
Definition: planning_scene_monitor.h:116
planning_scene_monitor::PlanningSceneMonitor::DEFAULT_PLANNING_SCENE_TOPIC
static const std::string DEFAULT_PLANNING_SCENE_TOPIC
The name of the topic used by default for receiving full planning scenes or planning scene diffs.
Definition: planning_scene_monitor.h:129
moveit_cpp::MoveItCpp::loadPlanningSceneMonitor
bool loadPlanningSceneMonitor(const PlanningSceneMonitorOptions &options)
Initialize and setup the planning scene monitor.
Definition: moveit_cpp.cpp:128
planning_scene_monitor::PlanningSceneMonitor::MONITORED_PLANNING_SCENE_TOPIC
static const std::string MONITORED_PLANNING_SCENE_TOPIC
Definition: planning_scene_monitor.h:136
moveit
trajectory_execution_manager.h
planning_pipeline.h
planning_interface
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::load
void load(const ros::NodeHandle &nh)
Definition: moveit_cpp.h:92
moveit_cpp::MoveItCpp::PlanningPipelineOptions::parent_namespace
std::string parent_namespace
Definition: moveit_cpp.h:126
moveit_cpp::MoveItCpp::getTFBuffer
const std::shared_ptr< tf2_ros::Buffer > & getTFBuffer() const
Definition: moveit_cpp.cpp:314
moveit_cpp::MoveItCpp::getTrajectoryExecutionManager
const trajectory_execution_manager::TrajectoryExecutionManagerPtr & getTrajectoryExecutionManager() const
Get the stored instance of the trajectory execution manager.
Definition: moveit_cpp.cpp:274
moveit_cpp::MoveItCpp::PlanningSceneMonitorOptions::name
std::string name
Definition: moveit_cpp.h:107
moveit_cpp::MoveItCpp::groups_pipelines_map_
std::map< std::string, std::set< std::string > > groups_pipelines_map_
Definition: moveit_cpp.h:208
moveit_cpp::MoveItCpp::Options::planning_scene_monitor_options
PlanningSceneMonitorOptions planning_scene_monitor_options
Definition: moveit_cpp.h:138
moveit_cpp::MoveItCpp::loadPlanningPipelines
bool loadPlanningPipelines(const PlanningPipelineOptions &options)
Initialize and setup the planning pipelines.
Definition: moveit_cpp.cpp:164
moveit_cpp::MoveItCpp::tf_buffer_
std::shared_ptr< tf2_ros::Buffer > tf_buffer_
Definition: moveit_cpp.h:197
ros::NodeHandle
moveit::planning_interface::MoveItCpp
moveit_cpp::MoveItCpp MoveItCpp
Definition: moveit_cpp.h:197
moveit_cpp::MOVEIT_CLASS_FORWARD
MOVEIT_CLASS_FORWARD(MoveItCpp)
planning_scene_monitor::PlanningSceneMonitor::DEFAULT_ATTACHED_COLLISION_OBJECT_TOPIC
static const std::string DEFAULT_ATTACHED_COLLISION_OBJECT_TOPIC
The name of the topic used by default for attached collision objects.
Definition: planning_scene_monitor.h:119


planning
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Sun Sep 18 2022 02:26:52