26#ifndef TESSERACT_KINEMATICS_IMPL_IKFAST_INV_KIN_HPP
27#define TESSERACT_KINEMATICS_IMPL_IKFAST_INV_KIN_HPP
29#ifndef IKFAST_HAS_LIBRARY
30#define IKFAST_HAS_LIBRARY
37#include <console_bridge/console.h>
49 std::vector<Eigen::Index> redundancy_capable_joints,
50 std::string solver_name,
55 , redundancy_capable_joints_(std::move(redundancy_capable_joints))
56 , solver_name_(std::move(solver_name))
78 const Eigen::Ref<const Eigen::VectorXd>& )
const
80 assert(tip_link_poses.size() == 1);
81 assert(tip_link_poses.find(
tip_link_name_) != tip_link_poses.end());
82 assert(std::abs(1.0 - tip_link_poses.at(
tip_link_name_).matrix().determinant()) < 1e-6);
87 Eigen::Transform<IkReal, 3, Eigen::Isometry> ikfast_tcp =
pose.cast<IkReal>();
90 const Eigen::Matrix<IkReal, 3, 1>
translation = ikfast_tcp.translation();
94 const Eigen::Matrix<IkReal, 3, 3, Eigen::RowMajor> rotation = ikfast_tcp.rotation();
96 auto ikfast_dof =
static_cast<std::size_t
>(
numJoints());
100 std::vector<double> sols;
103 auto addSols = [&](
const double* pfree) {
109 std::vector<IkReal> ikfast_output;
110 ikfast_output.resize(n_sols * ikfast_dof);
112 for (std::size_t i = 0; i < n_sols; ++i)
115 const auto& sol = ikfast_solution_set.
GetSolution(i);
116 auto* out = ikfast_output.data() + i * ikfast_dof;
117 sol.GetSolution(out, pfree);
121 end(sols), std::make_move_iterator(ikfast_output.begin()), std::make_move_iterator(ikfast_output.end()));
128 addSols(j_combo.data());
137 std::size_t num_sol = sols.size() / ikfast_dof;
139 solution_set.reserve(sols.size());
140 for (std::size_t i = 0; i < num_sol; i++)
142 Eigen::Map<Eigen::VectorXd> eigen_sol(sols.data() + ikfast_dof * i,
static_cast<Eigen::Index
>(ikfast_dof));
143 if (eigen_sol.array().allFinite())
146 solution_set.push_back(eigen_sol);
160inline std::vector<std::vector<double>>
164 std::vector<std::size_t> curr_joint_indices(free_joint_samples.size(), 0);
165 while (curr_joint_indices.front() < free_joint_samples.front().size())
167 std::vector<double> curr_joint_values;
168 for (std::size_t i = 0; i < curr_joint_indices.size(); ++i)
169 curr_joint_values.push_back(free_joint_samples[i][curr_joint_indices[i]]);
171 curr_joint_indices.back()++;
172 for (std::size_t i = curr_joint_indices.size() - 1; i > 0; --i)
174 if (curr_joint_indices[i] == free_joint_samples[i].size())
176 curr_joint_indices[i] = 0;
177 curr_joint_indices[i - 1]++;
IKFAST_API int GetNumJoints()
Definition: abb_irb2400_ikfast_solver.hpp:381
IKFAST_API bool ComputeIk(const IkReal *eetrans, const IkReal *eerot, const IkReal *pfree, IkSolutionListBase< IkReal > &solutions)
Definition: abb_irb2400_ikfast_solver.hpp:3210
Default implementation of IkSolutionListBase.
Definition: ikfast.h:259
const IkSolutionBase< T > & GetSolution(size_t index) const override
returns the solution pointer
Definition: ikfast.h:268
size_t GetNumSolutions() const override
returns the number of solutions stored
Definition: ikfast.h:279
IKFast Inverse Kinematics Implmentation.
Definition: ikfast_inv_kin.h:78
std::string getWorkingFrame() const override
Get the inverse kinematics working frame.
Definition: ikfast_inv_kin.hpp:156
std::vector< std::vector< double > > free_joint_states_
Definition: ikfast_inv_kin.h:139
std::vector< Eigen::Index > redundancy_capable_joints_
Definition: ikfast_inv_kin.h:135
static std::vector< std::vector< double > > generateAllFreeJointStateCombinations(const std::vector< std::vector< double > > &free_joint_samples)
Generates all possible combinations of joint states and stores it to the free_joint_states_ class mem...
Definition: ikfast_inv_kin.hpp:161
std::vector< std::string > joint_names_
Joint names for the kinematic object.
Definition: ikfast_inv_kin.h:134
Eigen::Index numJoints() const override
Number of joints in robot.
Definition: ikfast_inv_kin.hpp:153
std::string base_link_name_
Link name of first link in the kinematic object.
Definition: ikfast_inv_kin.h:132
IKSolutions calcInvKin(const tesseract_common::TransformMap &tip_link_poses, const Eigen::Ref< const Eigen::VectorXd > &seed) const override
Calculates joint solutions given a pose for each tip link.
Definition: ikfast_inv_kin.hpp:77
IKFastInvKin(const IKFastInvKin &other)
Definition: ikfast_inv_kin.hpp:63
std::string solver_name_
Redundancy capable joints.
Definition: ikfast_inv_kin.h:136
std::vector< std::string > getJointNames() const override
Get list of joint names for kinematic object.
Definition: ikfast_inv_kin.hpp:154
IKFastInvKin & operator=(const IKFastInvKin &other)
Definition: ikfast_inv_kin.hpp:65
std::string getBaseLinkName() const override
Get the robot base link name.
Definition: ikfast_inv_kin.hpp:155
InverseKinematics::UPtr clone() const override
Clone the forward kinematics object.
Definition: ikfast_inv_kin.hpp:61
std::vector< std::string > getTipLinkNames() const override
Get the names of the tip links of the kinematics group.
Definition: ikfast_inv_kin.hpp:157
std::string getSolverName() const override
Get the name of the solver. Recommend using the name of the class.
Definition: ikfast_inv_kin.hpp:158
std::string tip_link_name_
Link name of last kink in the kinematic object.
Definition: ikfast_inv_kin.h:133
std::unique_ptr< InverseKinematics > UPtr
Definition: inverse_kinematics.h:55
Tesseract IKFast Inverse kinematics Wrapper.
std::string base_link_name
Definition: ikfast_kinematics_7dof_unit.cpp:52
std::string tip_link_name
Definition: ikfast_kinematics_7dof_unit.cpp:53
std::vector< std::vector< double > > free_joint_states
Definition: ikfast_kinematics_7dof_unit.cpp:58
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
Definition: types.h:66
Definition: forward_kinematics.h:44
std::vector< Eigen::VectorXd > IKSolutions
The inverse kinematics solutions container.
Definition: types.h:41
joint_state joint_names
Definition: tesseract_common_serialization_unit.cpp:75
auto pose
Definition: tesseract_environment_collision.cpp:118
Kinematics utility functions.