opw_inv_kin.cpp
Go to the documentation of this file.
1 
28 #include <stdexcept>
29 #include <console_bridge/console.h>
33 
36 
37 namespace tesseract_kinematics
38 {
40  std::string base_link_name,
41  std::string tip_link_name,
42  std::vector<std::string> joint_names,
43  std::string solver_name)
44  : params_(params)
45  , base_link_name_(std::move(base_link_name))
46  , tip_link_name_(std::move(tip_link_name))
47  , joint_names_(std::move(joint_names))
48  , solver_name_(std::move(solver_name))
49 {
50  if (joint_names_.size() != 6)
51  throw std::runtime_error("OPWInvKin, only support six joints!");
52 }
53 
54 InverseKinematics::UPtr OPWInvKin::clone() const { return std::make_unique<OPWInvKin>(*this); }
55 
56 OPWInvKin::OPWInvKin(const OPWInvKin& other) { *this = other; }
57 
59 {
62  joint_names_ = other.joint_names_;
63  params_ = other.params_;
64  solver_name_ = other.solver_name_;
65  return *this;
66 }
67 
69  const Eigen::Ref<const Eigen::VectorXd>& /*seed*/) const
70 {
71  assert(tip_link_poses.size() == 1); // NOLINT
72  assert(tip_link_poses.find(tip_link_name_) != tip_link_poses.end()); // NOLINT
73  assert(std::abs(1.0 - tip_link_poses.at(tip_link_name_).matrix().determinant()) < 1e-6); // NOLINT
74 
75  // NOLINTNEXTLINE
77 
78  // Check the output
79  IKSolutions solution_set;
80  solution_set.reserve(sols.size());
81  for (auto& sol : sols)
82  {
83  if (opw_kinematics::isValid<double>(sol))
84  solution_set.emplace_back(Eigen::Map<Eigen::VectorXd>(sol.data(), static_cast<Eigen::Index>(sol.size())));
85  }
86 
87  return solution_set;
88 }
89 
90 Eigen::Index OPWInvKin::numJoints() const { return 6; }
91 
92 std::vector<std::string> OPWInvKin::getJointNames() const { return joint_names_; }
93 std::string OPWInvKin::getBaseLinkName() const { return base_link_name_; }
94 std::string OPWInvKin::getWorkingFrame() const { return base_link_name_; }
95 std::vector<std::string> OPWInvKin::getTipLinkNames() const { return { tip_link_name_ }; }
96 std::string OPWInvKin::getSolverName() const { return solver_name_; }
97 
98 } // namespace tesseract_kinematics
tesseract_kinematics::OPWInvKin::params_
opw_kinematics::Parameters< double > params_
The opw kinematics parameters.
Definition: opw_inv_kin.h:85
tesseract_kinematics::OPWInvKin::getWorkingFrame
std::string getWorkingFrame() const override final
Get the inverse kinematics working frame.
Definition: opw_inv_kin.cpp:94
opw_utilities.h
tesseract_kinematics::OPWInvKin::getBaseLinkName
std::string getBaseLinkName() const override final
Get the robot base link name.
Definition: opw_inv_kin.cpp:93
tesseract_common::TransformMap
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
tesseract_kinematics::OPWInvKin::base_link_name_
std::string base_link_name_
Link name of first link in the kinematic object.
Definition: opw_inv_kin.h:86
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_kinematics::OPWInvKin::numJoints
Eigen::Index numJoints() const override final
Number of joints in robot.
Definition: opw_inv_kin.cpp:90
opw_kinematics::Solutions
std::array< std::array< T, 6 >, 8 > Solutions
tesseract_kinematics::OPWInvKin::OPWInvKin
OPWInvKin(const OPWInvKin &other)
Definition: opw_inv_kin.cpp:56
tesseract_kinematics::OPWInvKin::tip_link_name_
std::string tip_link_name_
Link name of last kink in the kinematic object.
Definition: opw_inv_kin.h:87
tesseract_kinematics::InverseKinematics::UPtr
std::unique_ptr< InverseKinematics > UPtr
Definition: inverse_kinematics.h:52
utils.h
Kinematics utility functions.
tesseract_kinematics::OPWInvKin::getTipLinkNames
std::vector< std::string > getTipLinkNames() const override final
Get the names of the tip links of the kinematics group.
Definition: opw_inv_kin.cpp:95
opw_inv_kin.h
Tesseract OPW Inverse kinematics Wrapper.
tesseract_kinematics::OPWInvKin::solver_name_
std::string solver_name_
Name of this solver.
Definition: opw_inv_kin.h:89
tesseract_kinematics::OPWInvKin::calcInvKin
IKSolutions calcInvKin(const tesseract_common::TransformMap &tip_link_poses, const Eigen::Ref< const Eigen::VectorXd > &seed) const override final
Calculates joint solutions given a pose for each tip link.
Definition: opw_inv_kin.cpp:68
opw_kinematics::inverse
Solutions< T > inverse(const Parameters< T > &params, const Transform< T > &pose) noexcept
tesseract_kinematics::OPWInvKin::getJointNames
std::vector< std::string > getJointNames() const override final
Get list of joint names for kinematic object.
Definition: opw_inv_kin.cpp:92
tesseract_kinematics::OPWInvKin::operator=
OPWInvKin & operator=(const OPWInvKin &other)
Definition: opw_inv_kin.cpp:58
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_kinematics::OPWInvKin::getSolverName
std::string getSolverName() const override final
Get the name of the solver. Recommend using the name of the class.
Definition: opw_inv_kin.cpp:96
tesseract_kinematics
Definition: forward_kinematics.h:40
tesseract_kinematics::OPWInvKin::clone
InverseKinematics::UPtr clone() const override final
Clone the forward kinematics object.
Definition: opw_inv_kin.cpp:54
opw_kinematics::Parameters< double >
tesseract_kinematics::IKSolutions
std::vector< Eigen::VectorXd > IKSolutions
The inverse kinematics solutions container.
Definition: types.h:38
macros.h
opw_kinematics.h
tesseract_kinematics::OPWInvKin::joint_names_
std::vector< std::string > joint_names_
Joint names for the kinematic object.
Definition: opw_inv_kin.h:88
tesseract_kinematics::OPWInvKin
OPW Inverse Kinematics Implementation.
Definition: opw_inv_kin.h:41


tesseract_kinematics
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:14