Skip to main content

MPCBehaviorBase Class

All non-template implementation for the templated MPCBehaviorBase class. More...

Declaration

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

Included Headers

#include <mpc_behavior_base.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...

Derived Classes

classMPCBehaviorBase<IMPL>

A base class for behaviors to help set up and execute MPC. More...

classMPCBehaviorBase<IMPL>

A base class for behaviors to help set up and execute MPC. More...

classMPCBehaviorBase<IMPL>

A base class for behaviors to help set up and execute MPC. More...

classMPCBehaviorBase<IMPL>

A base class for behaviors to help set up and execute MPC. More...

Public Constructors Index

MPCBehaviorBase (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< moveit_pro::behaviors::BehaviorContext > &shared_resources, const std::function< tl::expected< void, std::string >(const BT::TreeNode &)> &set_residual_ports)

Public Destructor Index

~MPCBehaviorBase () override

Public Member Functions Index

tl::expected< void, std::string >doHalt () override

Optionally implement additional work needed to cleanly interrupt the async process. More...

BT::NodeStatusonStart () final

Claims the process-wide right to execute MPC, then sets up the problem from the Behavior's ports. More...

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

Runs the MPC loop and releases the claim taken by onStart() on every exit path. Final for that reason. More...

boolfinished ()

Determines whether the behavior has finished execution. More...

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

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

Private Member Functions Index

tl::expected< moveit_pro_mpc::ProblemParameters, std::string >getRequiredProblemInputs () const

Retrieves the required problem parameters from the input ports. More...

tl::expected< moveit_pro_mpc::SolverParameters, std::string >getRequiredSolverInputs () const

Retrieves the required solver parameters from the input ports. More...

tl::expected< bool, std::string >runStreamingLoop (moveit_pro_mpc::MPCProblem &mpc_problem)

Streams MPC trajectory chunks to the controller until the behavior finishes, is halted, or fails. More...

Public Member Attributes Index

trajectory_msgs::msg::JointTrajectorytrajectory_msg

Trajectory message to be populated by MPC. More...

rclcpp_action::Client< control_msgs::action::FollowJointTrajectory >::SharedPtrclient

Action client to send trajectories to a joint trajectory controller. More...

std::shared_ptr< moveit_pro::planning_scene_monitor::PlanningSceneMonitor >planning_scene_monitor

Shared pointer to the planning scene monitor used for monitoring and updating the planning scene. More...

moveit_pro::base::RobotModelConstPtrrobot_model

Constant pointer to the robot model used for planning and execution. More...

std::function< tl::expected< void, std::string >(const BT::TreeNode &)>set_residual_ports

Callback to set the residual parameters from the BT ports. More...

Private Member Attributes Index

std::stringfollow_joint_trajectory_topic_
std::atomic< bool >canceled_ = true
std::shared_future< tl::expected< bool, std::string > >future

Classes derived from AsyncBehaviorBase must have this shared_future as a class member. Declared as the class's last data member so its destructor joins the running doWork before any member doWork uses is destroyed. More...

Public Static Functions Index

static BT::PortsListprovidedProblemParametersPorts ()

Provides the list of BT ports required for problem parameters. More...

static BT::PortsListprovidedSolverParametersPorts ()

Provides the list of BT ports required for solver parameters. More...

Description

All non-template implementation for the templated MPCBehaviorBase class.

Definition at line 32 of file mpc_behavior_base.hpp.

Public Constructors

MPCBehaviorBase()

moveit_pro::behaviors::internal::MPCBehaviorBase::MPCBehaviorBase (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< moveit_pro::behaviors::BehaviorContext > & shared_resources, const std::function< tl::expected< void, std::string >(const BT::TreeNode &)> & set_residual_ports)

Declaration at line 35 of file mpc_behavior_base.hpp, definition at line 73 of file mpc_behavior_base.cpp.

Public Destructor

~MPCBehaviorBase()

moveit_pro::behaviors::internal::MPCBehaviorBase::~MPCBehaviorBase ()

Definition at line 39 of file mpc_behavior_base.hpp.

Public Member Functions

doHalt()

tl::expected< void, std::string > moveit_pro::behaviors::internal::MPCBehaviorBase::doHalt ()
virtual

Optionally implement additional work needed to cleanly interrupt the async process.

The default implementation of this function is a no-op which will not interrupt the async process. This will mean that onHalted will wait until the process finishes before returning.

Returns

Return an empty tl::expected<void, std::string> if the additional work to halt was successful. Return an error message if something failed while doing additional work to halt.

Declaration at line 41 of file mpc_behavior_base.hpp, definition at line 83 of file mpc_behavior_base.cpp.

doWork()

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

Runs the MPC loop and releases the claim taken by onStart() on every exit path. Final for that reason.

Declaration at line 51 of file mpc_behavior_base.hpp, definition at line 219 of file mpc_behavior_base.cpp.

finished()

virtual bool moveit_pro::behaviors::internal::MPCBehaviorBase::finished ()
inline virtual

Determines whether the behavior has finished execution.

This method can be overridden by derived classes to customize the termination condition for the behavior. By default, it always returns false.

Returns

true if the behavior has finished, false otherwise.

Definition at line 73 of file mpc_behavior_base.hpp.

getFuture()

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

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

Declaration at line 79 of file mpc_behavior_base.hpp, definition at line 347 of file mpc_behavior_base.cpp.

onStart()

BT::NodeStatus moveit_pro::behaviors::internal::MPCBehaviorBase::onStart ()

Claims the process-wide right to execute MPC, then sets up the problem from the Behavior's ports.

Final because it pairs with doWork(), which hands the claim back. An override that skipped either half would leak the claim and permanently block every later MPC Behavior in this process. Override finished() instead.

Declaration at line 48 of file mpc_behavior_base.hpp, definition at line 145 of file mpc_behavior_base.cpp.

Private Member Functions

getRequiredProblemInputs()

tl::expected< moveit_pro_mpc::ProblemParameters, std::string > moveit_pro::behaviors::internal::MPCBehaviorBase::getRequiredProblemInputs ()

Retrieves the required problem parameters from the input ports.

Returns

A tl::expected containing the problem parameters on success, or an error message on failure.

Declaration at line 97 of file mpc_behavior_base.hpp, definition at line 89 of file mpc_behavior_base.cpp.

getRequiredSolverInputs()

tl::expected< moveit_pro_mpc::SolverParameters, std::string > moveit_pro::behaviors::internal::MPCBehaviorBase::getRequiredSolverInputs ()

Retrieves the required solver parameters from the input ports.

Returns

A tl::expected containing the solver parameters on success, or an error message on failure.

Declaration at line 103 of file mpc_behavior_base.hpp, definition at line 119 of file mpc_behavior_base.cpp.

runStreamingLoop()

tl::expected< bool, std::string > moveit_pro::behaviors::internal::MPCBehaviorBase::runStreamingLoop (moveit_pro_mpc::MPCProblem & mpc_problem)

Streams MPC trajectory chunks to the controller until the behavior finishes, is halted, or fails.

Returns

true on completion, or an error message on failure.

Declaration at line 109 of file mpc_behavior_base.hpp, definition at line 271 of file mpc_behavior_base.cpp.

Public Member Attributes

client

rclcpp_action::Client<control_msgs::action::FollowJointTrajectory>::SharedPtr moveit_pro::behaviors::internal::MPCBehaviorBase::client

Action client to send trajectories to a joint trajectory controller.

Definition at line 84 of file mpc_behavior_base.hpp.

planning_scene_monitor

std::shared_ptr<moveit_pro::planning_scene_monitor::PlanningSceneMonitor> moveit_pro::behaviors::internal::MPCBehaviorBase::planning_scene_monitor

Shared pointer to the planning scene monitor used for monitoring and updating the planning scene.

Definition at line 86 of file mpc_behavior_base.hpp.

robot_model

moveit_pro::base::RobotModelConstPtr moveit_pro::behaviors::internal::MPCBehaviorBase::robot_model

Constant pointer to the robot model used for planning and execution.

Definition at line 88 of file mpc_behavior_base.hpp.

set_residual_ports

std::function<tl::expected<void, std::string>(const BT::TreeNode&)> moveit_pro::behaviors::internal::MPCBehaviorBase::set_residual_ports

Callback to set the residual parameters from the BT ports.

Definition at line 90 of file mpc_behavior_base.hpp.

trajectory_msg

trajectory_msgs::msg::JointTrajectory moveit_pro::behaviors::internal::MPCBehaviorBase::trajectory_msg

Trajectory message to be populated by MPC.

Definition at line 82 of file mpc_behavior_base.hpp.

Private Member Attributes

canceled_

std::atomic<bool> moveit_pro::behaviors::internal::MPCBehaviorBase::canceled_ = true

Definition at line 112 of file mpc_behavior_base.hpp.

follow_joint_trajectory_topic_

std::string moveit_pro::behaviors::internal::MPCBehaviorBase::follow_joint_trajectory_topic_

Definition at line 111 of file mpc_behavior_base.hpp.

future

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::internal::MPCBehaviorBase::future

Classes derived from AsyncBehaviorBase must have this shared_future as a class member. Declared as the class's last data member so its destructor joins the running doWork before any member doWork uses is destroyed.

Definition at line 115 of file mpc_behavior_base.hpp.

Public Static Functions

providedProblemParametersPorts()

BT::PortsList moveit_pro::behaviors::internal::MPCBehaviorBase::providedProblemParametersPorts ()
static

Provides the list of BT ports required for problem parameters.

Returns

A list of BT ports for problem parameters.

Declaration at line 57 of file mpc_behavior_base.hpp, definition at line 41 of file mpc_behavior_base.cpp.

providedSolverParametersPorts()

BT::PortsList moveit_pro::behaviors::internal::MPCBehaviorBase::providedSolverParametersPorts ()
static

Provides the list of BT ports required for solver parameters.

Returns

A list of BT ports for solver parameters.

Declaration at line 63 of file mpc_behavior_base.hpp, definition at line 59 of file mpc_behavior_base.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.