41 #include <moveit/task_constructor/stage.h>
42 #include <moveit/task_constructor/properties.h>
43 #include <moveit/task_constructor/type_traits.h>
44 #include <moveit_msgs/CollisionObject.h>
49 MOVEIT_CLASS_FORWARD(JointModelGroup);
54 namespace task_constructor {
68 using Names = std::vector<std::string>;
69 using ApplyCallback = std::function<void(
const planning_scene::PlanningScenePtr&,
const PropertyMap&)>;
79 void attachObjects(
const Names& objects,
const std::string& attach_link,
bool attach);
81 void addObject(
const moveit_msgs::CollisionObject& collision_object);
85 void moveObject(
const moveit_msgs::CollisionObject& collision_object);
88 inline void attachObject(
const std::string&
object,
const std::string& link);
89 inline void detachObject(
const std::string&
object,
const std::string& link);
92 template <
typename T,
typename E =
typename std::enable_if_t<
95 attachObjects(Names(objects.cbegin(), objects.cend()), link,
true);
97 template <
typename T,
typename E =
typename std::enable_if_t<
99 inline void detachObjects(
const T& objects,
const std::string& link) {
100 attachObjects(Names(objects.cbegin(), objects.cend()), link,
false);
104 void allowCollisions(
const Names& first,
const Names& second,
bool allow);
106 void allowCollisions(
const std::string& first,
const std::string& second,
bool allow) {
113 template <
typename T1,
typename T2,
114 typename E1 =
typename std::enable_if_t<is_container<T1>::value &&
115 std::is_convertible<typename T1::value_type, std::string>::value>,
116 typename E2 =
typename std::enable_if_t<is_container<T2>::value &&
117 std::is_convertible<typename T1::value_type, std::string>::value>>
118 inline void allowCollisions(
const T1& first,
const T2& second,
bool enable_collision) {
119 allowCollisions(Names(first.cbegin(), first.cend()), Names(second.cbegin(), second.cend()), enable_collision);
122 template <
typename T,
typename E =
typename std::enable_if_t<
124 inline void allowCollisions(
const std::string& first,
const T& second,
bool enable_collision) {
125 allowCollisions(Names({ first }), Names(second.cbegin(), second.cend()), enable_collision);
128 template <
typename T,
typename E =
typename std::enable_if_t<
130 inline void allowCollisions(
const char* first,
const T& second,
bool enable_collision) {
131 allowCollisions(Names({ first }), Names(second.cbegin(), second.cend()), enable_collision);
134 void allowCollisions(
const std::string& first,
const moveit::core::JointModelGroup& jmg,
bool allow);
138 std::map<std::string, std::pair<Names, bool>> attach_objects_;
140 std::vector<moveit_msgs::CollisionObject> collision_objects_;
149 std::list<CollisionMatrixPairs> collision_matrix_edits_;
150 ApplyCallback callback_;
154 std::pair<InterfaceState, SubTrajectory> apply(
const InterfaceState& from,
bool invert);
155 void processCollisionObject(planning_scene::PlanningScene& scene,
const moveit_msgs::CollisionObject&
object,
157 void attachObjects(planning_scene::PlanningScene& scene,
const std::pair<std::string, std::pair<Names, bool>>& pair,
166 inline void ModifyPlanningScene::detachObject(
const std::string&
object,
const std::string& link) {
Definition: properties.h:257
Definition: modify_planning_scene.h:66
void allowCollisions(const char *first, const T &second, bool enable_collision)
conveniency method accepting const char* and an arbitrary container of names
Definition: modify_planning_scene.h:130
void addObject(const moveit_msgs::CollisionObject &collision_object)
Add an object to the planning scene.
Definition: modify_planning_scene.cpp:60
void attachObjects(const Names &objects, const std::string &attach_link, bool attach)
attach or detach a list of objects to the given link
Definition: modify_planning_scene.cpp:54
void allowCollisions(const std::string &first, const std::string &second, bool allow)
allow / forbid collisions for pair (first, second)
Definition: modify_planning_scene.h:106
void allowCollisions(const T1 &first, const T2 &second, bool enable_collision)
conveniency method accepting arbitrary container types
Definition: modify_planning_scene.h:118
void allowCollisions(const Names &first, const Names &second, bool allow)
allow / forbid collisions for each combination of pairs in first and second lists
Definition: modify_planning_scene.cpp:86
void allowCollisions(const std::string &first, const T &second, bool enable_collision)
conveniency method accepting std::string and an arbitrary container of names
Definition: modify_planning_scene.h:124
void attachObject(const std::string &object, const std::string &link)
conviency methods accepting a single object name
Definition: modify_planning_scene.h:162
void moveObject(const moveit_msgs::CollisionObject &collision_object)
Move an object from the planning scene.
Definition: modify_planning_scene.cpp:77
void setCallback(const ApplyCallback &cb)
call an arbitrary function
Definition: modify_planning_scene.h:76
void attachObjects(const T &objects, const std::string &link)
conviency methods accepting any container of object names
Definition: modify_planning_scene.h:94
void allowCollisions(const std::string &object, bool allow)
allow / forbid all collisions for given object
Definition: modify_planning_scene.h:110
void removeObject(const std::string &object_name)
Remove an object from the planning scene.
Definition: modify_planning_scene.cpp:70
Definition: type_traits.h:49
Definition: modify_planning_scene.h:144