Skip to main content

InProcessActionChunkProducer Class

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

Declaration​

class moveit_pro::behaviors::internal::InProcessActionChunkProducer { ... }

Included Headers​

#include <in_process_action_chunk_producer.hpp>

Base class​

classActionChunkProducerInterface

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

Public Member Typedefs Index​

usingPredict = std::function< GetActionChunk::Response(const GetActionChunk::Request &, const moveit_pro_ml::model::RunControl &)>

Answers one request, blocking until the response is ready. A failure is a response with status ERROR. More...

Public Constructors Index​

InProcessActionChunkProducer (Predict predict, std::chrono::duration< double > timeout, PolicyRunGuard::Lease lease={})
InProcessActionChunkProducer (const InProcessActionChunkProducer &)=delete
InProcessActionChunkProducer (InProcessActionChunkProducer &&)=delete

Public Destructor Index​

~InProcessActionChunkProducer () override

Cancels the run and waits for an in-flight call to return. More...

Public Operators Index​

InProcessActionChunkProducer &operator= (const InProcessActionChunkProducer &)=delete
InProcessActionChunkProducer &operator= (InProcessActionChunkProducer &&)=delete

Public Member Functions Index​

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

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

std::optional< InferenceResult >pollActionChunkInference () override

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

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

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

Private Member Attributes Index​

Predictpredict_
PolicyRunGuard::Leaselease_
std::chrono::duration< double >timeout_
moveit_pro_ml::model::RunControlcontrol_
std::future< GetActionChunk::Response >pending_
std::jthreadworker_
boolawaiting_response_ = false
std::chrono::steady_clock::time_pointcall_start_ {}

Description​

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

Each call runs on its own thread, owned by this producer, so the streaming loop keeps its safety checks running while the model computes. Cancellation and timeout ask the model to stop through RunControl and discard any late response. Destruction waits for an in-flight call to return, so halting ExecutePolicy returns once the current pass finishes, and the handle admits its next run only after that.

warning

Not thread-safe except for cancelActionChunkInference(), as ActionChunkProducerInterface documents.

Definition at line 35 of file in_process_action_chunk_producer.hpp.

Public Member Typedefs​

Predict​

using moveit_pro::behaviors::internal::InProcessActionChunkProducer::Predict = std::function<GetActionChunk::Response(const GetActionChunk::Request&, const moveit_pro_ml::model::RunControl&)>

Answers one request, blocking until the response is ready. A failure is a response with status ERROR.

Definition at line 39 of file in_process_action_chunk_producer.hpp.

Public Constructors​

InProcessActionChunkProducer()​

moveit_pro::behaviors::internal::InProcessActionChunkProducer::InProcessActionChunkProducer (Predict predict, std::chrono::duration< double > timeout, PolicyRunGuard::Lease lease={})
Parameters
predict

The policy. Called on a background thread, one call at a time.

timeout

How long one call may run before it is asked to stop and reported as a failure. A call that finished before the owner polls is returned even past this bound.

lease

Keeps the policy handle busy until this producer is destroyed.

Declaration at line 48 of file in_process_action_chunk_producer.hpp, definition at line 59 of file in_process_action_chunk_producer.cpp.

InProcessActionChunkProducer()​

moveit_pro::behaviors::internal::InProcessActionChunkProducer::InProcessActionChunkProducer (const InProcessActionChunkProducer &)
delete

Definition at line 52 of file in_process_action_chunk_producer.hpp.

InProcessActionChunkProducer()​

moveit_pro::behaviors::internal::InProcessActionChunkProducer::InProcessActionChunkProducer (InProcessActionChunkProducer &&)
delete

Definition at line 54 of file in_process_action_chunk_producer.hpp.

Public Destructor​

~InProcessActionChunkProducer()​

moveit_pro::behaviors::internal::InProcessActionChunkProducer::~InProcessActionChunkProducer ()

Cancels the run and waits for an in-flight call to return.

Declaration at line 50 of file in_process_action_chunk_producer.hpp, definition at line 65 of file in_process_action_chunk_producer.cpp.

Public Operators​

operator=()​

InProcessActionChunkProducer & moveit_pro::behaviors::internal::InProcessActionChunkProducer::operator= (const InProcessActionChunkProducer &)
delete

Definition at line 53 of file in_process_action_chunk_producer.hpp.

operator=()​

InProcessActionChunkProducer & moveit_pro::behaviors::internal::InProcessActionChunkProducer::operator= (InProcessActionChunkProducer &&)
delete

Definition at line 55 of file in_process_action_chunk_producer.hpp.

Public Member Functions​

cancelActionChunkInference()​

void moveit_pro::behaviors::internal::InProcessActionChunkProducer::cancelActionChunkInference ()
virtual

Cancel this run and discard any later result.

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

Declaration at line 66 of file in_process_action_chunk_producer.hpp, definition at line 159 of file in_process_action_chunk_producer.cpp.

pollActionChunkInference()​

std::optional< ActionChunkProducerInterface::InferenceResult > moveit_pro::behaviors::internal::InProcessActionChunkProducer::pollActionChunkInference ()
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. 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.

Declaration at line 60 of file in_process_action_chunk_producer.hpp, definition at line 100 of file in_process_action_chunk_producer.cpp.

startActionChunkInference()​

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

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

Declaration at line 58 of file in_process_action_chunk_producer.hpp, definition at line 72 of file in_process_action_chunk_producer.cpp.

warmup()​

tl::expected< void, std::string > moveit_pro::behaviors::internal::InProcessActionChunkProducer::warmup (const GetActionChunk::Request & sample_request)
virtual

Runs one prediction to completion before the run's clock starts, so the first streamed call does not pay the device's first-use cost, and fails when the policy cannot answer the request.

Declaration at line 64 of file in_process_action_chunk_producer.hpp, definition at line 136 of file in_process_action_chunk_producer.cpp.

Private Member Attributes​

awaiting_response_​

bool moveit_pro::behaviors::internal::InProcessActionChunkProducer::awaiting_response_ = false

Definition at line 80 of file in_process_action_chunk_producer.hpp.

call_start_​

std::chrono::steady_clock::time_point moveit_pro::behaviors::internal::InProcessActionChunkProducer::call_start_ {}

Definition at line 81 of file in_process_action_chunk_producer.hpp.

control_​

moveit_pro_ml::model::RunControl moveit_pro::behaviors::internal::InProcessActionChunkProducer::control_

Definition at line 74 of file in_process_action_chunk_producer.hpp.

lease_​

PolicyRunGuard::Lease moveit_pro::behaviors::internal::InProcessActionChunkProducer::lease_

Definition at line 70 of file in_process_action_chunk_producer.hpp.

pending_​

std::future<GetActionChunk::Response> moveit_pro::behaviors::internal::InProcessActionChunkProducer::pending_

Definition at line 78 of file in_process_action_chunk_producer.hpp.

predict_​

Predict moveit_pro::behaviors::internal::InProcessActionChunkProducer::predict_

Definition at line 69 of file in_process_action_chunk_producer.hpp.

timeout_​

std::chrono::duration<double> moveit_pro::behaviors::internal::InProcessActionChunkProducer::timeout_

Definition at line 71 of file in_process_action_chunk_producer.hpp.

worker_​

std::jthread moveit_pro::behaviors::internal::InProcessActionChunkProducer::worker_

Definition at line 79 of file in_process_action_chunk_producer.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.