40 #include <rclcpp/rclcpp.hpp>
41 #include <random_numbers/random_numbers.h>
44 #include <geometry_msgs/msg/pose.hpp>
45 #include <moveit_msgs/srv/get_position_fk.hpp>
46 #include <moveit_msgs/srv/get_position_ik.hpp>
47 #include <moveit_msgs/msg/kinematic_solver_info.hpp>
48 #include <moveit_msgs/msg/move_it_error_codes.hpp>
51 #include <kdl/config.h>
52 #include <kdl/chainfksolver.hpp>
53 #include <kdl/chainiksolver.hpp>
75 getPositionIK(
const geometry_msgs::msg::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
76 std::vector<double>& solution, moveit_msgs::msg::MoveItErrorCodes& error_code,
80 const geometry_msgs::msg::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
81 std::vector<double>& solution, moveit_msgs::msg::MoveItErrorCodes& error_code,
85 const geometry_msgs::msg::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
86 const std::vector<double>& consistency_limits, std::vector<double>& solution,
87 moveit_msgs::msg::MoveItErrorCodes& error_code,
91 const geometry_msgs::msg::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
92 std::vector<double>& solution,
const IKCallbackFn& solution_callback,
93 moveit_msgs::msg::MoveItErrorCodes& error_code,
97 const geometry_msgs::msg::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
98 const std::vector<double>& consistency_limits, std::vector<double>& solution,
99 const IKCallbackFn& solution_callback, moveit_msgs::msg::MoveItErrorCodes& error_code,
102 bool getPositionFK(
const std::vector<std::string>& link_names,
const std::vector<double>& joint_angles,
103 std::vector<geometry_msgs::msg::Pose>& poses)
const override;
106 const std::string& group_name,
const std::string& base_frame,
107 const std::vector<std::string>& tip_frames,
double search_discretization)
override;
112 const std::vector<std::string>&
getJointNames()
const override;
117 const std::vector<std::string>&
getLinkNames()
const override;
120 bool timedOut(
const rclcpp::Time& start_time,
double duration)
const;
128 bool checkConsistency(
const Eigen::VectorXd& seed_state,
const std::vector<double>& consistency_limits,
129 const Eigen::VectorXd& solution)
const;
131 bool obeysLimits(
const Eigen::VectorXd& values)
const;
133 void harmonize(Eigen::VectorXd& values)
const;
135 void getRandomConfiguration(Eigen::VectorXd& jnt_array)
const;
142 void getRandomConfiguration(
const Eigen::VectorXd& seed_state,
const std::vector<double>& consistency_limits,
143 Eigen::VectorXd& jnt_array)
const;
147 unsigned int dimension_;
148 moveit_msgs::msg::KinematicSolverInfo solver_info_;
151 moveit::core::RobotStatePtr state_;
152 KDL::Chain kdl_chain_;
153 std::unique_ptr<KDL::ChainFkSolverPos> fk_solver_;
154 std::vector<const moveit::core::JointModel*> joints_;
155 std::vector<std::string> joint_names_;
156 rclcpp::Node::SharedPtr node_;
158 int max_solver_iterations_;
165 double orientation_vs_position_weight_;
Provides an interface for kinematics solvers.
std::function< void(const geometry_msgs::msg::Pose &, const std::vector< double > &, moveit_msgs::msg::MoveItErrorCodes &)> IKCallbackFn
Signature for a callback to validate an IK solution. Typically used for collision checking.
Implementation of kinematics using Levenberg-Marquardt (LMA) solver from KDL. This version supports a...
const std::vector< std::string > & getJointNames() const override
Return all the joint names in the order they are used internally.
LMAKinematicsPlugin()
Default constructor.
bool initialize(const rclcpp::Node::SharedPtr &node, const moveit::core::RobotModel &robot_model, const std::string &group_name, const std::string &base_frame, const std::vector< std::string > &tip_frames, double search_discretization) override
Initialization function for the kinematics, for use with kinematic chain IK solvers.
bool getPositionIK(const geometry_msgs::msg::Pose &ik_pose, const std::vector< double > &ik_seed_state, std::vector< double > &solution, moveit_msgs::msg::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions()) const override
Given a desired pose of the end-effector, compute the joint angles to reach it.
bool getPositionFK(const std::vector< std::string > &link_names, const std::vector< double > &joint_angles, std::vector< geometry_msgs::msg::Pose > &poses) const override
Given a set of joint angles and a set of links, compute their pose.
bool searchPositionIK(const geometry_msgs::msg::Pose &ik_pose, const std::vector< double > &ik_seed_state, double timeout, std::vector< double > &solution, moveit_msgs::msg::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions()) const override
Given a desired pose of the end-effector, search for the joint angles required to reach it....
const std::vector< std::string > & getLinkNames() const override
Return all the link names in the order they are represented internally.
Definition of a kinematic model. This class is not thread safe, however multiple instances can be cre...
A set of options for the kinematics solver.