Skip to main content

LoadPi05Policy Class

Load a resident pi0.5 policy and publish a process-local handle. More...

Declaration​

class moveit_pro::behaviors::LoadPi05Policy { ... }

Included Headers​

#include <load_pi05_policy.hpp>

Base class​

classAsyncBehaviorBase

A base class for behaviors which need to asynchronously run a function that might take a long time to complete. More...

Public Constructors Index​

LoadPi05Policy (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, internal::Pi05PolicyLoader load={})

Private Member Functions Index​

tl::expected< bool, std::string >doWork () override

User-implemented function which handles executing the potentially-long-running process. More...

std::shared_future< tl::expected< bool, std::string > > &getFuture () override

Gets the shared future which is used to monitor the progress of the async process. More...

Private Member Attributes Index​

internal::Pi05PolicyLoaderload_
PolicyHandlepolicy_
std::stringmanifest_
std::stringpackage_
std::shared_future< tl::expected< bool, std::string > >future_

Public Static Functions Index​

static BT::PortsListprovidedPorts ()
static BT::KeyValueVectormetadata ()

Description​

Load a resident pi0.5 policy and publish a process-local handle.

Loads on the first tick, latches model selection, and republishes the same handle on later ticks. Changing selection fails; stop, edit and relaunch the Objective to select another model. The loader, blackboard and active run share the facade. Model-pool retention can outlive them. Model loading is not preemptible; halting the loader waits for load completion without advancing the tree.

Data Port NamePort TypeObject Type
model_bundle_manifestinputstd::string
model_packageinputstd::string
policyoutputPolicyHandle

Definition at line 42 of file load_pi05_policy.hpp.

Public Constructors​

LoadPi05Policy()​

moveit_pro::behaviors::LoadPi05Policy::LoadPi05Policy (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, internal::Pi05PolicyLoader load={})
Parameters
name

Behavior instance name.

config

Behavior Tree port configuration.

shared_resources

Shared node and diagnostics.

load

Internal loader override for tests; empty uses Pi05::load.

Declaration at line 51 of file load_pi05_policy.hpp, definition at line 66 of file load_pi05_policy.cpp.

Private Member Functions​

doWork()​

tl::expected< bool, std::string > moveit_pro::behaviors::LoadPi05Policy::doWork ()
virtual

User-implemented function which handles executing the potentially-long-running process.

This function is called within an async process in a separate thread.

Returns

A tl::expected which contains a bool indicating task success if the process completed successfully or was canceled, or an error message if the process failed unexpectedly.

Declaration at line 57 of file load_pi05_policy.hpp, definition at line 94 of file load_pi05_policy.cpp.

getFuture()​

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::LoadPi05Policy::getFuture ()
virtual

Gets the shared future which is used to monitor the progress of the async process.

Classes derived from AsyncBehaviorBase must implement getFuture() so that it returns a shared_future class member.

This exists to prevent destruction of the derived class while the async process is still in-progress. If the derived class is destroyed, the definitions of the functions used within doWork() will be destroyed too, which will result in the virtual functions in the base class being called instead and cause a fault.

This function will force derived classes to add an instance of this type and return a reference to it. The base class can then use this virtual function to access the shared future in functions like onStart.

By adding this virtual function we're properly demonstrating how this future depends on things from the derived class and the natural flow of object lifetimes will do the hard work for us. The std::shared_future destructor will get the value of the future before the derived class is destructed assuming it's the last reference to the shared state. Doing it this way means neither the base nor derived class should need to implement a destructor which is a nice property to have.

Returns

Returns the shared_future, which should be owned by the child class.

Declaration at line 58 of file load_pi05_policy.hpp, definition at line 169 of file load_pi05_policy.cpp.

Private Member Attributes​

future_​

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::LoadPi05Policy::future_

Definition at line 64 of file load_pi05_policy.hpp.

load_​

internal::Pi05PolicyLoader moveit_pro::behaviors::LoadPi05Policy::load_

Definition at line 59 of file load_pi05_policy.hpp.

manifest_​

std::string moveit_pro::behaviors::LoadPi05Policy::manifest_

Definition at line 61 of file load_pi05_policy.hpp.

package_​

std::string moveit_pro::behaviors::LoadPi05Policy::package_

Definition at line 62 of file load_pi05_policy.hpp.

policy_​

PolicyHandle moveit_pro::behaviors::LoadPi05Policy::policy_

Definition at line 60 of file load_pi05_policy.hpp.

Public Static Functions​

metadata()​

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

Declaration at line 54 of file load_pi05_policy.hpp, definition at line 86 of file load_pi05_policy.cpp.

providedPorts()​

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

Declaration at line 53 of file load_pi05_policy.hpp, definition at line 73 of file load_pi05_policy.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.