Skip to main content

CreateRobotState Class

Create a moveit_msgs::msg::RobotState and write it to the Blackboard. More...

Declaration

class moveit_pro::behaviors::CreateRobotState { ... }

Included Headers

#include <create_robot_state.hpp>

Base class

classServiceClientBehaviorBase<ServiceT>

A base class for behaviors which need to send a request to a ROS service client and wait for a result. More...

Public Constructors Index

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

Constructor for CreateRobotState behavior. More...

CreateRobotState (const std::string &name, const BT::NodeConfiguration &config, const std::shared_ptr< BehaviorContext > &shared_resources, std::unique_ptr< ClientInterfaceBase< GetPlanningScene > > client_interface)

Constructor for CreateRobotState behavior that allows for mocking of the rclcpp service client. More...

Private Member Functions Index

tl::expected< std::string, std::string >getServiceName () override

User-provided function to get the name of the service when initializing the service client. More...

tl::expected< GetPlanningScene::Request, std::string >createRequest () override

Creates a service request message. More...

tl::expected< bool, std::string >processResponse (const GetPlanningScene::Response &response) override

Given the planning scene, extract the robot's current joint state and then overwrite the positions, velocities, and efforts according to the input port values. 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 Attributes Index

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

Holds the result of calling the service asynchronously. More...

Public Static Functions Index

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

Description

Create a moveit_msgs::msg::RobotState and write it to the Blackboard.

Data Port NamePort TypeObject Type
joint_namesinputstd::vector<std::string>
positionsinputstd::vector<double>
velocitiesinputstd::vector<double>
effortsinputstd::vector<double>
joint_state_msgoutputmoveit_msgs::msg::RobotState

This Behavior takes the current JointState of the robot and overwrites the positions, velocities and efforts of those joints indicated in the 'joint_names' input port. 'joint_names' and 'positions' are mandatory, and their sizes have to match. Otherwise an error will be returned. 'velocities' and 'efforts' are optional. If specified, their size needs to match with the size of 'joint_names'.

The current robot JointState is retrieved by a call to the '/get_planning_scene' service, which contains the full robot state.

Definition at line 38 of file create_robot_state.hpp.

Public Constructors

CreateRobotState()

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

Constructor for CreateRobotState behavior.

Parameters
name

See SharedResourcesNode

config

See SharedResourcesNode

shared_resources

See SharedResourcesNode

Declaration at line 47 of file create_robot_state.hpp, definition at line 99 of file create_robot_state.cpp.

CreateRobotState()

moveit_pro::behaviors::CreateRobotState::CreateRobotState (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< ClientInterfaceBase< GetPlanningScene > > client_interface)

Constructor for CreateRobotState behavior that allows for mocking of the rclcpp service client.

Parameters
name

See SharedResourcesNode

config

See SharedResourcesNode

shared_resources

See SharedResourcesNode

client_interface

Service client interface, allowing a mock to be injected in tests.

Declaration at line 57 of file create_robot_state.hpp, definition at line 105 of file create_robot_state.cpp.

Private Member Functions

createRequest()

tl::expected< GetPlanningScene::Request, std::string > moveit_pro::behaviors::CreateRobotState::createRequest ()
virtual

Creates a service request message.

Returns

Returns an instance of GetPlanningScene::Request.

Declaration at line 72 of file create_robot_state.hpp, definition at line 140 of file create_robot_state.cpp.

getFuture()

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

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

Definition at line 82 of file create_robot_state.hpp.

getServiceName()

tl::expected< std::string, std::string > moveit_pro::behaviors::CreateRobotState::getServiceName ()
virtual

User-provided function to get the name of the service when initializing the service client.

Returns

Returns the name of the service. If not successful, returns an error message. Note that the criteria for success or failure is defined by the user's implementation of this function.

Declaration at line 66 of file create_robot_state.hpp, definition at line 135 of file create_robot_state.cpp.

processResponse()

tl::expected< bool, std::string > moveit_pro::behaviors::CreateRobotState::processResponse (const GetPlanningScene::Response & response)

Given the planning scene, extract the robot's current joint state and then overwrite the positions, velocities, and efforts according to the input port values.

Parameters
response

The response from a service call that contains the planning scene msg.

Declaration at line 79 of file create_robot_state.hpp, definition at line 147 of file create_robot_state.cpp.

Private Member Attributes

future_

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

Holds the result of calling the service asynchronously.

Definition at line 90 of file create_robot_state.hpp.

Public Static Functions

metadata()

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

Declaration at line 63 of file create_robot_state.hpp, definition at line 130 of file create_robot_state.cpp.

providedPorts()

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

Declaration at line 61 of file create_robot_state.hpp, definition at line 112 of file create_robot_state.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.