Skip to main content

RemoveCollisionObject Class

Removes a collision object from a planning scene by id. More...

Declaration

class moveit_pro::behaviors::RemoveCollisionObject { ... }

Included Headers

#include <remove_collision_object.hpp>

Base class

classAsyncBehaviorBase

A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More...

Public Constructors Index

RemoveCollisionObject (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
RemoveCollisionObject (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< PlanningSceneBridge > bridge)

Public Destructor Index

~RemoveCollisionObject () override=default

Private Member Functions Index

tl::expected< bool, std::string >doWork () override

User-implemented function which handles executing the potentially-long-running process. More...

std::shared_future< tl::expected< bool, std::string > > &getFuture () override

Gets the shared future which is used to monitor the progress of the async process. More...

Private Member Attributes Index

std::unique_ptr< PlanningSceneBridge >bridge_
std::shared_future< tl::expected< bool, std::string > >future_

Public Static Functions Index

static BT::PortsListprovidedPorts ()
static BT::KeyValueVectormetadata ()

Public Static Attributes Index

static constexpr autokPortIDObjectId = "object_id"
static constexpr autokPortIDPlanningScene = "planning_scene"

Description

Removes a collision object from a planning scene by id.

The Behavior has two operating modes selected by the planning_scene input port:

  • Live scene mode (port unwired, default): the Behavior fetches the current planning scene from the /get_planning_scene service, validates that the id is in the world and is not attached, then commits a REMOVE diff via the /apply_planning_scene service. Service names are hard-coded; they are not exposed as ports.
  • Supplied scene mode (port wired): the Behavior reads the moveit_msgs::PlanningScene message supplied on the port, validates the id against that scene, erases the matching entry from world.collision_objects, and writes the modified scene back to the same port. No service calls are made.

Succeeds without changes (no-op) when the id is not present in world.collision_objects: the removal intent is already satisfied. Fails when object_id is empty, or when the id is currently in robot_state.attached_collision_objects. Attached objects must be detached first; the underlying REMOVE operation only affects the world list, so removing an attached id would silently no-op without this check.

Data Port NamePort TypeObject Type
object_idinputstd::string
planning_scenebidirectionalmoveit_msgs::msg::PlanningScene

Definition at line 67 of file remove_collision_object.hpp.

Public Constructors

RemoveCollisionObject()

moveit_pro::behaviors::RemoveCollisionObject::RemoveCollisionObject (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources)
explicit

Declaration at line 73 of file remove_collision_object.hpp, definition at line 83 of file remove_collision_object.cpp.

RemoveCollisionObject()

moveit_pro::behaviors::RemoveCollisionObject::RemoveCollisionObject (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< PlanningSceneBridge > bridge)
explicit

Declaration at line 76 of file remove_collision_object.hpp, definition at line 90 of file remove_collision_object.cpp.

Public Destructor

~RemoveCollisionObject()

moveit_pro::behaviors::RemoveCollisionObject::~RemoveCollisionObject ()
default

Definition at line 80 of file remove_collision_object.hpp.

Private Member Functions

doWork()

tl::expected< bool, std::string > moveit_pro::behaviors::RemoveCollisionObject::doWork ()
virtual

User-implemented function which handles executing the potentially-long-running process.

This function is called within an async process in a separate thread.

Returns

A tl::expected which contains a bool indicating task success if the process completed successfully or was canceled, or an error message if the process failed unexpectedly.

Declaration at line 86 of file remove_collision_object.hpp, definition at line 116 of file remove_collision_object.cpp.

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::RemoveCollisionObject::getFuture ()
inline virtual

Gets the shared future which is used to monitor the progress of the async process.

Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.

This exists to prevent destruction of the derived class while the async process is still in-progress. If the derived class is destroyed, the definitions of the functions used within doWork() will be destroyed too, which will result in the virtual functions in the base class being called instead and cause a fault.

This function will force derived classes to add an instance of this type and return a reference to it. The base class can then use this virtual function to access the shared future in functions like onStart.

By adding this virtual function we're properly demonstrating how this future depends on things from the derived class and the natural flow of object lifetimes will do the hard work for us. The std::shared_future destructor will get the value of the future before the derived class is destructed assuming it's the last reference to the shared state. Doing it this way means neither the base nor derived class should need to implement a destructor which is a nice property to have.

Returns

Returns the shared_future, which should be owned by the child class.

Definition at line 88 of file remove_collision_object.hpp.

Private Member Attributes

bridge_

std::unique_ptr<PlanningSceneBridge> moveit_pro::behaviors::RemoveCollisionObject::bridge_

Definition at line 95 of file remove_collision_object.hpp.

future_

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::RemoveCollisionObject::future_

Definition at line 96 of file remove_collision_object.hpp.

Public Static Functions

metadata()

BT::KeyValueVector moveit_pro::behaviors::RemoveCollisionObject::metadata ()
static

Declaration at line 83 of file remove_collision_object.hpp, definition at line 110 of file remove_collision_object.cpp.

providedPorts()

BT::PortsList moveit_pro::behaviors::RemoveCollisionObject::providedPorts ()
static

Declaration at line 82 of file remove_collision_object.hpp, definition at line 97 of file remove_collision_object.cpp.

Public Static Attributes

kPortIDObjectId

constexpr auto moveit_pro::behaviors::RemoveCollisionObject::kPortIDObjectId = "object_id"
constexpr static

Definition at line 70 of file remove_collision_object.hpp.

kPortIDPlanningScene

constexpr auto moveit_pro::behaviors::RemoveCollisionObject::kPortIDPlanningScene = "planning_scene"
constexpr static

Definition at line 71 of file remove_collision_object.hpp.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.