MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_pro::behaviors::ExecutePolicy Class Reference

Executes a policy as continuous, collision-checked motion on the arm and optional gripper. More...

#include <execute_policy.hpp>

Inheritance diagram for moveit_pro::behaviors::ExecutePolicy:
Collaboration diagram for moveit_pro::behaviors::ExecutePolicy:

Classes

struct  Deps
 
struct  SceneAndState
 

Public Types

using JTACClientInterface = jtac_client::JTACClientInterface
 
using GripperClientInterface = gripper_client::GripperClientInterface
 
using TrajectoryChunkValidator = chunked_trajectory_executor::TrajectoryChunkValidator
 

Public Member Functions

 ExecutePolicy (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, Deps deps={})
 Constructor for the ExecutePolicy Behavior.
 
virtual tl::expected< SceneAndState, std::string > acquireSceneAndInitialState (const std::vector< std::string > &joint_names, double link_padding)
 Start monitoring the planning scene for the run and read the commanded joints' current positions.
 
- Public Member Functions inherited from moveit_pro::behaviors::AsyncBehaviorBase
 AsyncBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)
 
 ~AsyncBehaviorBase () override=default
 
BT::NodeStatus onStart () override
 Required implementation of BT::StatefulActionNode::onStart().
 
BT::NodeStatus onRunning () override
 Required implementation of BT::StatefulActionNode::onRunning().
 
void onHalted () override
 Required implementation of BT::StatefulActionNode::onHalted().
 
void resetStatus ()
 Resets the internal status of this node.
 
void notifyCanHalt ()
 Called when runAsync() finishes to notify onHalted() that the async process has finished.
 
- Public Member Functions inherited from moveit_pro::behaviors::SharedResourcesNode< BT::StatefulActionNode >
 SharedResourcesNode (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &behavior_context)
 Constructor for SharedResourcesNode. Called by BT::BehaviorTreeFactory when creating a new behavior tree containing this node.
 
const std::shared_ptr< BehaviorContext > & getBehaviorContext () const
 

Static Public Member Functions

static BT::PortsList providedPorts ()
 Input ports that configure the chunk execution.
 
static BT::KeyValueVector metadata ()
 Metadata for the MoveIt Pro Developer Tool.
 

Detailed Description

Executes a policy as continuous, collision-checked motion on the arm and optional gripper.

The Behavior gathers the current observation (joint positions and camera images), asks a policy for the next chunk over the GetActionChunk service, and feeds it to a ChunkedTrajectoryExecutor that blends it onto the running motion at the seam, checks it against the commanded joints' position, velocity, and acceleration limits and for collision of the robot with itself and with the world, and stitches it onto the controller. It requests the next chunk before the committed motion drains so the robot does not pause at chunk boundaries, and stops cleanly once total_action_steps points have run, when the policy reports no more actions, or when the Behavior is halted.

The collision checks read a planning scene that is monitored for the whole run and honor its AllowedCollisionMatrix. The matrix and the set of attached objects are read once at run start and not refreshed, so any contact the task means to make, such as a grasp or a place, must be allowed with a collision rule before this Behavior starts. Motion already sent to the controller but not yet executed is re-validated against the current scene when a world-geometry update arrives, and again each time the Behavior requests the next chunk from the policy; a violation cancels the controller goals, the controller decelerates to rest, and the Behavior fails, reporting the contact.

The policy is any node that serves the GetActionChunk ROS 2 service (moveit_pro_ml_msgs/srv/GetActionChunk); the serving node can wrap an in-process model adapter, a local GPU server, or a remote one. Every chunk is blended onto the running motion at the seam regardless of the policy; the seam blend is never delegated to the producer. When the policy runs real-time chunking (policy_uses_real_time_chunking), the Behavior additionally sends it the previous chunk's unexecuted tail and the state that chunk was anchored to, so it continues the committed motion and the blend has less to correct.

The arm and the gripper are driven on separate paths from the same chunk. The arm joints are streamed to the trajectory controller; the gripper, when one is configured, is the joint named by gripper_joint_name, which the chunk must carry as its one joint beyond the arm group (only single-DOF grippers are supported), and is commanded through the GripperCommand action server named by gripper_command_action_name, streamed step by step across each committed chunk so it tracks the policy's gripper motion rather than holding one value per chunk. The two gripper ports are set together or both left empty. With a gripper configured, the joint's sensed position is appended to the robot state sent to the policy after the arm group's joints, so the policy observes the gripper it commands; the executor and the controller still command the arm joints only. Leaving both ports empty runs the arm only and leaves the gripper to a separate Behavior. Each gripper target is checked for finiteness and clamped to the gripper joint's position limits. The gripper's links are part of the collision check at the pose the monitored scene currently reports, so the gripper geometry is considered, but the commanded gripper opening itself is not re-validated per step the way the arm chunk is. A halt cancels both the arm controller goals and any in-flight gripper goal; a position controller may still hold its last gripper setpoint after a cancel, so a halt is not guaranteed to reopen the gripper.

Data Port Name Port Type Object Type
policy_service_name input std::string
joint_group_name input std::string
total_action_steps input int
prompt input std::string
committed_action_steps input int
dt input double
num_interpolation_points input int
link_padding input double
goal_path_tolerance input double
policy_tracking_weight input double
policy_uses_real_time_chunking input bool
guidance_horizon input int
controller_action_name input std::string
absolute_force_torque_threshold input std::vector<double>
policy_call_timeout input double
image_names input std::vector<std::string>
image_topics input std::vector<std::string>
joint_states_topic input std::string
gripper_command_action_name input std::string
gripper_joint_name input std::string

Member Typedef Documentation

◆ GripperClientInterface

using moveit_pro::behaviors::ExecutePolicy::GripperClientInterface = gripper_client::GripperClientInterface

◆ JTACClientInterface

◆ TrajectoryChunkValidator

using moveit_pro::behaviors::ExecutePolicy::TrajectoryChunkValidator = chunked_trajectory_executor::TrajectoryChunkValidator

Constructor & Destructor Documentation

◆ ExecutePolicy()

moveit_pro::behaviors::ExecutePolicy::ExecutePolicy ( const std::string &  name,
const BT::NodeConfiguration &  config,
const std::shared_ptr< BehaviorContext > &  shared_resources,
Deps  deps = {} 
)

Constructor for the ExecutePolicy Behavior.

Parameters
nameBehavior instance name, set by the behavior tree factory.
configBehavior tree configuration, set by the behavior tree factory.
shared_resourcesResources shared between Behaviors, such as the node and the robot model.
depsInjected collaborators for testing. Each null entry is built from the ports at run start: the producer as a GetActionChunk service client, the jtac_client as a default JTACClient, the validator as a collision validator reading the live monitored planning scene, the observation_source as a topic subscriber, and the gripper_client as a GripperClient created only when gripper_command_action_name is set.

Member Function Documentation

◆ acquireSceneAndInitialState()

tl::expected< ExecutePolicy::SceneAndState, std::string > moveit_pro::behaviors::ExecutePolicy::acquireSceneAndInitialState ( const std::vector< std::string > &  joint_names,
double  link_padding 
)
virtual

Start monitoring the planning scene for the run and read the commanded joints' current positions.

Production starts a PlanningSceneMonitor that stays alive for the whole run, so the collision checks follow the world as it changes. Tests override this to supply canned initial positions with no live scene (and inject their own validator).

Parameters
joint_namesCommanded joints, defining the order of initial_joint_positions.
link_paddingPadding in meters added to the robot's collision geometry in the monitored scene. The validator applies it when checking the robot against the world, but not when checking the robot against itself.
Returns
The running scene monitor and the initial positions, or an error if the scene could not be fetched.

◆ metadata()

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

Metadata for the MoveIt Pro Developer Tool.

Returns
The Behavior metadata.

◆ providedPorts()

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

Input ports that configure the chunk execution.

Returns
The list of ports.

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