Skip to main content

RecordJointTrajectory Class

Record a JointTrajectory message by subscribing to a topic publishing joint states and pushing the joint states to a JointTrajectory message. More...

Declaration

class moveit_pro::behaviors::RecordJointTrajectory { ... }

Included Headers

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

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

voidonHalted () override
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

std::shared_future< tl::expected< bool, std::string > >future_

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

rclcpp::Service< std_srvs::srv::Trigger >::SharedPtrstart_recording_service_
rclcpp::Service< std_srvs::srv::Trigger >::SharedPtrstop_recording_service_
rclcpp::Subscription< sensor_msgs::msg::JointState >::SharedPtrjoint_state_subscriber_
std::atomic_boolstart_recording_flag_
std::atomic_boolstop_recording_flag_
std::atomic_boolerror_flag_
std::stringerror_
std::condition_variablecv_
std::mutexmtx_
trajectory_msgs::msg::JointTrajectoryjoint_trajectory_msg_
std::set< std::string, std::less<> >joints_to_record_
rclcpp::Timestart_time_for_recording_
rclcpp::Timestart_timeout_
doubletimeout_sec_

Public Static Functions Index

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

Description

Record a JointTrajectory message by subscribing to a topic publishing joint states and pushing the joint states to a JointTrajectory message.

This Behavior doesn't start recording until the start recording service is called. To stop recording, the stop recording service must be called. There is an optional omit_joints port, which can be used to omit joints from being recorded

Data Port NamePort TypeObject Type
start_recording_serviceInputstd::string
stop_recording_serviceInputstd::string
joint_state_topicInputstd::string
timeout_secInputdouble
planning_group_nameInputstd::string
joint_space_stepInputdouble
joint_trajectory_messageOutputtrajectory_msgs::msg::JointTrajectory

Definition at line 44 of file record_joint_trajectory.hpp.

Public Constructors

RecordJointTrajectory()

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

Declaration at line 47 of file record_joint_trajectory.hpp, definition at line 302 of file record_joint_trajectory.cpp.

Private Member Functions

doWork()

tl::expected< bool, std::string > moveit_pro::behaviors::RecordJointTrajectory::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 55 of file record_joint_trajectory.hpp, definition at line 337 of file record_joint_trajectory.cpp.

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::RecordJointTrajectory::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 59 of file record_joint_trajectory.hpp.

onHalted()

void moveit_pro::behaviors::RecordJointTrajectory::onHalted ()

Declaration at line 57 of file record_joint_trajectory.hpp, definition at line 428 of file record_joint_trajectory.cpp.

Private Member Attributes

cv_

std::condition_variable moveit_pro::behaviors::RecordJointTrajectory::cv_

Definition at line 81 of file record_joint_trajectory.hpp.

error_

std::string moveit_pro::behaviors::RecordJointTrajectory::error_

Definition at line 78 of file record_joint_trajectory.hpp.

error_flag_

std::atomic_bool moveit_pro::behaviors::RecordJointTrajectory::error_flag_

Definition at line 77 of file record_joint_trajectory.hpp.

future_

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

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

Definition at line 65 of file record_joint_trajectory.hpp.

joint_state_subscriber_

rclcpp::Subscription<sensor_msgs::msg::JointState>::SharedPtr moveit_pro::behaviors::RecordJointTrajectory::joint_state_subscriber_

Definition at line 70 of file record_joint_trajectory.hpp.

joint_trajectory_msg_

trajectory_msgs::msg::JointTrajectory moveit_pro::behaviors::RecordJointTrajectory::joint_trajectory_msg_

Definition at line 85 of file record_joint_trajectory.hpp.

joints_to_record_

std::set<std::string, std::less<> > moveit_pro::behaviors::RecordJointTrajectory::joints_to_record_

Definition at line 86 of file record_joint_trajectory.hpp.

mtx_

std::mutex moveit_pro::behaviors::RecordJointTrajectory::mtx_

Definition at line 82 of file record_joint_trajectory.hpp.

start_recording_flag_

std::atomic_bool moveit_pro::behaviors::RecordJointTrajectory::start_recording_flag_

Definition at line 73 of file record_joint_trajectory.hpp.

start_recording_service_

rclcpp::Service<std_srvs::srv::Trigger>::SharedPtr moveit_pro::behaviors::RecordJointTrajectory::start_recording_service_

Definition at line 68 of file record_joint_trajectory.hpp.

start_time_for_recording_

rclcpp::Time moveit_pro::behaviors::RecordJointTrajectory::start_time_for_recording_

Definition at line 87 of file record_joint_trajectory.hpp.

start_timeout_

rclcpp::Time moveit_pro::behaviors::RecordJointTrajectory::start_timeout_

Definition at line 88 of file record_joint_trajectory.hpp.

stop_recording_flag_

std::atomic_bool moveit_pro::behaviors::RecordJointTrajectory::stop_recording_flag_

Definition at line 74 of file record_joint_trajectory.hpp.

stop_recording_service_

rclcpp::Service<std_srvs::srv::Trigger>::SharedPtr moveit_pro::behaviors::RecordJointTrajectory::stop_recording_service_

Definition at line 69 of file record_joint_trajectory.hpp.

timeout_sec_

double moveit_pro::behaviors::RecordJointTrajectory::timeout_sec_

Definition at line 89 of file record_joint_trajectory.hpp.

Public Static Functions

metadata()

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

Declaration at line 52 of file record_joint_trajectory.hpp, definition at line 331 of file record_joint_trajectory.cpp.

providedPorts()

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

Declaration at line 50 of file record_joint_trajectory.hpp, definition at line 311 of file record_joint_trajectory.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.