Skip to main content

AccumulateSurfaceCoverage Class

Record which parts of a target surface a tool treats, live, while it treats them. More...

Declaration

class moveit_pro::behaviors::AccumulateSurfaceCoverage { ... }

Included Headers

#include <accumulate_surface_coverage.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...

Private Member Typedefs Index

usingStartSurfaceCoverage = moveit_studio_internal_msgs::srv::StartSurfaceCoverage
usingStopSurfaceCoverage = moveit_studio_internal_msgs::srv::StopSurfaceCoverage

Public Constructors Index

AccumulateSurfaceCoverage (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)

Constructor for the AccumulateSurfaceCoverage Behavior. More...

Private Member Functions Index

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

Opens the session, then waits until the sweep beside it finishes and halts this Behavior. More...

tl::expected< void, std::string >doHalt () override

Ends the session, so a failed sweep stops the sampling as surely as a successful one. More...

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

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

voidcreateClients (const std::string &start_service, const std::string &stop_service)

Private Member Attributes Index

std::shared_future< tl::expected< bool, std::string > >future_

Classes derived from AsyncBehaviorBase must have this shared_future as a class member. More...

rclcpp::Client< StartSurfaceCoverage >::SharedPtrstart_client_
rclcpp::Client< StopSurfaceCoverage >::SharedPtrstop_client_
std::stringstop_service_name_

Kept for the halt's diagnostics, which run after the port that named it is out of reach. More...

std::uint64_tsession_id_ = 0
std::mutexmutex_
std::condition_variablehalt_cv_
boolhalted_ = false
std::optional< int >covered_points_

Public Static Functions Index

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

Description

Record which parts of a target surface a tool treats, live, while it treats them.

Opens a coverage session for as long as this Behavior runs. The Runtime — not this Behavior — samples the tool's actual pose and paints the target points it reaches, publishing the accumulated result so the 3D view fills in as the sweep proceeds. Because the Runtime owns the session, the history outlives the Objective run that started it.

Run it beside the motion in a Parallel, not before it in a Sequence: the session must end whether the sweep succeeds or fails, and a Parallel halts this Behavior either way. It returns Running while the session is open, and Failure if the Runtime was unavailable or refused the session. It has no success status of its own: BT.CPP resets a halted node to Idle in the same call that halts it, so the sweep finishing normally leaves this node Idle, which the tree view draws the same as a cancelled one. Read covered_points to know a session closed, not this status.

 <Control ID="Parallel" success_count="1" failure_count="1">
  <Action ID="ExecuteTrajectory" joint_trajectory_msg="{coverage_trajectory}" />
  <Action ID="AccumulateSurfaceCoverage" target_cloud="{point_cloud}" tool_frame="grasp_link" />
 </Control>

What is recorded is where the tool went, not where it was asked to go — a sweep the controller only partly tracked paints only the part it reached. Transit counts as going: nothing tells the session when treatment is actually on, so keep the Parallel around the treating motion alone and set footprint_range to just past the standoff. A near cutoff on the footprint, or an activation signal from the tool, would close that gap properly.

The tool pose is sampled at the latest transform available, so the painted band trails the true pose by the joint-state and TF publication latency — millimetres at working speeds, and a constant shift rather than a gap.

Data Port NamePort TypeObject Type
target_cloudinputsensor_msgs::msg::PointCloud2
tool_frameinputstd::string
output_frameinputstd::string
footprint_radiusinputdouble
footprint_rangeinputdouble
treated_colorinputstd::vector<int>
sample_rate_hzinputdouble
max_tool_speedinputdouble
covered_pointsoutputint

Definition at line 67 of file accumulate_surface_coverage.hpp.

Private Member Typedefs

StartSurfaceCoverage

using moveit_pro::behaviors::AccumulateSurfaceCoverage::StartSurfaceCoverage = moveit_studio_internal_msgs::srv::StartSurfaceCoverage

Definition at line 85 of file accumulate_surface_coverage.hpp.

StopSurfaceCoverage

using moveit_pro::behaviors::AccumulateSurfaceCoverage::StopSurfaceCoverage = moveit_studio_internal_msgs::srv::StopSurfaceCoverage

Definition at line 86 of file accumulate_surface_coverage.hpp.

Public Constructors

AccumulateSurfaceCoverage()

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

Constructor for the AccumulateSurfaceCoverage Behavior.

Parameters
name

Name of this node instance in the Behavior tree.

config

Node configuration, including the port remappings.

shared_resources

Shared resources the Behavior uses, such as the ROS node, the logger, and the transform buffer.

Declaration at line 77 of file accumulate_surface_coverage.hpp, definition at line 67 of file accumulate_surface_coverage.cpp.

Private Member Functions

createClients()

void moveit_pro::behaviors::AccumulateSurfaceCoverage::createClients (const std::string & start_service, const std::string & stop_service)

Stand the two service clients up once the port-supplied names are known. Not the constructor: the names are ports, so they are not readable until the Behavior ticks.

Declaration at line 111 of file accumulate_surface_coverage.hpp, definition at line 73 of file accumulate_surface_coverage.cpp.

doHalt()

tl::expected< void, std::string > moveit_pro::behaviors::AccumulateSurfaceCoverage::doHalt ()
virtual

Ends the session, so a failed sweep stops the sampling as surely as a successful one.

Returns

An error when the stop did not reach the Runtime, which leaves it sampling.

Declaration at line 98 of file accumulate_surface_coverage.hpp, definition at line 235 of file accumulate_surface_coverage.cpp.

doWork()

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

Opens the session, then waits until the sweep beside it finishes and halts this Behavior.

Returns

True once the session has been closed and the covered count reported.

Declaration at line 92 of file accumulate_surface_coverage.hpp, definition at line 134 of file accumulate_surface_coverage.cpp.

getFuture()

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

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

Definition at line 101 of file accumulate_surface_coverage.hpp.

Private Member Attributes

covered_points_

std::optional<int> moveit_pro::behaviors::AccumulateSurfaceCoverage::covered_points_

Read back from the stop response, so the port reports what the Runtime actually accumulated. Empty when the stop never reported a count: leaving the port untouched is the honest outcome, because a zero there reads as a surface nothing treated.

Definition at line 131 of file accumulate_surface_coverage.hpp.

future_

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

Classes derived from AsyncBehaviorBase must have this shared_future as a class member.

Definition at line 107 of file accumulate_surface_coverage.hpp.

halt_cv_

std::condition_variable moveit_pro::behaviors::AccumulateSurfaceCoverage::halt_cv_

Definition at line 124 of file accumulate_surface_coverage.hpp.

halted_

bool moveit_pro::behaviors::AccumulateSurfaceCoverage::halted_ = false

Set by doHalt() to release doWork() from its wait, and cleared by doWork() so a re-tick starts a fresh session rather than returning the previous one's result immediately.

Definition at line 127 of file accumulate_surface_coverage.hpp.

mutex_

std::mutex moveit_pro::behaviors::AccumulateSurfaceCoverage::mutex_

Guards halted_ and covered_points_, which doHalt() writes from the tick thread while doWork() reads them from the async worker.

Definition at line 123 of file accumulate_surface_coverage.hpp.

session_id_

std::uint64_t moveit_pro::behaviors::AccumulateSurfaceCoverage::session_id_ = 0

The session doWork() opened, named again when stopping it so the Runtime can tell a stale stop from one that belongs to the session it is currently sampling.

Definition at line 119 of file accumulate_surface_coverage.hpp.

start_client_

rclcpp::Client<StartSurfaceCoverage>::SharedPtr moveit_pro::behaviors::AccumulateSurfaceCoverage::start_client_

Definition at line 113 of file accumulate_surface_coverage.hpp.

stop_client_

rclcpp::Client<StopSurfaceCoverage>::SharedPtr moveit_pro::behaviors::AccumulateSurfaceCoverage::stop_client_

Definition at line 114 of file accumulate_surface_coverage.hpp.

stop_service_name_

std::string moveit_pro::behaviors::AccumulateSurfaceCoverage::stop_service_name_

Kept for the halt's diagnostics, which run after the port that named it is out of reach.

Definition at line 116 of file accumulate_surface_coverage.hpp.

Public Static Functions

metadata()

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

Declaration at line 82 of file accumulate_surface_coverage.hpp, definition at line 128 of file accumulate_surface_coverage.cpp.

providedPorts()

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

Declaration at line 80 of file accumulate_surface_coverage.hpp, definition at line 86 of file accumulate_surface_coverage.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.