@@ -91,43 +91,40 @@ IKSolutions IKFastInvKin::calcInvKin(const Eigen::Isometry3d& pose, const Eigen:
9191
9292 // Check the output
9393 int num_sol = sols.size () / ikfast_dof;
94- std::vector< double > solution_set;
94+ IKSolutions solution_set;
9595 solution_set.reserve (sols.size ());
9696 for (int i = 0 ; i < num_sol; i++)
9797 {
98- double * sol = sols.data () + ikfast_dof * i;
99- if (isValid< double >(sol, ikfast_dof ))
98+ Eigen::Map<Eigen::VectorXd> eigen_sol ( sols.data () + ikfast_dof * i, static_cast <Eigen::Index>(ikfast_dof)) ;
99+ if (eigen_sol. array (). allFinite ( ))
100100 {
101- harmonizeTowardZero<double >(sol, ikfast_dof ); // Modifies 'sol' in place
101+ harmonizeTowardZero<double >(eigen_sol ); // Modifies 'sol' in place
102102
103103 // Add solution
104- if (isWithinLimits<double >(Eigen::Map<Eigen::VectorXd>(sol, ikfast_dof) , limits_.joint_limits ))
105- solution_set.insert ( end (solution_set), sol, sol + ikfast_dof );
104+ if (isWithinLimits<double >(eigen_sol , limits_.joint_limits ))
105+ solution_set.push_back (eigen_sol );
106106
107107 // Add redundant solutions
108- std::vector< double > redundant_sols = getRedundantSolutions (sol , limits_.joint_limits );
108+ IKSolutions redundant_sols = getRedundantSolutions< double >(eigen_sol , limits_.joint_limits );
109109 if (!redundant_sols.empty ())
110110 {
111- int num_sol = redundant_sols.size () / ikfast_dof;
112- for (int s = 0 ; s < num_sol; ++s)
113- {
114- double * redundant_sol = redundant_sols.data () + ikfast_dof * s;
115- solution_set.insert (end (solution_set),
116- std::make_move_iterator (redundant_sol),
117- std::make_move_iterator (redundant_sol + ikfast_dof));
118- }
111+ solution_set.insert (end (solution_set),
112+ std::make_move_iterator (redundant_sols.begin ()),
113+ std::make_move_iterator (redundant_sols.end ()));
119114 }
120115 }
121116 }
122117
123- solutions = Eigen::Map<Eigen::VectorXd>(solution_set.data (), solution_set.size ());
124- return !solution_set.empty ();
118+ return solution_set;
125119}
126120
127121IKSolutions IKFastInvKin::calcInvKin (const Eigen::Isometry3d& pose,
128122 const Eigen::Ref<const Eigen::VectorXd>& seed,
129123 const std::string& link_name) const
130124{
125+ if (link_name == tip_link_name_)
126+ return calcInvKin (pose, seed);
127+
131128 throw std::runtime_error (" IKFastInvKin::calcInvKin(Eigen::VectorXd&, const Eigen::Isometry3d&, const "
132129 " Eigen::Ref<const Eigen::VectorXd>&, const std::string&) Not Supported!" );
133130}
0 commit comments