MoveIt Pro API
Core Behaviors for MoveIt Pro
Loading...
Searching...
No Matches
moveit_pro::behaviors::ActionChunkProducerInterface Class Referenceabstract

Runs one inference of a policy that produces trajectory chunks. More...

#include <execute_policy.hpp>

Public Types

using GetActionChunk = moveit_pro_ml_msgs::srv::GetActionChunk
 
using InferenceResult = tl::expected< GetActionChunk::Response, std::string >
 Outcome of one inference: the policy response, or an error if the call could not complete.
 

Public Member Functions

virtual ~ActionChunkProducerInterface ()=default
 
virtual tl::expected< void, std::string > startActionChunkInference (const GetActionChunk::Request &request)=0
 Begin one inference without waiting for it.
 
virtual std::optional< InferenceResultpollActionChunkInference ()=0
 Check the inference begun by startActionChunkInference() for a result.
 
virtual tl::expected< void, std::string > warmup (const GetActionChunk::Request &)
 Exercise the full policy round-trip once before the run's clock starts.
 

Detailed Description

Runs one inference of a policy that produces trajectory chunks.

Hidden behind an interface so the production service client and a test double share one seam. The caller fills the request observation and real-time-chunking carryover, starts the inference, and polls for the result, so it can keep streaming and re-checking motion while the policy computes. One inference is in flight at a time. A failed result means the call itself could not complete, which is distinct from a successful call whose response reports the policy has no more actions.

Warning
Not thread-safe: startActionChunkInference() and pollActionChunkInference() share state, so one thread must own the whole start/poll cycle.

Member Typedef Documentation

◆ GetActionChunk

◆ InferenceResult

using moveit_pro::behaviors::ActionChunkProducerInterface::InferenceResult = tl::expected<GetActionChunk::Response, std::string>

Outcome of one inference: the policy response, or an error if the call could not complete.

Constructor & Destructor Documentation

◆ ~ActionChunkProducerInterface()

virtual moveit_pro::behaviors::ActionChunkProducerInterface::~ActionChunkProducerInterface ( )
virtualdefault

Member Function Documentation

◆ pollActionChunkInference()

virtual std::optional< InferenceResult > moveit_pro::behaviors::ActionChunkProducerInterface::pollActionChunkInference ( )
pure virtual

Check the inference begun by startActionChunkInference() for a result.

Returns
std::nullopt while the inference is still running; otherwise its result, which also ends the in-flight state. Polling with no inference in flight returns an error result.

◆ startActionChunkInference()

virtual tl::expected< void, std::string > moveit_pro::behaviors::ActionChunkProducerInterface::startActionChunkInference ( const GetActionChunk::Request &  request)
pure virtual

Begin one inference without waiting for it.

Parameters
requestThe observation and real-time-chunking carryover for this step.
Returns
An error if the request could not be sent or an inference is already in flight, otherwise success. The result is collected with pollActionChunkInference().

◆ warmup()

virtual tl::expected< void, std::string > moveit_pro::behaviors::ActionChunkProducerInterface::warmup ( const GetActionChunk::Request &  )
inlinevirtual

Exercise the full policy round-trip once before the run's clock starts.

Sends one throwaway inference so the first streamed inference on the run timeline does not pay the cold cost of establishing the request/response path (service discovery and the transport's first-message endpoint matching, which is seconds on a fresh connection). Paid on the timeline, that cost stalls the first chunk so it lands in the controller's past with nothing to stitch, and inflates the latency estimate that places every later seam. The request is shaped like a first inference (new_episode set) and its response is discarded. The default does nothing, which suits an in-process producer with no transport to warm.

Parameters
sample_requestA representative first-inference request used only to drive the round-trip.
Returns
An error if the policy cannot be reached, otherwise success.

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