39#include <pybind11/operators.h>
45bool saveGeometryToFile(std::shared_ptr<planning_scene::PlanningScene>&
planning_scene,
46 const std::string& file_path_and_name)
48 std::ofstream file(file_path_and_name);
58bool loadGeometryFromFile(std::shared_ptr<planning_scene::PlanningScene>&
planning_scene,
59 const std::string& file_path_and_name)
61 std::ifstream file(file_path_and_name);
70namespace bind_planning_scene
73 moveit_msgs::msg::CollisionObject& collision_object_msg,
74 std::optional<moveit_msgs::msg::ObjectColor> color_msg)
80 if (color_msg.has_value())
83 planning_scene->setObjectColor(color_msg.value().id, color_msg.value().color);
90 return transformation.matrix();
95 moveit_msgs::msg::PlanningScene planning_scene_msg;
97 return planning_scene_msg;
105#pragma GCC diagnostic push
106#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
107 py::class_<planning_scene::PlanningScene, std::shared_ptr<planning_scene::PlanningScene>>(
planning_scene,
110 Representation of the environment as seen by a planning instance. The environment geometry, the robot geometry and state are maintained.
113 .def(py::init<const moveit::core::RobotModelConstPtr&, const collision_detection::WorldPtr&>(),
114 py::arg("robot_model"), py::arg(
"world") = std::make_shared<collision_detection::World>())
118 str: The name of the planning scene.
122 py::return_value_policy::move,
124 :py:class:`moveit_py.core.RobotModel`: The robot model associated to this planning scene.
128 py::return_value_policy::move,
130 str: The frame in which planning is performed.
135 py::return_value_policy::reference_internal,
137 :py:class:`moveit_py.core.RobotState`: The current state of the robot.
141 py::return_value_policy::move)
146 py::return_value_policy::reference_internal)
156 .def(
"knows_frame_transform",
157 py::overload_cast<const moveit::core::RobotState&, const std::string&>(
159 py::arg(
"robot_state"), py::arg(
"frame_id"),
161 Check if a transform to the frame id is known. This will be known if id is a link name, an attached body id or a collision object.
164 robot_state (:py:class:`moveit_py.core.RobotState`): The robot state to check.
165 frame_id (str): The frame id to check.
168 bool: True if the transform is known, false otherwise.
171 .def("knows_frame_transform",
175 Check if a transform to the frame id is known. This will be known if id is a link name, an attached body id or a collision object.
178 frame_id (str): The frame id to check.
181 bool: True if the transform is known, false otherwise.
186 Get the transform corresponding to the frame id.
187 This will be known if id is a link name, an attached body id or a collision object. Return identity when no transform is available.
190 frame_id (str): The frame id to get the transform for.
193 :py:class:`numpy.ndarray`: The transform corresponding to the frame id.
199 Process a planning scene world message.
202 msg (:py:class:`moveit_msgs.msg.PlanningSceneWorld`): The planning scene world message.
206 py::arg(
"collision_object_msg"), py::arg(
"color_msg") =
nullptr,
208 Apply a collision object to the planning scene.
211 object (moveit_msgs.msg.CollisionObject): The collision object to apply to the planning scene.
212 color (moveit_msgs.msg.ObjectColor, optional): The color of the collision object. Defaults to None if not specified.
216 py::arg(
"color_msg"),
218 Set the color of a collision object.
221 object_id (str): The id of the collision object to set the color of.
222 color (std_msgs.msg.ObjectColor): The color of the collision object.
228 Apply an attached collision object to the planning scene.
231 object (moveit_msgs.msg.AttachedCollisionObject): The attached collision object to apply to the planning scene.
234 .def("process_octomap",
238 Apply an octomap to the planning scene.
241 octomap (moveit_msgs.msg.Octomap): The octomap to apply to the planning scene.
246 Removes collision objects from the planning scene.
247 This method will remove all collision object from the scene except for attached collision objects.
250 .def("set_current_state",
252 py::arg(
"robot_state"),
254 Set the current state using a moveit_msgs::msg::RobotState message.
257 robot_state (moveit_msgs.msg.RobotState): The robot state message to set as current state.
260 .def("set_current_state",
262 py::arg(
"robot_state"),
264 Set the current state using a moveit::core::RobotState object.
267 robot_state (moveit_py.core.RobotState): The robot state object to set as current state.
271 .def(
"is_state_valid",
272 py::overload_cast<const moveit::core::RobotState&, const std::string&, bool>(
274 py::arg(
"robot_state"), py::arg(
"joint_model_group_name"), py::arg(
"verbose") =
false)
275 .def(
"is_state_colliding",
277 py::arg(
"joint_model_group_name"), py::arg(
"verbose") =
false,
279 Check if the robot state is in collision.
282 joint_model_group_name (str): The name of the group to check collision for.
283 verbose (bool): If true, print the link names of the links in collision.
285 bool: True if the robot state is in collision, false otherwise.
288 .def("is_state_colliding",
289 py::overload_cast<const moveit::core::RobotState&, const std::string&, bool>(
291 py::arg(
"robot_state"), py::arg(
"joint_model_group_name"), py::arg(
"verbose") =
false,
293 Check if the robot state is in collision.
296 robot_state (:py:class:`moveit_py.core.RobotState`): The robot state to check collision for.
297 joint_model_group_name (str): The name of the group to check collision for.
298 verbose (bool): If true, print the link names of the links in collision.
300 bool: True if the robot state is in collision, false otherwise.
303 .def("is_state_constrained",
304 py::overload_cast<const moveit::core::RobotState&, const moveit_msgs::msg::Constraints&, bool>(
306 py::arg(
"state"), py::arg(
"constraints"), py::arg(
"verbose") =
false,
308 Check if the robot state fulfills the passed constraints
311 state (moveit_py.core.RobotState): The robot state to check constraints for.
312 constraints (moveit_msgs.msg.Constraints): The constraints to check.
315 bool: true if state is constrained otherwise false.
318 .def("is_path_valid",
321 py::arg(
"trajectory"), py::arg(
"joint_model_group_name"), py::arg(
"verbose") =
false,
322 py::arg(
"invalid_index") =
nullptr,
324 Check if a given path is valid. Each state is checked for validity (collision avoidance and feasibility)
327 trajectory (:py:class:`moveit_py.core.RobotTrajectory`): The trajectory to check.
328 joint_model_group_name (str): The joint model group to check the path against.
330 invalid_index (list):
333 bool: true if the path is valid otherwise false.
338 .def(
"check_collision",
339 py::overload_cast<const collision_detection::CollisionRequest&, collision_detection::CollisionResult&>(
341 py::arg(
"collision_request"), py::arg(
"collision_result"),
343 Check whether the current state is in collision, and if needed, updates the collision transforms of the current state before the computation.
346 collision_request (:py:class:`moveit_py.core.CollisionRequest`): The collision request to use.
347 collision_result (:py:class:`moveit_py.core.CollisionResult`): The collision result to update
350 bool: true if state is in collision otherwise false.
353 .def("check_collision",
356 py::arg(
"collision_request"), py::arg(
"collision_result"), py::arg(
"state"),
358 Check if the robot state is in collision.
361 collision_request ():
366 bool: true if state is in collision otherwise false.
369 .def("check_collision",
373 py::arg(
"collision_request"), py::arg(
"collision_result"), py::arg(
"state"), py::arg(
"acm"),
375 Check if the robot state is in collision.
378 collision_request ():
384 bool: true if state is in collision otherwise false.
387 .def(
"check_collision_unpadded",
388 py::overload_cast<const collision_detection::CollisionRequest&, collision_detection::CollisionResult&>(
390 py::arg(
"req"), py::arg(
"result"),
392 Check if the robot state is in collision.
395 collision_request ():
399 bool: true if state is in collision otherwise false.
402 .def(
"check_collision_unpadded",
406 py::arg(
"collision_request"), py::arg(
"collision_result"), py::arg(
"state"),
408 Check if the robot state is in collision.
411 collision_request ():
416 bool: true if state is in collision otherwise false.
419 .def(
"check_collision_unpadded",
423 py::arg(
"collision_request"), py::arg(
"collision_result"), py::arg(
"state"), py::arg(
"acm"),
425 Check if the robot state is in collision.
428 collision_request ():
434 bool: true if state is in collision otherwise false.
436 .def("check_self_collision",
437 py::overload_cast<const collision_detection::CollisionRequest&, collision_detection::CollisionResult&>(
439 py::arg(
"collision_request"), py::arg(
"collision_result"),
441 Check if the robot state is in collision.
444 collision_request ():
448 bool: true if state is in collision otherwise false.
451 .def("check_self_collision",
454 py::arg(
"collision_request"), py::arg(
"collision_result"), py::arg(
"state"),
456 Check if the robot state is in collision.
459 collision request ():
464 bool: true if state is in self collision otherwise false.
467 .def("check_self_collision",
471 py::arg(
"collision_request"), py::arg(
"collision_result"), py::arg(
"state"), py::arg(
"acm"),
473 Check if the robot state is in collision.
476 collision request ():
482 bool: true if state is in self collision otherwise false.
485 .def("save_geometry_to_file", &saveGeometryToFile, py::arg(
"file_path_and_name"),
487 Save the CollisionObjects in the PlanningScene to a file
490 file_path_and_name (str): The file to save the CollisionObjects to.
493 bool: true if save to file was successful otherwise false.
496 .def("load_geometry_from_file", &loadGeometryFromFile, py::arg(
"file_path_and_name"),
498 Load the CollisionObjects from a file to the PlanningScene
501 file_path_and_name (str): The file to load the CollisionObjects from.
504 bool: true if load from file was successful otherwise false.
506#pragma GCC diagnostic pop
Definition of a structure for the allowed collision matrix. All elements in the collision world are r...
Representation of a robot's state. This includes position, velocity, acceleration and effort.
This class maintains the representation of the environment as seen by a planning instance....
void setName(const std::string &name)
Set the name of the planning scene.
void setAllowedCollisionMatrix(const collision_detection::AllowedCollisionMatrix &acm)
Set the allowed collision matrix.
const moveit::core::RobotModelConstPtr & getRobotModel() const
Get the kinematic model for which the planning scene is maintained.
static PlanningScenePtr clone(const PlanningSceneConstPtr &scene)
Clone a planning scene. Even if the scene scene depends on a parent, the cloned scene will not.
void setCurrentState(const moveit_msgs::msg::RobotState &state)
Set the current robot state to be state. If not all joint values are specified, the previously mainta...
bool isPathValid(const moveit_msgs::msg::RobotState &start_state, const moveit_msgs::msg::RobotTrajectory &trajectory, const std::string &group="", bool verbose=false, std::vector< std::size_t > *invalid_index=nullptr) const
Check if a given path is valid. Each state is checked for validity (collision avoidance and feasibili...
void checkCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res)
Check whether the current state is in collision, and if needed, updates the collision transforms of t...
bool knowsFrameTransform(const std::string &id) const
Check if a transform to the frame id is known. This will be known if id is a link name,...
bool isStateValid(const moveit_msgs::msg::RobotState &state, const std::string &group="", bool verbose=false) const
Check if a given state is valid. This means checking for collisions and feasibility....
void checkCollisionUnpadded(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res)
Check whether the current state is in collision, but use a collision_detection::CollisionRobot instan...
void processOctomapMsg(const octomap_msgs::msg::OctomapWithPose &map)
bool processAttachedCollisionObjectMsg(const moveit_msgs::msg::AttachedCollisionObject &object)
const moveit::core::RobotState & getCurrentState() const
Get the state at which the robot is assumed to be.
bool processPlanningSceneWorldMsg(const moveit_msgs::msg::PlanningSceneWorld &world)
void setObjectColor(const std::string &id, const std_msgs::msg::ColorRGBA &color)
const std::string & getPlanningFrame() const
Get the frame in which planning is performed.
const moveit::core::Transforms & getTransforms() const
Get the set of fixed transforms from known frames to the planning frame.
void removeAllCollisionObjects()
Clear all collision objects in planning scene.
const std::string & getName() const
Get the name of the planning scene. This is empty by default.
bool isStateColliding(const std::string &group="", bool verbose=false)
Check if the current state is in collision (with the environment or self collision)....
bool isStateConstrained(const moveit_msgs::msg::RobotState &state, const moveit_msgs::msg::Constraints &constr, bool verbose=false) const
Check if a given state satisfies a set of constraints.
void checkSelfCollision(const collision_detection::CollisionRequest &req, collision_detection::CollisionResult &res)
Check whether the current state is in self collision.
const collision_detection::AllowedCollisionMatrix & getAllowedCollisionMatrix() const
Get the allowed collision matrix.
Maintain a sequence of waypoints and the time durations between these waypoints.
void initPlanningScene(py::module &m)
Eigen::MatrixXd getFrameTransform(std::shared_ptr< planning_scene::PlanningScene > &planning_scene, const std::string &id)
moveit_msgs::msg::PlanningScene getPlanningSceneMsg(std::shared_ptr< planning_scene::PlanningScene > &planning_scene)
void applyCollisionObject(std::shared_ptr< planning_scene::PlanningScene > &planning_scene, moveit_msgs::msg::CollisionObject &collision_object_msg, std::optional< moveit_msgs::msg::ObjectColor > color_msg)
This namespace includes the central class for representing planning contexts.
Representation of a collision checking request.
Representation of a collision checking result.