moveit2
The MoveIt Motion Planning Framework for ROS 2.
|
Monitors the joint_states topic and tf to maintain the current state of the robot. More...
#include <current_state_monitor.h>
Classes | |
class | MiddlewareHandle |
Dependency injection class for testing the CurrentStateMonitor. More... | |
Public Member Functions | |
CurrentStateMonitor (std::unique_ptr< MiddlewareHandle > middleware_handle, const moveit::core::RobotModelConstPtr &robot_model, const std::shared_ptr< tf2_ros::Buffer > &tf_buffer, bool use_sim_time) | |
Constructor. | |
CurrentStateMonitor (const rclcpp::Node::SharedPtr &node, const moveit::core::RobotModelConstPtr &robot_model, const std::shared_ptr< tf2_ros::Buffer > &tf_buffer, bool use_sim_time) | |
Constructor. | |
~CurrentStateMonitor () | |
void | startStateMonitor (const std::string &joint_states_topic="joint_states") |
Start monitoring joint states on a particular topic. | |
void | stopStateMonitor () |
Stop monitoring the "joint_states" topic. | |
bool | isActive () const |
Check if the state monitor is started. | |
const moveit::core::RobotModelConstPtr & | getRobotModel () const |
Get the RobotModel for which we are monitoring state. | |
std::string | getMonitoredTopic () const |
Get the name of the topic being monitored. Returns an empty string if the monitor is inactive. | |
bool | haveCompleteState () const |
Query whether we have joint state information for all DOFs in the kinematic model. | |
bool | haveCompleteState (const rclcpp::Time &oldest_allowed_update_time) const |
Query whether we have joint state information for all DOFs in the kinematic model. | |
bool | haveCompleteState (const rclcpp::Duration &age) const |
Query whether we have joint state information for all DOFs in the kinematic model. | |
bool | haveCompleteState (std::vector< std::string > &missing_joints) const |
Query whether we have joint state information for all DOFs in the kinematic model. | |
bool | haveCompleteState (const rclcpp::Time &oldest_allowed_update_time, std::vector< std::string > &missing_joints) const |
Query whether we have joint state information for all DOFs in the kinematic model. | |
bool | haveCompleteState (const rclcpp::Duration &age, std::vector< std::string > &missing_joints) const |
Query whether we have joint state information for all DOFs in the kinematic model. | |
moveit::core::RobotStatePtr | getCurrentState () const |
Get the current state. | |
void | setToCurrentState (moveit::core::RobotState &upd) const |
Set the state upd to the current state maintained by this class. | |
rclcpp::Time | getCurrentStateTime () const |
Get the time stamp for the current state. | |
std::pair< moveit::core::RobotStatePtr, rclcpp::Time > | getCurrentStateAndTime () const |
Get the current state and its time stamp. | |
std::map< std::string, double > | getCurrentStateValues () const |
Get the current state values as a map from joint names to joint state values. | |
bool | waitForCurrentState (const rclcpp::Time &t=rclcpp::Clock(RCL_ROS_TIME).now(), double wait_time_s=1.0) const |
Wait for at most wait_time_s seconds (default 1s) for a robot state more recent than t. | |
bool | waitForCompleteState (double wait_time_s) const |
Wait for at most wait_time_s seconds until the complete robot state is known. | |
bool | waitForCompleteState (const std::string &group, double wait_time_s) const |
Wait for at most wait_time_s seconds until the joint values from the group group are known. Return true if values for all joints in group are known. | |
const rclcpp::Time & | getMonitorStartTime () const |
Get the time point when the monitor was started. | |
void | addUpdateCallback (const JointStateUpdateCallback &fn) |
Add a function that will be called whenever the joint state is updated. | |
void | clearUpdateCallbacks () |
Clear the functions to be called when an update to the joint state is received. | |
void | setBoundsError (double error) |
When a joint value is received to be out of bounds, it is changed slightly to fit within bounds, if the difference is less than a specified value (labeled the "allowed bounds error"). This value can be set using this function. | |
double | getBoundsError () const |
When a joint value is received to be out of bounds, it is changed slightly to fit within bounds, if the difference is less than a specified value (labeled the "allowed bounds error"). | |
void | enableCopyDynamics (bool enabled) |
Allow the joint_state arrays velocity and effort to be copied into the robot state this is useful in some but not all applications. | |
Monitors the joint_states topic and tf to maintain the current state of the robot.
Definition at line 61 of file current_state_monitor.h.
planning_scene_monitor::CurrentStateMonitor::CurrentStateMonitor | ( | std::unique_ptr< MiddlewareHandle > | middleware_handle, |
const moveit::core::RobotModelConstPtr & | robot_model, | ||
const std::shared_ptr< tf2_ros::Buffer > & | tf_buffer, | ||
bool | use_sim_time | ||
) |
Constructor.
middleware_handle | The ros middleware handle |
robot_model | The current kinematic model to build on |
tf_buffer | A pointer to the tf2_ros Buffer to use |
use_sim_time | True when the time is abstracted |
planning_scene_monitor::CurrentStateMonitor::CurrentStateMonitor | ( | const rclcpp::Node::SharedPtr & | node, |
const moveit::core::RobotModelConstPtr & | robot_model, | ||
const std::shared_ptr< tf2_ros::Buffer > & | tf_buffer, | ||
bool | use_sim_time | ||
) |
Constructor.
node | A shared_ptr to a node used for subscription to joint_states_topic |
robot_model | The current kinematic model to build on |
tf_buffer | A pointer to the tf2_ros Buffer to use |
use_sim_time | True when the time is abstracted |
Definition at line 68 of file current_state_monitor.cpp.
planning_scene_monitor::CurrentStateMonitor::~CurrentStateMonitor | ( | ) |
void planning_scene_monitor::CurrentStateMonitor::addUpdateCallback | ( | const JointStateUpdateCallback & | fn | ) |
Add a function that will be called whenever the joint state is updated.
Definition at line 137 of file current_state_monitor.cpp.
void planning_scene_monitor::CurrentStateMonitor::clearUpdateCallbacks | ( | ) |
Clear the functions to be called when an update to the joint state is received.
Definition at line 143 of file current_state_monitor.cpp.
|
inline |
Allow the joint_state arrays velocity and effort to be copied into the robot state this is useful in some but not all applications.
Definition at line 316 of file current_state_monitor.h.
|
inline |
When a joint value is received to be out of bounds, it is changed slightly to fit within bounds, if the difference is less than a specified value (labeled the "allowed bounds error").
Definition at line 308 of file current_state_monitor.h.
moveit::core::RobotStatePtr planning_scene_monitor::CurrentStateMonitor::getCurrentState | ( | ) | const |
Get the current state.
Definition at line 81 of file current_state_monitor.cpp.
std::pair< moveit::core::RobotStatePtr, rclcpp::Time > planning_scene_monitor::CurrentStateMonitor::getCurrentStateAndTime | ( | ) | const |
Get the current state and its time stamp.
Definition at line 94 of file current_state_monitor.cpp.
rclcpp::Time planning_scene_monitor::CurrentStateMonitor::getCurrentStateTime | ( | ) | const |
Get the time stamp for the current state.
Definition at line 88 of file current_state_monitor.cpp.
std::map< std::string, double > planning_scene_monitor::CurrentStateMonitor::getCurrentStateValues | ( | ) | const |
Get the current state values as a map from joint names to joint state values.
Definition at line 101 of file current_state_monitor.cpp.
std::string planning_scene_monitor::CurrentStateMonitor::getMonitoredTopic | ( | ) | const |
Get the name of the topic being monitored. Returns an empty string if the monitor is inactive.
Definition at line 195 of file current_state_monitor.cpp.
|
inline |
Get the time point when the monitor was started.
Definition at line 284 of file current_state_monitor.h.
|
inline |
Get the RobotModel for which we are monitoring state.
Definition at line 188 of file current_state_monitor.h.
|
inline |
Query whether we have joint state information for all DOFs in the kinematic model.
Definition at line 199 of file current_state_monitor.h.
|
inline |
Query whether we have joint state information for all DOFs in the kinematic model.
age | Joint information must be at most this old |
Definition at line 218 of file current_state_monitor.h.
|
inline |
Query whether we have joint state information for all DOFs in the kinematic model.
Definition at line 247 of file current_state_monitor.h.
|
inline |
Query whether we have joint state information for all DOFs in the kinematic model.
oldest_allowed_update_time | All joint information must be from this time or more current |
Definition at line 208 of file current_state_monitor.h.
|
inline |
Query whether we have joint state information for all DOFs in the kinematic model.
oldest_allowed_update_time | All joint information must be from this time or more current |
missing_joints | Returns the list of joints that are missing |
Definition at line 237 of file current_state_monitor.h.
|
inline |
Query whether we have joint state information for all DOFs in the kinematic model.
missing_joints | Returns the list of joints that are missing |
Definition at line 227 of file current_state_monitor.h.
bool planning_scene_monitor::CurrentStateMonitor::isActive | ( | ) | const |
Check if the state monitor is started.
Definition at line 176 of file current_state_monitor.cpp.
|
inline |
When a joint value is received to be out of bounds, it is changed slightly to fit within bounds, if the difference is less than a specified value (labeled the "allowed bounds error"). This value can be set using this function.
error | The specified value for the "allowed bounds error". The default is machine precision. |
Definition at line 299 of file current_state_monitor.h.
void planning_scene_monitor::CurrentStateMonitor::setToCurrentState | ( | moveit::core::RobotState & | upd | ) | const |
Set the state upd to the current state maintained by this class.
Definition at line 112 of file current_state_monitor.cpp.
void planning_scene_monitor::CurrentStateMonitor::startStateMonitor | ( | const std::string & | joint_states_topic = "joint_states" | ) |
Start monitoring joint states on a particular topic.
joint_states_topic | The topic name for joint states (defaults to "joint_states") |
Definition at line 148 of file current_state_monitor.cpp.
void planning_scene_monitor::CurrentStateMonitor::stopStateMonitor | ( | ) |
Stop monitoring the "joint_states" topic.
Definition at line 181 of file current_state_monitor.cpp.
bool planning_scene_monitor::CurrentStateMonitor::waitForCompleteState | ( | const std::string & | group, |
double | wait_time_s | ||
) | const |
Wait for at most wait_time_s seconds until the joint values from the group group are known. Return true if values for all joints in group are known.
Definition at line 293 of file current_state_monitor.cpp.
bool planning_scene_monitor::CurrentStateMonitor::waitForCompleteState | ( | double | wait_time_s | ) | const |
Wait for at most wait_time_s seconds until the complete robot state is known.
Definition at line 280 of file current_state_monitor.cpp.
bool planning_scene_monitor::CurrentStateMonitor::waitForCurrentState | ( | const rclcpp::Time & | t = rclcpp::Clock(RCL_ROS_TIME).now() , |
double | wait_time_s = 1.0 |
||
) | const |
Wait for at most wait_time_s seconds (default 1s) for a robot state more recent than t.
Definition at line 232 of file current_state_monitor.cpp.