Skip to main content

ValidateTrajectory Class

Checks if a joint trajectory is valid, given a PlanningScene. More...

Declaration

class moveit_pro::behaviors::ValidateTrajectory { ... }

Included Headers

#include <validate_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

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

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

rclcpp::Publisher< visualization_msgs::msg::MarkerArray >::SharedPtrmarkers_publisher_
std::set< std::string >contact_namespaces_
std::shared_future< tl::expected< bool, std::string > >future_

Classes derived from AsyncBehaviorBase must have this shared_future as a class member. More...

Public Static Functions Index

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

Description

Checks if a joint trajectory is valid, given a PlanningScene.

This behavior just checks that the joint trajectory is collision-free at a given density (joint_space_step and cartesian_space_step).

The planning scene is taken as input (instead of querying the current planning scene) to enable the user to set arbitrary planning scenes. Combine with the GetCurrentPlanningScene behavior to use the current planning scene.

The given trajectory must contain exclusively the planning group joints, otherwise an error will be returned.

The debug_solution port will contain an MTC Solution message with the portion of the trajectory that passed validation. This can be the entire trajectory if all the setpoints passed validation.

A trajectory that collides also draws the offending waypoint in the 3D Visualizer, as a translucent robot beside the spheres marking where it touches.

Data Port NamePort TypeObject Type
planning_scene_msgInputmoveit_msgs::msg::PlanningScene
planning_group_nameInputstd::string
joint_trajectory_msgInputtrajectory_msgs::msg::JointTrajectory
joint_space_stepInputdouble
cartesian_space_stepInputdouble
debug_solutionOutputmoveit_task_constructor_msgs::msg::Solution

Definition at line 86 of file validate_trajectory.hpp.

Public Constructors

ValidateTrajectory()

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

Declaration at line 89 of file validate_trajectory.hpp, definition at line 120 of file validate_trajectory.cpp.

Private Member Functions

doWork()

tl::expected< bool, std::string > moveit_pro::behaviors::ValidateTrajectory::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 97 of file validate_trajectory.hpp, definition at line 155 of file validate_trajectory.cpp.

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::ValidateTrajectory::getFuture ()
inline 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.

Definition at line 99 of file validate_trajectory.hpp.

Private Member Attributes

contact_namespaces_

std::set<std::string> moveit_pro::behaviors::ValidateTrajectory::contact_namespaces_

Where the previous attempt drew contact spheres, so this one can retract them. Declared before future_ so it outlives the worker that touches it.

Definition at line 110 of file validate_trajectory.hpp.

future_

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

Classes derived from AsyncBehaviorBase must have this shared_future as a class member.

Definition at line 113 of file validate_trajectory.hpp.

markers_publisher_

rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr moveit_pro::behaviors::ValidateTrajectory::markers_publisher_

Definition at line 106 of file validate_trajectory.hpp.

Public Static Functions

metadata()

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

Declaration at line 94 of file validate_trajectory.hpp, definition at line 149 of file validate_trajectory.cpp.

providedPorts()

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

Declaration at line 92 of file validate_trajectory.hpp, definition at line 128 of file validate_trajectory.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.