Skip to main content

ExecuteTrajectory Class

Accepts a JointTrajectory message via an input data port, and executes it by sending a goal to either a standard FollowJointTrajectory action server (JTC) or a Joint Trajectory Admittance Controller (JTAC) action server, depending on the value of the execution_pipeline input port. More...

Declaration

class moveit_pro::behaviors::ExecuteTrajectory { ... }

Included Headers

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

ExecuteTrajectory (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources)

Public Member Functions Index

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 Functions Index

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

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

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

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

Private Member Attributes Index

std::unique_ptr< TrajectoryExecutionPipeline >trajectory_executor_
std::stringcurrent_execution_pipeline_
std::mutexgoal_mutex_
boolgoal_active_ = false
std::atomic< bool >halt_requested_ = false
std::shared_future< tl::expected< bool, std::string > >future_

Public Static Functions Index

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

Private Static Attributes Index

static constexpr autokDescriptionExecuteTrajectory = ...
static constexpr autokPortExecutionPipeline = "execution_pipeline"
static constexpr autokPortControllerActionName = "controller_action_name"
static constexpr autokPortJointTrajectoryMsg = "joint_trajectory_msg"
static constexpr autokPortGoalPositionTolerance = "goal_position_tolerance"
static constexpr autokPortPathPositionTolerance = "path_position_tolerance"
static constexpr autokPortAbsoluteForceTorqueThreshold = "absolute_force_torque_threshold"
static constexpr autokPortAdmittanceParameters = "admittance_parameters_msg"
static constexpr autokPortGoalDurationTolerance = "goal_duration_tolerance"

Description

Accepts a JointTrajectory message via an input data port, and executes it by sending a goal to either a standard FollowJointTrajectory action server (JTC) or a Joint Trajectory Admittance Controller (JTAC) action server, depending on the value of the execution_pipeline input port.

The execution_pipeline input port selects between the JTC and JTAC action interfaces at runtime.

Data Port NamePort TypeObject Type
execution_pipelineInputstd::string
controller_action_nameInputstd::string
joint_trajectory_msgInputtrajectory_msgs::msg::JointTrajectory
goal_position_toleranceInputdouble
path_position_toleranceInputdouble
absolute_force_torque_thresholdInputstd::vector<double>
admittance_parameters_msgInputmoveit_pro_controllers_msgs::msg::AdmittanceParameters
goal_duration_toleranceInputdouble

Definition at line 37 of file execute_trajectory.hpp.

Public Constructors

ExecuteTrajectory()

moveit_pro::behaviors::ExecuteTrajectory::ExecuteTrajectory (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources)

Declaration at line 40 of file execute_trajectory.hpp, definition at line 17 of file execute_trajectory.cpp.

Public Member Functions

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::ExecuteTrajectory::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 47 of file execute_trajectory.hpp, definition at line 62 of file execute_trajectory.cpp.

Private Member Functions

doHalt()

tl::expected< void, std::string > moveit_pro::behaviors::ExecuteTrajectory::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 52 of file execute_trajectory.hpp, definition at line 160 of file execute_trajectory.cpp.

doWork()

tl::expected< bool, std::string > moveit_pro::behaviors::ExecuteTrajectory::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 50 of file execute_trajectory.hpp, definition at line 67 of file execute_trajectory.cpp.

Private Member Attributes

current_execution_pipeline_

std::string moveit_pro::behaviors::ExecuteTrajectory::current_execution_pipeline_

Definition at line 82 of file execute_trajectory.hpp.

future_

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

Definition at line 87 of file execute_trajectory.hpp.

goal_active_

bool moveit_pro::behaviors::ExecuteTrajectory::goal_active_ = false

Definition at line 84 of file execute_trajectory.hpp.

goal_mutex_

std::mutex moveit_pro::behaviors::ExecuteTrajectory::goal_mutex_

Definition at line 83 of file execute_trajectory.hpp.

halt_requested_

std::atomic<bool> moveit_pro::behaviors::ExecuteTrajectory::halt_requested_ = false

Definition at line 85 of file execute_trajectory.hpp.

trajectory_executor_

std::unique_ptr<TrajectoryExecutionPipeline> moveit_pro::behaviors::ExecuteTrajectory::trajectory_executor_

Definition at line 81 of file execute_trajectory.hpp.

Public Static Functions

metadata()

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

Declaration at line 45 of file execute_trajectory.hpp, definition at line 56 of file execute_trajectory.cpp.

providedPorts()

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

Declaration at line 43 of file execute_trajectory.hpp, definition at line 23 of file execute_trajectory.cpp.

Private Static Attributes

kDescriptionExecuteTrajectory

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kDescriptionExecuteTrajectory
constexpr static
Initialiser
= R"(     <p>Execute a given joint trajectory by sending a request to either a standard FollowJointTrajectory action server (JTC)     or a Joint Trajectory Admittance Controller (JTAC) action server, depending on the value of the execution_pipeline input port.</p>     <p>The corresponding controller needs to be active, which can be done with the <code>ActivateControllers</code> Behavior.</p>     <p>If execution_pipeline is set to 'jtc', this Behavior sends the trajectory to a standard     <code>control_msgs::action::FollowJointTrajectory</code> action server (e.g., JTC or other controllers with that interface).</p>     <p>If execution_pipeline is set to 'jtac', this Behavior sends the trajectory to a     <code>moveit_pro_controllers_msgs::action::FollowJointTrajectoryWithAdmittance</code> action server (e.g., JTAC).</p>     <p>If the server completes the action successfully, this Behavior succeeds.</p>     <p>If any of the following failure states occur, this Behavior will exit with a FAILURE status code:</p>     <ul>         <li>No action server is available with the specified name.</li>         <li>The joint trajectory message has no data.</li>         <li>absolute_force_torque_threshold is set without admittance_parameters_msg, since the threshold is a field of the admittance parameters and has no effect on its own.</li>         <li>The action result is received, but its contents indicate that the action server failed to execute the trajectory.</li>     </ul>   )"

Definition at line 54 of file execute_trajectory.hpp.

kPortAbsoluteForceTorqueThreshold

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortAbsoluteForceTorqueThreshold = "absolute_force_torque_threshold"
constexpr static

Definition at line 77 of file execute_trajectory.hpp.

kPortAdmittanceParameters

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortAdmittanceParameters = "admittance_parameters_msg"
constexpr static

Definition at line 78 of file execute_trajectory.hpp.

kPortControllerActionName

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortControllerActionName = "controller_action_name"
constexpr static

Definition at line 73 of file execute_trajectory.hpp.

kPortExecutionPipeline

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortExecutionPipeline = "execution_pipeline"
constexpr static

Definition at line 72 of file execute_trajectory.hpp.

kPortGoalDurationTolerance

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortGoalDurationTolerance = "goal_duration_tolerance"
constexpr static

Definition at line 79 of file execute_trajectory.hpp.

kPortGoalPositionTolerance

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortGoalPositionTolerance = "goal_position_tolerance"
constexpr static

Definition at line 75 of file execute_trajectory.hpp.

kPortJointTrajectoryMsg

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortJointTrajectoryMsg = "joint_trajectory_msg"
constexpr static

Definition at line 74 of file execute_trajectory.hpp.

kPortPathPositionTolerance

constexpr auto moveit_pro::behaviors::ExecuteTrajectory::kPortPathPositionTolerance = "path_position_tolerance"
constexpr static

Definition at line 76 of file execute_trajectory.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.