MoveCollisionObject Class
Updates the reference pose of an existing CollisionObject in the planning scene. More...
Declaration
Included Headers
Base class
| class | AsyncBehaviorBase |
|
A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More... | |
Public Constructors Index
| MoveCollisionObject (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) | |
| MoveCollisionObject (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< PlanningSceneBridge > bridge) | |
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::PortsList | providedPorts () |
| static BT::KeyValueVector | metadata () |
Public Static Attributes Index
| static constexpr auto | kPortIDPlanningScene = "planning_scene" |
Description
Updates the reference pose of an existing CollisionObject in the planning scene.
Replaces the remove-and-re-add workaround for repositioning collision objects. The Behavior emits a CollisionObject::MOVE so all child shapes (primitives, meshes, planes) follow the new reference pose without any per-shape pose updates and without a transient gap in collision checking.
The Behavior has two operating modes selected by the planning_scene input port:
- Live scene mode (port unwired): the Behavior fetches the current planning scene from the /get_planning_scene service to verify the object exists and is not currently attached, then commits a MOVE diff to the /apply_planning_scene service. Service names are hard-coded; they are not exposed as ports. The new pose may be in any frame — the planning scene resolves it via TF.
- Supplied scene mode (port wired): the Behavior locates the existing entry by id in world.collision_objects, updates its pose field in place, and writes the modified scene back to the same port. No service calls are made. The supplied pose must be in the same frame as the existing entry's header.frame_id; the Behavior fails otherwise, because mutating the reference pose without transforming the shape poses would leave the entry self-inconsistent.
Returns FAILURE when object_id is empty, when pose.header.frame_id is empty, when no world entry with the given id exists, when an entry with the same id is currently attached to the robot (MOVE for attached objects is not supported; the caller must detach first), when the supplied scene's matching entry is in a different frame than the input pose, or when a required service call fails in live scene mode.
| Data Port Name | Port Type | Object Type |
|---|---|---|
| object_id | input | std::string |
| pose | input | geometry_msgs::msg::PoseStamped |
| planning_scene | bidirectional | moveit_msgs::msg::PlanningScene |
Definition at line 85 of file move_collision_object.hpp.
Public Constructors
MoveCollisionObject()
| explicit |
Declaration at line 90 of file move_collision_object.hpp, definition at line 88 of file move_collision_object.cpp.
MoveCollisionObject()
| explicit |
Declaration at line 93 of file move_collision_object.hpp, definition at line 95 of file move_collision_object.cpp.
Private Member Functions
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 101 of file move_collision_object.hpp, definition at line 125 of file move_collision_object.cpp.
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 103 of file move_collision_object.hpp.
Private Member Attributes
bridge_
|
Definition at line 110 of file move_collision_object.hpp.
future_
|
Definition at line 111 of file move_collision_object.hpp.
Public Static Functions
metadata()
| static |
Declaration at line 98 of file move_collision_object.hpp, definition at line 120 of file move_collision_object.cpp.
providedPorts()
| static |
Declaration at line 97 of file move_collision_object.hpp, definition at line 102 of file move_collision_object.cpp.
Public Static Attributes
kPortIDPlanningScene
| constexpr static |
Definition at line 88 of file move_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.