Abstract base for Behaviors that add a CollisionObject to the planning scene.
More...
|
| virtual tl::expected< moveit_msgs::msg::CollisionObject, std::string > | buildCollisionObject ()=0 |
| | Build the CollisionObject to apply to the planning scene.
|
| |
| tl::expected< bool, std::string > | doWork () override |
| | User-implemented function which handles executing the potentially-long-running process.
|
| |
| 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.
|
| |
| virtual tl::expected< void, std::string > | doHalt () |
| | Optionally implement additional work needed to cleanly interrupt the async process.
|
| |
| void | notifyCanHalt () |
| | Called when runAsync() finishes to notify onHalted() that the async process has finished.
|
| |
Abstract base for Behaviors that add a CollisionObject to the planning scene.
Subclasses override buildCollisionObject() to produce the CollisionObject. The base class then validates the object (non-empty id, non-empty frame_id, equal-size subframe arrays), enforces operation = ADD, and commits the addition.
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, then commits by sending a diff to the /apply_planning_scene service. Service names are hard-coded; they are not exposed as ports. This is the default behavior.
- Supplied scene mode (port wired): the Behavior modifies the
moveit_msgs::PlanningScene message supplied on the port and writes the result back to the same port. No service calls are made.
Before adding the object, the Behavior looks for another entry in the planning scene with the same id. The id can already be present in two places: in the world (world.collision_objects), or attached to the robot (robot_state.attached_collision_objects).
- If a world entry with the same id already exists, the Behavior fails unless
overwrite is true, in which case the existing world entry is replaced.
- If an attached entry with the same id already exists, the Behavior fails regardless of
overwrite, and the caller must detach the object first. This Behavior never modifies the attached list.
| std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::AddCollisionObjectBase::getFuture |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
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.
Implements moveit_pro::behaviors::AsyncBehaviorBase.