moveit2
The MoveIt Motion Planning Framework for ROS 2.
planning_scene_storage.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
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 Willow Garage 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: Ioan Sucan */
36 
37 #pragma once
38 
41 #include <moveit_msgs/msg/planning_scene.hpp>
42 #include <moveit_msgs/msg/motion_plan_request.hpp>
43 #include <moveit_msgs/msg/robot_trajectory.hpp>
44 
45 #include <moveit_warehouse_export.h>
46 
47 namespace moveit_warehouse
48 {
49 typedef warehouse_ros::MessageWithMetadata<moveit_msgs::msg::PlanningScene>::ConstPtr PlanningSceneWithMetadata;
50 typedef warehouse_ros::MessageWithMetadata<moveit_msgs::msg::MotionPlanRequest>::ConstPtr MotionPlanRequestWithMetadata;
51 typedef warehouse_ros::MessageWithMetadata<moveit_msgs::msg::RobotTrajectory>::ConstPtr RobotTrajectoryWithMetadata;
52 
53 typedef warehouse_ros::MessageCollection<moveit_msgs::msg::PlanningScene>::Ptr PlanningSceneCollection;
54 typedef warehouse_ros::MessageCollection<moveit_msgs::msg::MotionPlanRequest>::Ptr MotionPlanRequestCollection;
55 typedef warehouse_ros::MessageCollection<moveit_msgs::msg::RobotTrajectory>::Ptr RobotTrajectoryCollection;
56 
57 MOVEIT_CLASS_FORWARD(PlanningSceneStorage); // Defines PlanningSceneStoragePtr, ConstPtr, WeakPtr... etc
58 
59 class MOVEIT_WAREHOUSE_EXPORT PlanningSceneStorage : public MoveItMessageStorage
60 {
61 public:
62  static const std::string DATABASE_NAME;
63 
64  static const std::string PLANNING_SCENE_ID_NAME;
65  static const std::string MOTION_PLAN_REQUEST_ID_NAME;
66 
67  PlanningSceneStorage(warehouse_ros::DatabaseConnection::Ptr conn);
68 
69  void addPlanningScene(const moveit_msgs::msg::PlanningScene& scene);
70  void addPlanningQuery(const moveit_msgs::msg::MotionPlanRequest& planning_query, const std::string& scene_name,
71  const std::string& query_name = "");
72  void addPlanningResult(const moveit_msgs::msg::MotionPlanRequest& planning_query,
73  const moveit_msgs::msg::RobotTrajectory& result, const std::string& scene_name);
74 
75  bool hasPlanningScene(const std::string& name) const;
76  void getPlanningSceneNames(std::vector<std::string>& names) const;
77  void getPlanningSceneNames(const std::string& regex, std::vector<std::string>& names) const;
78 
80  bool getPlanningScene(PlanningSceneWithMetadata& scene_m, const std::string& scene_name) const;
81  bool getPlanningSceneWorld(moveit_msgs::msg::PlanningSceneWorld& world, const std::string& scene_name) const;
82 
83  bool hasPlanningQuery(const std::string& scene_name, const std::string& query_name) const;
84  bool getPlanningQuery(MotionPlanRequestWithMetadata& query_m, const std::string& scene_name,
85  const std::string& query_name);
86  void getPlanningQueries(std::vector<MotionPlanRequestWithMetadata>& planning_queries,
87  const std::string& scene_name) const;
88  void getPlanningQueriesNames(std::vector<std::string>& query_names, const std::string& scene_name) const;
89  void getPlanningQueriesNames(const std::string& regex, std::vector<std::string>& query_names,
90  const std::string& scene_name) const;
91  void getPlanningQueries(std::vector<MotionPlanRequestWithMetadata>& planning_queries,
92  std::vector<std::string>& query_names, const std::string& scene_name) const;
93 
94  void getPlanningResults(std::vector<RobotTrajectoryWithMetadata>& planning_results, const std::string& scene_name,
95  const moveit_msgs::msg::MotionPlanRequest& planning_query) const;
96  void getPlanningResults(std::vector<RobotTrajectoryWithMetadata>& planning_results, const std::string& scene_name,
97  const std::string& query_name) const;
98 
99  void renamePlanningScene(const std::string& old_scene_name, const std::string& new_scene_name);
100  void renamePlanningQuery(const std::string& scene_name, const std::string& old_query_name,
101  const std::string& new_query_name);
102 
103  void removePlanningScene(const std::string& scene_name);
104  void removePlanningQuery(const std::string& scene_name, const std::string& query_name);
105  void removePlanningQueries(const std::string& scene_name);
106  void removePlanningResults(const std::string& scene_name);
107  void removePlanningResults(const std::string& scene_name, const std::string& query_name);
108 
109  void reset();
110 
111 private:
112  void createCollections();
113 
114  std::string getMotionPlanRequestName(const moveit_msgs::msg::MotionPlanRequest& planning_query,
115  const std::string& scene_name) const;
116  std::string addNewPlanningRequest(const moveit_msgs::msg::MotionPlanRequest& planning_query,
117  const std::string& scene_name, const std::string& query_name);
118 
119  PlanningSceneCollection planning_scene_collection_;
120  MotionPlanRequestCollection motion_plan_request_collection_;
121  RobotTrajectoryCollection robot_trajectory_collection_;
122 };
123 } // namespace moveit_warehouse
This class provides the mechanism to connect to a database and reads needed ROS parameters when appro...
static const std::string MOTION_PLAN_REQUEST_ID_NAME
warehouse_ros::MessageCollection< moveit_msgs::msg::PlanningScene >::Ptr PlanningSceneCollection
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::RobotTrajectory >::ConstPtr RobotTrajectoryWithMetadata
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::PlanningScene >::ConstPtr PlanningSceneWithMetadata
MOVEIT_CLASS_FORWARD(PlanningSceneStorage)
warehouse_ros::MessageCollection< moveit_msgs::msg::MotionPlanRequest >::Ptr MotionPlanRequestCollection
warehouse_ros::MessageWithMetadata< moveit_msgs::msg::MotionPlanRequest >::ConstPtr MotionPlanRequestWithMetadata
warehouse_ros::MessageCollection< moveit_msgs::msg::RobotTrajectory >::Ptr RobotTrajectoryCollection
scene
Definition: pick.py:52
moveit_msgs::msg::MotionPlanRequest MotionPlanRequest
name
Definition: setup.py:7