Attaches a collision object that is already in the planning scene to a robot link. More...
Declaration
class moveit_pro::behaviors::AttachObject { ... }
#include <attach_object.hpp>
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
| AttachObject (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources) |
|
|
|
| AttachObject (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< PlanningSceneBridge > bridge) |
|
|
|
Public Destructor Index
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
Public Static Attributes Index
Description
Attaches a collision object that is already in the planning scene to a robot link.
Works for collision objects in the world. For URDF objects, use AttachURDF instead.
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, then commits an attach diff via the /apply_planning_scene service. The server moves the object from the world to the requested link, reusing the object's existing geometry. 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, moves the matching entry from world.collision_objects into robot_state.attached_collision_objects with the requested link and allowed collision links, and writes the modified scene back to the same port. No service calls are made.
By default the object keeps its current pose relative to the link. Wire the optional relative_transform port to instead attach the object at a chosen transform link_T_object, regardless of where the object currently is. When relative_transform is wired and the id is already attached to link_name, the object is re-posed to the requested transform (and its allowed collision links are refreshed from allowed_collision_links) rather than treated as a no-op.
Succeeds without changes (no-op) when the id is already attached to link_name and no relative_transform is requested: the attachment intent is already satisfied. Fails when object_id or link_name is empty, when the id is absent from the scene, or when the id is attached to a different link.
| Data Port Name | Port Type | Object Type |
|---|
| object_id | input | std::string |
| link_name | input | std::string |
| allowed_collision_links | input | std::vector<std::string> |
| relative_transform | input | geometry_msgs::msg::Transform |
| planning_scene | bidirectional | moveit_msgs::msg::PlanningScene |
Definition at line 100 of file attach_object.hpp.
Public Constructors
AttachObject()
| moveit_pro::behaviors::AttachObject::AttachObject (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources) |
|
explicit
|
AttachObject()
| moveit_pro::behaviors::AttachObject::AttachObject (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< PlanningSceneBridge > bridge) |
|
explicit
|
Public Destructor
~AttachObject()
| moveit_pro::behaviors::AttachObject::~AttachObject () |
|
default
|
Private Member Functions
doWork()
| tl::expected< bool, std::string > moveit_pro::behaviors::AttachObject::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 122 of file attach_object.hpp, definition at line 174 of file attach_object.cpp.
getFuture()
| std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::AttachObject::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 124 of file attach_object.hpp.
Private Member Attributes
bridge_
| std::unique_ptr<PlanningSceneBridge> moveit_pro::behaviors::AttachObject::bridge_ |
|
future_
| std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::AttachObject::future_ |
|
Public Static Functions
metadata()
| BT::KeyValueVector moveit_pro::behaviors::AttachObject::metadata () |
|
static
|
providedPorts()
| BT::PortsList moveit_pro::behaviors::AttachObject::providedPorts () |
|
static
|
Public Static Attributes
kPortIDAllowedCollisionLinks
| constexpr auto moveit_pro::behaviors::AttachObject::kPortIDAllowedCollisionLinks = "allowed_collision_links" |
|
constexpr
static
|
kPortIDLinkName
| constexpr auto moveit_pro::behaviors::AttachObject::kPortIDLinkName = "link_name" |
|
constexpr
static
|
kPortIDObjectId
| constexpr auto moveit_pro::behaviors::AttachObject::kPortIDObjectId = "object_id" |
|
constexpr
static
|
kPortIDPlanningScene
| constexpr auto moveit_pro::behaviors::AttachObject::kPortIDPlanningScene = "planning_scene" |
|
constexpr
static
|
kPortIDRelativeTransform
| constexpr auto moveit_pro::behaviors::AttachObject::kPortIDRelativeTransform = "relative_transform" |
|
constexpr
static
|
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.