Skip to main content

BehaviorContext Struct

The BehaviorContext struct contains shared resources that are common between all instances of Behaviors that inherit from moveit_pro::behaviors::SharedResourcesNode. More...

Declaration​

struct moveit_pro::behaviors::BehaviorContext { ... }

Included Headers​

#include <behavior_context.hpp>

Public Constructors Index​

BehaviorContext (const std::shared_ptr< rclcpp::Node > &node_in, bool tf2_spin_thread=true, bool load_robot_model=false, std::size_t mtc_introspection_retained_tasks=kMtcIntrospectionRetainedTaskLimit, MotionApprovalSwitch::SteadyNowFn motion_approval_now={})
BehaviorContext (const std::shared_ptr< rclcpp::Node > &node_in, std::unique_ptr< moveit_pro::behavior::LoggerBase > logger, bool tf2_spin_thread=true, bool load_robot_model=false, std::size_t mtc_introspection_retained_tasks=kMtcIntrospectionRetainedTaskLimit, MotionApprovalSwitch::SteadyNowFn motion_approval_now={})
BehaviorContext (const BehaviorContext &)=delete
BehaviorContext (BehaviorContext &&)=delete

Public Operators Index​

BehaviorContext &operator= (const BehaviorContext &)=delete
BehaviorContext &operator= (BehaviorContext &&)=delete

Public Member Functions Index​

std::stringgetModelFrameOrDefault () const

The robot model's root frame, or "world" when no robot model was loaded. More...

Public Member Attributes Index​

const std::shared_ptr< rclcpp::Node >node

A const shared pointer to a RCLCPP Node. This points to an instance of a Node provided when constructing the BehaviorContext. More...

const std::shared_ptr< rclcpp::CallbackGroup >callback_group_mutually_exclusive

A const shared pointer mutually-exclusive callback group. More...

const std::shared_ptr< rclcpp::CallbackGroup >reentrant_callback_group

A const shared pointer reentrant callback group. More...

const std::unique_ptr< moveit_pro::behavior::LoggerBase >logger

A const unique pointer to a logger for reporting messages to the UI. More...

std::shared_ptr< tf2_ros::Buffer >transform_buffer_ptr

Transform buffer, listener, and broadcaster to interface with TF. More...

std::shared_ptr< tf2_ros::TransformListener >transform_listener_ptr
std::shared_ptr< tf2_ros::TransformBroadcaster >transform_broadcaster_ptr
std::shared_ptr< moveit_pro::base::RobotModel >robot_model

The robot model, may be nullptr if the BehaviorContext was created with load_robot_model=false. More...

PersistentPublisherCachepersistent_publishers

Cache of publishers (e.g. UI point-cloud snapshots) whose latched samples must outlive the Behavior instance that published them, so a UI that reconnects or reloads after the Objective still receives them. More...

BoundedRetentionQueuemtc_introspection_retention

Bounds MTC introspection memory across the process: only the most recently planned MTC tasks keep their introspection data (solutions, failures, and per-candidate planning scenes); older tasks' data is released when a newer task is retained. Without this bound, every MTC planning Subtree's task retains that data until the Objective is unloaded, so Objectives with many planning Subtrees grow memory without limit (issue #22024). PlanMTCTask registers each introspection-enabled task here after planning. The limit is the mtc_introspection_retained_tasks constructor argument (default kMtcIntrospectionRetainedTaskLimit), which the objective server reads from the robot config's objectives.mtc_introspection_retained_tasks key. More...

const std::unique_ptr< internal::MotionApproval >motion_approval

The motion approval gate's process-wide state: whether an app is asking, where an operator's answer arrives, and the ROS entities feeding both. More...

Description​

The BehaviorContext struct contains shared resources that are common between all instances of Behaviors that inherit from moveit_pro::behaviors::SharedResourcesNode.

The BehaviorContext struct won't load a robot model by default. This is to avoid the cost of loading the robot model when it's not actually needed (e.g. tests), or needing to consume a timeout waiting for the model to be available. If a robot model is needed (e.g. when running on an actual robot), set load_robot_model=true when constructing the BehaviorContext. If load_robot_model=true and the robot model fails to load, the BehaviorContext will throw an exception and the program will terminate.

Definition at line 101 of file behavior_context.hpp.

Public Constructors​

BehaviorContext()​

moveit_pro::behaviors::BehaviorContext::BehaviorContext (const std::shared_ptr< rclcpp::Node > & node_in, bool tf2_spin_thread=true, bool load_robot_model=false, std::size_t mtc_introspection_retained_tasks=kMtcIntrospectionRetainedTaskLimit, MotionApprovalSwitch::SteadyNowFn motion_approval_now={})
explicit

Declaration at line 107 of file behavior_context.hpp, definition at line 34 of file behavior_context.cpp.

BehaviorContext()​

moveit_pro::behaviors::BehaviorContext::BehaviorContext (const std::shared_ptr< rclcpp::Node > & node_in, std::unique_ptr< moveit_pro::behavior::LoggerBase > logger, bool tf2_spin_thread=true, bool load_robot_model=false, std::size_t mtc_introspection_retained_tasks=kMtcIntrospectionRetainedTaskLimit, MotionApprovalSwitch::SteadyNowFn motion_approval_now={})

Declaration at line 112 of file behavior_context.hpp, definition at line 46 of file behavior_context.cpp.

BehaviorContext()​

moveit_pro::behaviors::BehaviorContext::BehaviorContext (const BehaviorContext &)
delete

Definition at line 118 of file behavior_context.hpp.

BehaviorContext()​

moveit_pro::behaviors::BehaviorContext::BehaviorContext (BehaviorContext &&)
delete

Definition at line 120 of file behavior_context.hpp.

Public Operators​

operator=()​

BehaviorContext & moveit_pro::behaviors::BehaviorContext::operator= (const BehaviorContext &)
delete

Definition at line 122 of file behavior_context.hpp.

operator=()​

BehaviorContext & moveit_pro::behaviors::BehaviorContext::operator= (BehaviorContext &&)
delete

Definition at line 124 of file behavior_context.hpp.

Public Member Functions​

getModelFrameOrDefault()​

std::string moveit_pro::behaviors::BehaviorContext::getModelFrameOrDefault ()

The robot model's root frame, or "world" when no robot model was loaded.

Behaviors default their visualization and IK frames to this so they stay correct on robots whose model is not rooted at "world" (e.g. mobile bases rooted at "odom").

Declaration at line 169 of file behavior_context.hpp, definition at line 76 of file behavior_context.cpp.

Public Member Attributes​

callback_group_mutually_exclusive​

const std::shared_ptr<rclcpp::CallbackGroup> moveit_pro::behaviors::BehaviorContext::callback_group_mutually_exclusive

A const shared pointer mutually-exclusive callback group.

Marked const to prevent Behaviors that can access BehaviorContext from changing it.

Definition at line 137 of file behavior_context.hpp.

logger​

const std::unique_ptr<moveit_pro::behavior::LoggerBase> moveit_pro::behaviors::BehaviorContext::logger

A const unique pointer to a logger for reporting messages to the UI.

Marked const to prevent Behaviors that can access BehaviorContext from changing it.

Definition at line 149 of file behavior_context.hpp.

motion_approval​

const std::unique_ptr<internal::MotionApproval> moveit_pro::behaviors::BehaviorContext::motion_approval

The motion approval gate's process-wide state: whether an app is asking, where an operator's answer arrives, and the ROS entities feeding both.

One subscription and one service per process rather than per tree. A per-tree subscription would start empty and could still be waiting for its first message when a Behavior needs an answer, and a service advertised only once a motion waits has to clear discovery before the operator's first click can land. The type is internal, so it carries no compatibility guarantee and can change without a deprecation.

warning

Inject a clock through this context's constructor rather than replacing this member: the subscription inside it is bound to the switch inside it, so a replacement would be fed by nothing.

Definition at line 203 of file behavior_context.hpp.

mtc_introspection_retention​

BoundedRetentionQueue moveit_pro::behaviors::BehaviorContext::mtc_introspection_retention

Bounds MTC introspection memory across the process: only the most recently planned MTC tasks keep their introspection data (solutions, failures, and per-candidate planning scenes); older tasks' data is released when a newer task is retained. Without this bound, every MTC planning Subtree's task retains that data until the Objective is unloaded, so Objectives with many planning Subtrees grow memory without limit (issue #22024). PlanMTCTask registers each introspection-enabled task here after planning. The limit is the mtc_introspection_retained_tasks constructor argument (default kMtcIntrospectionRetainedTaskLimit), which the objective server reads from the robot config's objectives.mtc_introspection_retained_tasks key.

warning

Release callbacks run on whichever thread's retain() call evicted the entry, so a retained task's data can be released from a thread other than the one that planned it. retain() is a synchronization point (see BoundedRetentionQueue): a Behavior must retain a task (via mtc_utils::retainTaskIntrospection) before planning it or reading its retained data, after which no release of that task can run until the queue's full capacity of newer tasks is retained — the only residual race is that many retains completing while the use is still in progress.

Definition at line 191 of file behavior_context.hpp.

node​

const std::shared_ptr<rclcpp::Node> moveit_pro::behaviors::BehaviorContext::node

A const shared pointer to a RCLCPP Node. This points to an instance of a Node provided when constructing the BehaviorContext.

Marked const to prevent Behaviors that can access BehaviorContext from changing it.

Definition at line 131 of file behavior_context.hpp.

persistent_publishers​

PersistentPublisherCache moveit_pro::behaviors::BehaviorContext::persistent_publishers

Cache of publishers (e.g. UI point-cloud snapshots) whose latched samples must outlive the Behavior instance that published them, so a UI that reconnects or reloads after the Objective still receives them.

Definition at line 175 of file behavior_context.hpp.

reentrant_callback_group​

const std::shared_ptr<rclcpp::CallbackGroup> moveit_pro::behaviors::BehaviorContext::reentrant_callback_group

A const shared pointer reentrant callback group.

Marked const to prevent Behaviors that can access BehaviorContext from changing it.

Definition at line 143 of file behavior_context.hpp.

robot_model​

std::shared_ptr<moveit_pro::base::RobotModel> moveit_pro::behaviors::BehaviorContext::robot_model

The robot model, may be nullptr if the BehaviorContext was created with load_robot_model=false.

if load_robot_model=true, this is guaranteed to be a valid pointer.

Definition at line 162 of file behavior_context.hpp.

transform_broadcaster_ptr​

std::shared_ptr<tf2_ros::TransformBroadcaster> moveit_pro::behaviors::BehaviorContext::transform_broadcaster_ptr

Definition at line 156 of file behavior_context.hpp.

transform_buffer_ptr​

std::shared_ptr<tf2_ros::Buffer> moveit_pro::behaviors::BehaviorContext::transform_buffer_ptr

Transform buffer, listener, and broadcaster to interface with TF.

Definition at line 154 of file behavior_context.hpp.

transform_listener_ptr​

std::shared_ptr<tf2_ros::TransformListener> moveit_pro::behaviors::BehaviorContext::transform_listener_ptr

Definition at line 155 of file behavior_context.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.