Skip to main content

pose_ik Namespace

Definition​

namespace pose_ik { ... }

Classes Index​

structPoseTarget
structWholeBodyConfiguration

Typedefs Index​

usingIKValidationFunction = std::function< bool(const Eigen::VectorXd &solution)>
usingWholeBodyValidationFunction = std::function< bool(const Eigen::VectorXd &joint_positions, const Eigen::Isometry3d &robot_pose)>

Validates a candidate of solveWholeBodyIK(): its joint positions and its robot pose. More...

Functions Index​

boolemptyValidationFunction (const Eigen::VectorXd &)
tl::expected< Eigen::VectorXd, std::string >solveIK (moveit_pro::base::RobotState &robot_state, const moveit_pro::base::JointModelGroup &group, const std::vector< PoseTarget > &targets, const Eigen::VectorXd &seed, const rclcpp::Duration &timeout, const IKValidationFunction &validation_fn, const Params &params)

Computes pose inverse kinematics for the given group and set of targets. More...

tl::expected< WholeBodyConfiguration, std::string >solveWholeBodyIK (moveit_pro::base::RobotState &robot_state, const moveit_pro::base::JointModelGroup &group, const std::vector< PoseTarget > &targets, const WholeBodyConfiguration &seed, const rclcpp::Duration &timeout, const WholeBodyValidationFunction &validation_fn, const Params &params)

Computes pose inverse kinematics for a group that contains the robot's mobile base (JointModelGroup::getMobileBase()), solving for the robot pose as well as the joints. More...

tl::expected< void, std::string >checkPreconditions (const moveit_pro::base::JointModelGroup &group, const std::vector< PoseTarget > &targets, const Eigen::VectorXd &seed)
boolunwindAndCheckLimits (const moveit_pro::base::JointModelGroup &group, std::span< const moveit_pro::base::LinkModel *const > tip_links, Eigen::VectorXd &joint_values)
boolunwindAndCheckLimits (const moveit_pro::base::JointModelGroup &group, Eigen::VectorXd &joint_values)

Variables Index​

constexpr autokSolveModeFirstFound = "first_found"
constexpr autokSolveModeOptimizeDistance = "optimize_distance"
constexpr doublekMaxJointCost = 50.0

Typedefs​

IKValidationFunction​

using pose_ik::IKValidationFunction = std::function<bool(const Eigen::VectorXd& solution)>

Definition at line 57 of file pose_ik.hpp.

WholeBodyValidationFunction​

using pose_ik::WholeBodyValidationFunction = std::function<bool(const Eigen::VectorXd& joint_positions, const Eigen::Isometry3d& robot_pose)>

Validates a candidate of solveWholeBodyIK(): its joint positions and its robot pose.

Definition at line 140 of file pose_ik.hpp.

Functions​

checkPreconditions()​

tl::expected< void, std::string > pose_ik::checkPreconditions (const moveit_pro::base::JointModelGroup & group, const std::vector< PoseTarget > & targets, const Eigen::VectorXd & seed)

Definition at line 809 of file pose_ik.cpp.

emptyValidationFunction()​

bool pose_ik::emptyValidationFunction (const Eigen::VectorXd &)
inline

Definition at line 60 of file pose_ik.hpp.

solveIK()​

tl::expected< Eigen::VectorXd, std::string > pose_ik::solveIK (moveit_pro::base::RobotState & robot_state, const moveit_pro::base::JointModelGroup & group, const std::vector< PoseTarget > & targets, const Eigen::VectorXd & seed, const rclcpp::Duration & timeout, const IKValidationFunction & validation_fn, const Params & params)
nodiscard

Computes pose inverse kinematics for the given group and set of targets.

This implements a Jacobian-based Newton-Raphson IK solver. The random sequence used internally is deterministic: given the same inputs, the solver will always find the same solution.

Groups may contain mimic joints. The solver searches over the group's active joints only — seed and solution are laid out as RobotState::setJointGroupActivePositions() expects — and mimic joints follow their driving joint, both in the forward kinematics and in the Jacobian, so the returned solution places the tips correctly when the mimic joints are applied. A mimic joint's own position limits need no check here: models built through RobotModel::create or the robot model loader reject a mimic mapping that could exceed them (see RobotModel::validateMimicJointLimits).

Parameters
robot_state

A robot state, used to compute FK. Scratch: its final contents are unspecified (it holds whatever configuration gradient descent set last, which can differ from the returned solution by whole turns on continuous joints). Callers must use the returned vector, not this state.

group

The joint model group to compute IK for.

targets

The target poses to compute IK for.

seed

A joint configuration to be used as a first seed, before starting taking random configurations.

timeout

Search timeout in seconds.

validation_fn

Applied to a candidate solution; returning false discards it and the search resumes. It is only ever invoked with a configuration that has already converged on targets, so a candidate it refuses is one that reached them and was rejected. Callers can rely on that to tell a target that was unreachable from one that was reachable and unacceptable — a distinction the returned error message does not carry. It follows that an unreachable target never invokes it at all.

params

Other IK parameters like tolerance, etc. params.joint_costs optionally holds one cost multiplier per active joint of group, in JointModelGroup::getActiveJointModelNames() order. A joint's cost scales how expensive it is to move away from seed, so raising it biases the solver toward solutions that move that joint less. Every entry must be finite and at least 1.0, the unbiased baseline; an empty list means "no bias", and kMaxJointCost is the accepted maximum — see that constant for why. Prefer the smallest cost that produces the bias you want. Costs only take effect when params.solve_mode is optimize_distance — see the error note below.

Returns

a joint-space solution that brings tip_link to root_pose_tip, or an error message if the preconditions are not met. Continuous revolute joints in the solution are aligned to seed's winding: each is shifted by whole 2*pi turns to land within half a turn of the seed value, so a solution stays consistent with the physical robot state the solve was seeded from even when it was found from a random restart. The one exception is a continuous joint that drives mimic joints, which is returned as solved: shifting the driver can change the pose of the links downstream of the mimic. Position bounds set on a continuous joint are dropped by the model, so it never enters the position-limit pass; a bounded revolute joint does, and is unwound into range only under the mimic rule documented on unwindAndCheckLimits below. On such groups a solution's winding can still come back a whole number of turns from the seed. Supplying non-empty params.joint_costs with params.solve_mode == "first_found" is an error rather than a no-op: that mode returns the first valid solution without ranking candidates, so the costs would otherwise be silently discarded. For the same reason, non-empty costs combined with a params.optimization_distance_gain that is not finite and strictly positive are also an error: zero flattens every candidate's cost, and a negative gain reverses the bias. That gain remains valid at zero when no costs are supplied, which is what the parameter's own validation allows.

Definition at line 815 of file pose_ik.cpp.

solveWholeBodyIK()​

tl::expected< WholeBodyConfiguration, std::string > pose_ik::solveWholeBodyIK (moveit_pro::base::RobotState & robot_state, const moveit_pro::base::JointModelGroup & group, const std::vector< PoseTarget > & targets, const WholeBodyConfiguration & seed, const rclcpp::Duration & timeout, const WholeBodyValidationFunction & validation_fn, const Params & params)
nodiscard

Computes pose inverse kinematics for a group that contains the robot's mobile base (JointModelGroup::getMobileBase()), solving for the robot pose as well as the joints.

The solver looks for a goal configuration, not a path to it, so it moves the base through its planar pose (x, y and yaw in the model frame) whatever its drive: a differential drive can reach any planar pose, and reaching it is the planner's or navigation stack's task. The robot pose keeps the height, roll and pitch of the seed's. The wheels take no part: the solution keeps their seed values.

Otherwise like solveIK(), with the same parameters, modes and errors, and these differences:

  • targets are in the robot model's frame, which getRootFrameName() names for such a group.
  • Random restarts draw new arm joints and start the base from the seed's robot pose.
  • In optimize_distance mode, the distance from the seed covers the base's x and y in m and its yaw change in rad, wrapped to [-pi, pi], each with cost 1.0. params.joint_costs still holds one entry per active joint, wheels included; a wheel's entry must be 1.0, since the wheels do not move. Raising the arm's costs makes the solver prefer moving the base.
Parameters
seed

The joint positions and robot pose the solve starts from, usually the current ones. The robot pose must be finite.

validation_fn

Called like solveIK()'s, with the candidate's robot pose as well.

Returns

The joint positions and robot pose, or an error: also for a group without the robot's mobile base (use solveIK()), and for a tip that a wheel turns.

Definition at line 892 of file pose_ik.cpp.

unwindAndCheckLimits()​

bool pose_ik::unwindAndCheckLimits (const moveit_pro::base::JointModelGroup & group, std::span< const moveit_pro::base::LinkModel *const > tip_links, Eigen::VectorXd & joint_values)

Definition at line 693 of file pose_ik.cpp.

unwindAndCheckLimits()​

bool pose_ik::unwindAndCheckLimits (const moveit_pro::base::JointModelGroup & group, Eigen::VectorXd & joint_values)

Definition at line 707 of file pose_ik.cpp.

Variables​

kMaxJointCost​

double pose_ik::kMaxJointCost = 50.0
constexpr

Definition at line 53 of file pose_ik.hpp.

kSolveModeFirstFound​

auto pose_ik::kSolveModeFirstFound = "first_found"
constexpr

Definition at line 29 of file pose_ik.hpp.

kSolveModeOptimizeDistance​

auto pose_ik::kSolveModeOptimizeDistance = "optimize_distance"
constexpr

Definition at line 30 of file pose_ik.hpp.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.15.0.