Skip to main content

ActionChunkProducerInterface Class

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

Declaration​

class moveit_pro::behaviors::ActionChunkProducerInterface { ... }

Included Headers​

#include <policy.hpp>

Derived Classes​

classInProcessActionChunkProducer

Runs a policy that answers in process, without blocking the streaming loop. More...

Public Member Typedefs Index​

usingGetActionChunk = moveit_pro_ml_msgs::srv::GetActionChunk
usingInferenceResult = tl::expected< GetActionChunk::Response, std::string >

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

Public Destructor Index​

~ActionChunkProducerInterface ()=default

Public Member Functions Index​

voidcancelActionChunkInference ()=0

Cancel this run and discard any later result. More...

tl::expected< void, std::string >startActionChunkInference (const GetActionChunk::Request &request)=0

Begin one inference without waiting for it. More...

std::optional< InferenceResult >pollActionChunkInference ()=0

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

tl::expected< void, std::string >warmup (const GetActionChunk::Request &)

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

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; a completed call's response carries its own status, which distinguishes a produced chunk from the policy's graceful end of the run and from a reported error.

warning

Not thread-safe: startActionChunkInference() and pollActionChunkInference() share state, so one thread must own the whole start/poll cycle. Cancellation may be called from another thread.

Definition at line 102 of file policy.hpp.

Public Member Typedefs​

GetActionChunk​

using moveit_pro::behaviors::ActionChunkProducerInterface::GetActionChunk = moveit_pro_ml_msgs::srv::GetActionChunk

Definition at line 105 of file policy.hpp.

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.

Definition at line 107 of file policy.hpp.

Public Destructor​

~ActionChunkProducerInterface()​

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

Definition at line 109 of file policy.hpp.

Public Member Functions​

cancelActionChunkInference()​

virtual void moveit_pro::behaviors::ActionChunkProducerInterface::cancelActionChunkInference ()

Cancel this run and discard any later result.

Must be thread-safe and nonblocking; a halt calls it from another thread.

Definition at line 115 of file policy.hpp.

pollActionChunkInference()​

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

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. A result that is ready when polled is returned even if the call timeout has passed, so a loop busy with other checks does not lose a completed chunk.

Definition at line 133 of file policy.hpp.

startActionChunkInference()​

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

Begin one inference without waiting for it.

Parameters
request

The 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().

Definition at line 124 of file policy.hpp.

warmup()​

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

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). The response's chunk is discarded, but its status is not: a producer must return an error when the policy answers with anything other than a produced chunk or the graceful end of the run, so a policy that is unreachable, still loading, or misconfigured fails the run before the trajectory clock starts. The default does nothing, for a producer with no cold cost to pay.

Parameters
sample_request

A representative first-inference request used only to drive the round-trip.

Returns

An error if the policy cannot be reached or answers with a failing status, otherwise success.

Definition at line 151 of file policy.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.