Skip to main content

SetMujocoFreeBodyPoses Class

Sets the poses of free bodies in the MuJoCo simulation and zeroes their velocities. More...

Declaration​

class moveit_pro::behaviors::SetMujocoFreeBodyPoses { ... }

Included Headers​

#include <set_mujoco_free_body_poses.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​

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

Constructor for testing with an injected 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< std::chrono::duration< double >, std::string >getResponseTimeout () override

Returns a fixed 5 s, so the Behavior fails instead of waiting forever when the service does not answer. More...

tl::expected< moveit_studio_internal_msgs::srv::SetMujocoFreeBodyPoses::Request, std::string >createRequest () override

User-provided function to create the service request. More...

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

Optional user-provided function to process the service response after the service has finished. 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​

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

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

Public Static Functions Index​

static BT::PortsListprovidedPorts ()

Defines the input/output ports for this behavior. More...

static BT::KeyValueVectormetadata ()

Provides metadata about the behavior for the behavior tree editor. More...

Description​

Sets the poses of free bodies in the MuJoCo simulation and zeroes their velocities.

Transforms each pose to mj_world through TF and calls the configured service, /mujoco_system/set_free_body_poses by default. TF resolves every pose before any body moves, so a pose relative to a body that the same call moves uses that body's old pose. The service applies every pose or none. Each body must have a free joint and must not be part of the robot. Place each body clear of other geometry, because MuJoCo pushes overlapping bodies apart and can move one far from its pose. Release a body that a suction cup or other active weld holds first, because the weld pulls it back. The Behavior does not stop the controllers, so deactivate them first if the arm could move into the bodies.

Data Port NamePort TypeObject Type
body_namesinputstd::vector<std::string>
posesinputstd::vector<geometry_msgs::msg::PoseStamped>
service_nameinputstd::string

Definition at line 37 of file set_mujoco_free_body_poses.hpp.

Public Constructors​

SetMujocoFreeBodyPoses()​

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

Declaration at line 41 of file set_mujoco_free_body_poses.hpp, definition at line 47 of file set_mujoco_free_body_poses.cpp.

SetMujocoFreeBodyPoses()​

moveit_pro::behaviors::SetMujocoFreeBodyPoses::SetMujocoFreeBodyPoses (const std::string & name, const BT::NodeConfiguration & config, const std::shared_ptr< BehaviorContext > & shared_resources, std::unique_ptr< ClientInterfaceBase< moveit_studio_internal_msgs::srv::SetMujocoFreeBodyPoses > > client_interface)
explicit

Constructor for testing with an injected service client.

Parameters
client_interface

The service client the Behavior calls.

Definition at line 48 of file set_mujoco_free_body_poses.hpp.

Private Member Functions​

createRequest()​

tl::expected< SetMujocoFreeBodyPosesSrv::Request, std::string > moveit_pro::behaviors::SetMujocoFreeBodyPoses::createRequest ()
virtual

User-provided function to create the service request.

Returns

Returns a service request message. 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 73 of file set_mujoco_free_body_poses.hpp, definition at line 102 of file set_mujoco_free_body_poses.cpp.

getFuture()​

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::SetMujocoFreeBodyPoses::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 80 of file set_mujoco_free_body_poses.hpp.

getResponseTimeout()​

tl::expected< std::chrono::duration< double >, std::string > moveit_pro::behaviors::SetMujocoFreeBodyPoses::getResponseTimeout ()
virtual

Returns a fixed 5 s, so the Behavior fails instead of waiting forever when the service does not answer.

Declaration at line 70 of file set_mujoco_free_body_poses.hpp, definition at line 97 of file set_mujoco_free_body_poses.cpp.

getServiceName()​

tl::expected< std::string, std::string > moveit_pro::behaviors::SetMujocoFreeBodyPoses::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 67 of file set_mujoco_free_body_poses.hpp, definition at line 81 of file set_mujoco_free_body_poses.cpp.

processResponse()​

tl::expected< bool, std::string > moveit_pro::behaviors::SetMujocoFreeBodyPoses::processResponse (const moveit_studio_internal_msgs::srv::SetMujocoFreeBodyPoses::Response & response)

Optional user-provided function to process the service response after the service has finished.

If no user-defined implementation is provided, then no additional processing will be performed on succeeding service responses and this function will always return void.

Parameters
response

Service response message to process.

Returns

Returns true or false depending on the user's implementation if the service response could be processed successfully. If the service response could not be processed, 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 77 of file set_mujoco_free_body_poses.hpp, definition at line 126 of file set_mujoco_free_body_poses.cpp.

Private Member Attributes​

response_future_​

std::shared_future<tl::expected<bool, std::string> > moveit_pro::behaviors::SetMujocoFreeBodyPoses::response_future_

Holds the result of calling the service asynchronously.

Definition at line 86 of file set_mujoco_free_body_poses.hpp.

Public Static Functions​

metadata()​

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

Provides metadata about the behavior for the behavior tree editor.

Returns

Key-value pairs describing subcategory and description.

Declaration at line 63 of file set_mujoco_free_body_poses.hpp, definition at line 75 of file set_mujoco_free_body_poses.cpp.

providedPorts()​

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

Defines the input/output ports for this behavior.

Returns

List of ports with their types and descriptions.

Declaration at line 57 of file set_mujoco_free_body_poses.hpp, definition at line 61 of file set_mujoco_free_body_poses.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.