58 constraints_collection_ =
59 conn_->openCollectionPtr<moveit_msgs::TrajectoryConstraints>(DATABASE_NAME,
"trajectory_constraints");
64 constraints_collection_.reset();
65 conn_->dropDatabase(DATABASE_NAME);
70 const moveit_msgs::TrajectoryConstraints& msg,
const std::string& name,
const std::string& robot,
71 const std::string& group)
74 if (hasTrajectoryConstraints(
name, robot, group))
76 removeTrajectoryConstraints(
name, robot, group);
79 Metadata::Ptr metadata = constraints_collection_->createMetadata();
80 metadata->append(CONSTRAINTS_ID_NAME,
name);
81 metadata->append(ROBOT_NAME, robot);
82 metadata->append(CONSTRAINTS_GROUP_NAME, group);
83 constraints_collection_->insert(msg, metadata);
84 ROS_DEBUG(
"%s constraints '%s'", replace ?
"Replaced" :
"Added",
name.c_str());
88 const std::string& robot,
89 const std::string& group)
const
91 Query::Ptr q = constraints_collection_->createQuery();
92 q->append(CONSTRAINTS_ID_NAME,
name);
94 q->append(ROBOT_NAME, robot);
96 q->append(CONSTRAINTS_GROUP_NAME, group);
97 std::vector<TrajectoryConstraintsWithMetadata> constr = constraints_collection_->queryList(q,
true);
98 return !constr.empty();
102 std::vector<std::string>& names,
103 const std::string& robot,
104 const std::string& group)
const
106 getKnownTrajectoryConstraints(names, robot, group);
107 filterNames(regex, names);
111 const std::string& robot,
112 const std::string& group)
const
115 Query::Ptr q = constraints_collection_->createQuery();
117 q->append(ROBOT_NAME, robot);
119 q->append(CONSTRAINTS_GROUP_NAME, group);
120 std::vector<TrajectoryConstraintsWithMetadata> constr =
121 constraints_collection_->queryList(q,
true, CONSTRAINTS_ID_NAME,
true);
123 if (traj_constraint->lookupField(CONSTRAINTS_ID_NAME))
124 names.push_back(traj_constraint->lookupString(CONSTRAINTS_ID_NAME));
128 const std::string& name,
129 const std::string& robot,
130 const std::string& group)
const
132 Query::Ptr q = constraints_collection_->createQuery();
133 q->append(CONSTRAINTS_ID_NAME,
name);
135 q->append(ROBOT_NAME, robot);
137 q->append(CONSTRAINTS_GROUP_NAME, group);
138 std::vector<TrajectoryConstraintsWithMetadata> constr = constraints_collection_->queryList(q,
false);
143 msg_m = constr.back();
149 const std::string& new_name,
150 const std::string& robot,
151 const std::string& group)
153 Query::Ptr q = constraints_collection_->createQuery();
154 q->append(CONSTRAINTS_ID_NAME, old_name);
156 q->append(ROBOT_NAME, robot);
158 q->append(CONSTRAINTS_GROUP_NAME, group);
159 Metadata::Ptr m = constraints_collection_->createMetadata();
160 m->append(CONSTRAINTS_ID_NAME, new_name);
161 constraints_collection_->modifyMetadata(q, m);
162 ROS_DEBUG(
"Renamed constraints from '%s' to '%s'", old_name.c_str(), new_name.c_str());
166 const std::string& robot,
167 const std::string& group)
169 Query::Ptr q = constraints_collection_->createQuery();
170 q->append(CONSTRAINTS_ID_NAME,
name);
172 q->append(ROBOT_NAME, robot);
174 q->append(CONSTRAINTS_GROUP_NAME, group);
175 unsigned int rem = constraints_collection_->removeMessages(q);
176 ROS_DEBUG(
"Removed %u TrajectoryConstraints messages (named '%s')", rem,
name.c_str());