kdl_state_solver.h
Go to the documentation of this file.
1 
26 #ifndef TESSERACT_STATE_SOLVER_KDL_STATE_SOLVER_H
27 #define TESSERACT_STATE_SOLVER_KDL_STATE_SOLVER_H
28 
31 #include <kdl/tree.hpp>
32 #include <kdl/jntarray.hpp>
33 #include <kdl/treejnttojacsolver.hpp>
34 #include <mutex>
36 
41 
42 namespace tesseract_scene_graph
43 {
45 {
46 public:
47  using Ptr = std::shared_ptr<KDLStateSolver>;
48  using ConstPtr = std::shared_ptr<const KDLStateSolver>;
49  using UPtr = std::unique_ptr<KDLStateSolver>;
50  using ConstUPtr = std::unique_ptr<const KDLStateSolver>;
51 
54  ~KDLStateSolver() override = default;
55  KDLStateSolver(const KDLStateSolver& other);
57  KDLStateSolver(KDLStateSolver&&) = delete;
59 
60  StateSolver::UPtr clone() const override;
61 
62  void setState(const Eigen::Ref<const Eigen::VectorXd>& joint_values,
63  const tesseract_common::TransformMap& floating_joint_values = {}) override final;
64  void setState(const std::unordered_map<std::string, double>& joint_values,
65  const tesseract_common::TransformMap& floating_joint_values = {}) override final;
66  void setState(const std::vector<std::string>& joint_names,
67  const Eigen::Ref<const Eigen::VectorXd>& joint_values,
68  const tesseract_common::TransformMap& floating_joint_values = {}) override final;
69  void setState(const tesseract_common::TransformMap& floating_joint_values) override final;
70 
71  SceneState getState(const Eigen::Ref<const Eigen::VectorXd>& joint_values,
72  const tesseract_common::TransformMap& floating_joint_values = {}) const override final;
73  SceneState getState(const std::unordered_map<std::string, double>& joint_values,
74  const tesseract_common::TransformMap& floating_joint_values = {}) const override final;
75  SceneState getState(const std::vector<std::string>& joint_names,
76  const Eigen::Ref<const Eigen::VectorXd>& joint_values,
77  const tesseract_common::TransformMap& floating_joint_values = {}) const override final;
78  SceneState getState(const tesseract_common::TransformMap& floating_joint_values) const override final;
79 
80  SceneState getState() const override final;
81 
82  SceneState getRandomState() const override final;
83 
84  Eigen::MatrixXd getJacobian(const Eigen::Ref<const Eigen::VectorXd>& joint_values,
85  const std::string& link_name,
86  const tesseract_common::TransformMap& floating_joint_values = {}) const override final;
87 
88  Eigen::MatrixXd getJacobian(const std::unordered_map<std::string, double>& joint_values,
89  const std::string& link_name,
90  const tesseract_common::TransformMap& floating_joint_values = {}) const override final;
91  Eigen::MatrixXd getJacobian(const std::vector<std::string>& joint_names,
92  const Eigen::Ref<const Eigen::VectorXd>& joint_values,
93  const std::string& link_name,
94  const tesseract_common::TransformMap& floating_joint_values = {}) const override final;
95 
96  std::vector<std::string> getJointNames() const override final;
97 
98  std::vector<std::string> getFloatingJointNames() const override final;
99 
100  std::vector<std::string> getActiveJointNames() const override final;
101 
102  std::string getBaseLinkName() const override final;
103 
104  std::vector<std::string> getLinkNames() const override final;
105 
106  std::vector<std::string> getActiveLinkNames() const override final;
107 
108  std::vector<std::string> getStaticLinkNames() const override final;
109 
110  bool isActiveLinkName(const std::string& link_name) const override final;
111 
112  bool hasLinkName(const std::string& link_name) const override final;
113 
114  tesseract_common::VectorIsometry3d getLinkTransforms() const override final;
115 
116  Eigen::Isometry3d getLinkTransform(const std::string& link_name) const override final;
117 
118  Eigen::Isometry3d getRelativeLinkTransform(const std::string& from_link_name,
119  const std::string& to_link_name) const override final;
120 
121  tesseract_common::KinematicLimits getLimits() const override final;
122 
123 private:
126  std::unique_ptr<KDL::TreeJntToJacSolver> jac_solver_;
127  std::unordered_map<std::string, unsigned int> joint_to_qnr_;
128  std::vector<int> joint_qnr_;
129  KDL::JntArray kdl_jnt_array_;
130  tesseract_common::KinematicLimits limits_;
131  mutable std::mutex mutex_;
133  void calculateTransforms(SceneState& state,
134  const KDL::JntArray& q_in,
135  const KDL::SegmentMap::const_iterator& it,
136  const Eigen::Isometry3d& parent_frame) const;
137 
139  const KDL::JntArray& q_in,
140  const KDL::SegmentMap::const_iterator& it,
141  const Eigen::Isometry3d& parent_frame) const;
142 
143  bool setJointValuesHelper(KDL::JntArray& q, const std::string& joint_name, const double& joint_value) const;
144 
145  bool calcJacobianHelper(KDL::Jacobian& jacobian, const KDL::JntArray& kdl_joints, const std::string& link_name) const;
146 
148  KDL::JntArray getKDLJntArray(const std::vector<std::string>& joint_names,
149  const Eigen::Ref<const Eigen::VectorXd>& joint_values) const;
150  KDL::JntArray getKDLJntArray(const std::unordered_map<std::string, double>& joint_values) const;
151 
152  bool processKDLData(const tesseract_scene_graph::SceneGraph& scene_graph);
153 };
154 
155 } // namespace tesseract_scene_graph
156 #endif // TESSERACT_STATE_SOLVER_KDL_STATE_SOLVER_H
tesseract_scene_graph::KDLStateSolver::ConstPtr
std::shared_ptr< const KDLStateSolver > ConstPtr
Definition: kdl_state_solver.h:48
VectorIsometry3d
AlignedVector< Eigen::Isometry3d > VectorIsometry3d
tesseract_scene_graph::KDLStateSolver::getState
SceneState getState() const override final
Get the current state of the scene.
Definition: kdl_state_solver.cpp:180
tesseract_scene_graph::KDLStateSolver::ConstUPtr
std::unique_ptr< const KDLStateSolver > ConstUPtr
Definition: kdl_state_solver.h:50
tesseract_scene_graph::KDLStateSolver::calculateTransforms
void calculateTransforms(SceneState &state, const KDL::JntArray &q_in, const KDL::SegmentMap::const_iterator &it, const Eigen::Isometry3d &parent_frame) const
Definition: kdl_state_solver.cpp:361
state_solver.h
Tesseract Scene Graph State Solver Interface.
tesseract_scene_graph::KDLStateSolver::getLinkTransforms
tesseract_common::VectorIsometry3d getLinkTransforms() const override final
Get all of the links transforms.
Definition: kdl_state_solver.cpp:251
tesseract_scene_graph::KDLStateSolver::getLimits
tesseract_common::KinematicLimits getLimits() const override final
Getter for kinematic limits.
Definition: kdl_state_solver.cpp:272
tesseract_common
tesseract_scene_graph::KDLStateSolver::mutex_
std::mutex mutex_
KDL is not thread safe due to mutable variables in Joint Class.
Definition: kdl_state_solver.h:131
tesseract_scene_graph::KDLStateSolver::setJointValuesHelper
bool setJointValuesHelper(KDL::JntArray &q, const std::string &joint_name, const double &joint_value) const
Definition: kdl_state_solver.cpp:319
tesseract_scene_graph::KDLStateSolver::getJacobian
Eigen::MatrixXd getJacobian(const Eigen::Ref< const Eigen::VectorXd > &joint_values, const std::string &link_name, const tesseract_common::TransformMap &floating_joint_values={}) const override final
Get the jacobian of the solver given the joint values.
Definition: kdl_state_solver.cpp:188
tesseract_scene_graph::KDLStateSolver::isActiveLinkName
bool isActiveLinkName(const std::string &link_name) const override final
Check if link is an active link.
Definition: kdl_state_solver.cpp:240
tesseract_scene_graph::KDLStateSolver::joint_qnr_
std::vector< int > joint_qnr_
Definition: kdl_state_solver.h:128
tesseract_scene_graph::KDLStateSolver::hasLinkName
bool hasLinkName(const std::string &link_name) const override final
Check if link name exists.
Definition: kdl_state_solver.cpp:246
tesseract_scene_graph::KDLStateSolver::calculateTransformsHelper
void calculateTransformsHelper(SceneState &state, const KDL::JntArray &q_in, const KDL::SegmentMap::const_iterator &it, const Eigen::Isometry3d &parent_frame) const
Definition: kdl_state_solver.cpp:334
tesseract_scene_graph::KDLStateSolver::getActiveLinkNames
std::vector< std::string > getActiveLinkNames() const override final
Get the vector of active link names.
Definition: kdl_state_solver.cpp:236
tesseract_common::TransformMap
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
tesseract_scene_graph::KDLStateSolver::getLinkTransform
Eigen::Isometry3d getLinkTransform(const std::string &link_name) const override final
Get the transform corresponding to the link.
Definition: kdl_state_solver.cpp:261
tesseract_scene_graph::KDLStateSolver::~KDLStateSolver
~KDLStateSolver() override=default
tesseract_scene_graph::KDLStateSolver::UPtr
std::unique_ptr< KDLStateSolver > UPtr
Definition: kdl_state_solver.h:49
tesseract_scene_graph::StateSolver
Definition: state_solver.h:45
kinematic_limits.h
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::SceneGraph
tesseract_scene_graph::KDLStateSolver::data_
KDLTreeData data_
Definition: kdl_state_solver.h:125
tesseract_scene_graph::SceneState
tesseract_scene_graph::KDLStateSolver::current_state_
SceneState current_state_
Definition: kdl_state_solver.h:124
tesseract_scene_graph::KDLStateSolver::joint_to_qnr_
std::unordered_map< std::string, unsigned int > joint_to_qnr_
Definition: kdl_state_solver.h:127
kdl_parser.h
tesseract_scene_graph::KDLStateSolver::limits_
tesseract_common::KinematicLimits limits_
Definition: kdl_state_solver.h:130
tesseract_scene_graph::KDLStateSolver::getJointNames
std::vector< std::string > getJointNames() const override final
Get the vector of joint names.
Definition: kdl_state_solver.cpp:226
tesseract_scene_graph::KDLStateSolver::getBaseLinkName
std::string getBaseLinkName() const override final
Get the base link name.
Definition: kdl_state_solver.cpp:232
tesseract_scene_graph::KDLStateSolver::Ptr
std::shared_ptr< KDLStateSolver > Ptr
Definition: kdl_state_solver.h:47
tesseract_scene_graph::KDLStateSolver
Definition: kdl_state_solver.h:44
tesseract_scene_graph::KDLStateSolver::getRandomState
SceneState getRandomState() const override final
Get the random state of the environment.
Definition: kdl_state_solver.cpp:182
tesseract_scene_graph::KDLStateSolver::getRelativeLinkTransform
Eigen::Isometry3d getRelativeLinkTransform(const std::string &from_link_name, const std::string &to_link_name) const override final
Get transform between two links using the current state.
Definition: kdl_state_solver.cpp:266
tesseract_scene_graph::KDLStateSolver::operator=
KDLStateSolver & operator=(const KDLStateSolver &other)
Definition: kdl_state_solver.cpp:64
tesseract_scene_graph::KDLStateSolver::KDLStateSolver
KDLStateSolver(const tesseract_scene_graph::SceneGraph &scene_graph)
Definition: kdl_state_solver.cpp:48
tesseract_scene_graph::KDLStateSolver::getFloatingJointNames
std::vector< std::string > getFloatingJointNames() const override final
Get the vector of floating joint names.
Definition: kdl_state_solver.cpp:228
tesseract_scene_graph::KDLTreeData
tesseract_scene_graph::StateSolver::UPtr
std::unique_ptr< StateSolver > UPtr
Definition: state_solver.h:50
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_scene_graph::KDLStateSolver::setState
void setState(const Eigen::Ref< const Eigen::VectorXd > &joint_values, const tesseract_common::TransformMap &floating_joint_values={}) override final
Set the current state of the solver.
Definition: kdl_state_solver.cpp:76
scene_state.h
tesseract_scene_graph::KDLStateSolver::kdl_jnt_array_
KDL::JntArray kdl_jnt_array_
Definition: kdl_state_solver.h:129
tesseract_scene_graph::KDLStateSolver::clone
StateSolver::UPtr clone() const override
This should clone the object so it may be used in a multi threaded application where each thread woul...
Definition: kdl_state_solver.cpp:46
tesseract_scene_graph::KDLStateSolver::getActiveJointNames
std::vector< std::string > getActiveJointNames() const override final
Get the vector of joint names which align with the limits.
Definition: kdl_state_solver.cpp:230
tesseract_scene_graph::KDLStateSolver::calcJacobianHelper
bool calcJacobianHelper(KDL::Jacobian &jacobian, const KDL::JntArray &kdl_joints, const std::string &link_name) const
Definition: kdl_state_solver.cpp:370
tesseract_scene_graph::KDLStateSolver::getKDLJntArray
KDL::JntArray getKDLJntArray(const std::vector< std::string > &joint_names, const Eigen::Ref< const Eigen::VectorXd > &joint_values) const
Get an updated kdl joint array.
Definition: kdl_state_solver.cpp:384
macros.h
tesseract_scene_graph::KDLStateSolver::jac_solver_
std::unique_ptr< KDL::TreeJntToJacSolver > jac_solver_
Definition: kdl_state_solver.h:126
tesseract_scene_graph
tesseract_scene_graph::KDLStateSolver::getLinkNames
std::vector< std::string > getLinkNames() const override final
Get the vector of link names.
Definition: kdl_state_solver.cpp:234
tesseract_scene_graph::KDLStateSolver::getStaticLinkNames
std::vector< std::string > getStaticLinkNames() const override final
Get a vector of static link names in the environment.
Definition: kdl_state_solver.cpp:238
tesseract_scene_graph::KDLStateSolver::processKDLData
bool processKDLData(const tesseract_scene_graph::SceneGraph &scene_graph)
Definition: kdl_state_solver.cpp:274


tesseract_state_solver
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:10