Skip to main content

ComputeInverseKinematics Class

A Behavior to compute the inverse kinematics for a given set of target poses. More...

Declaration

class moveit_pro::behaviors::ComputeInverseKinematics { ... }

Included Headers

#include <compute_inverse_kinematics.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

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

Constructor for the ComputeInverseKinematics Behavior. More...

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

A Behavior to compute the inverse kinematics for a given set of target poses.

This behavior will compute the inverse kinematics for a given planning group and set of target poses. Each target pose needs to be associated with a tip link that needs to reach that pose. In the most common case (e.g. kinematic chains), target_poses and tip_links will contain a single element each. In more complex cases (e.g. kinematic trees, like a humanoid torso), target_poses and tip_links may contain multiple elements, therefore solving the IK problem simultaneously for multiple end-effectors.

solve_mode selects the search strategy. first_found returns the first valid solution and is the default, which keeps the Behavior's historical behavior. optimize_distance keeps searching for the solver's optimization timeout and returns the candidate closest to the current robot state; it is the only mode that applies joint_costs, so setting costs under first_found fails loudly rather than silently ignoring them.

Data Port NamePort TypeObject Type
target_posesInputstd::vector<geometry_msgs::msg::PoseStamped>
tip_linksInputstd::vector<std::string>
planning_scene_msgInputmoveit_msgs::msg::PlanningScene
planning_group_nameInputstd::string
ik_timeout_sInputdouble
link_paddingInputdouble
solve_modeInputstd::string
joint_costsInputstd::vector<double>
optimization_timeout_sInputdouble
solutionOutputmoveit_msgs::msg::RobotState

Definition at line 50 of file compute_inverse_kinematics.hpp.

Public Constructors

ComputeInverseKinematics()

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

Constructor for the ComputeInverseKinematics Behavior.

Parameters
name

Name of the Behavior in the behavior tree.

config

Behavior tree node configuration, carrying the port remappings and blackboard.

shared_resources

Shared resources for the Behavior, including the robot model and logger.

Declaration at line 59 of file compute_inverse_kinematics.hpp, definition at line 148 of file compute_inverse_kinematics.cpp.

Private Member Functions

doWork()

tl::expected< bool, std::string > moveit_pro::behaviors::ComputeInverseKinematics::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 67 of file compute_inverse_kinematics.hpp, definition at line 211 of file compute_inverse_kinematics.cpp.

getFuture()

std::shared_future< tl::expected< bool, std::string > > & moveit_pro::behaviors::ComputeInverseKinematics::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 69 of file compute_inverse_kinematics.hpp.

Private Member Attributes

contact_namespaces_

std::set<std::string> moveit_pro::behaviors::ComputeInverseKinematics::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 80 of file compute_inverse_kinematics.hpp.

future_

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

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

Definition at line 83 of file compute_inverse_kinematics.hpp.

markers_publisher_

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

Definition at line 76 of file compute_inverse_kinematics.hpp.

Public Static Functions

metadata()

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

Declaration at line 64 of file compute_inverse_kinematics.hpp, definition at line 205 of file compute_inverse_kinematics.cpp.

providedPorts()

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

Declaration at line 62 of file compute_inverse_kinematics.hpp, definition at line 156 of file compute_inverse_kinematics.cpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.