Skip to content

Commit

Permalink
Add pose() as the inverse of transform()
Browse files Browse the repository at this point in the history
refs #228
  • Loading branch information
de-vri-es committed Jul 29, 2016
1 parent 7478522 commit d7eabd8
Showing 1 changed file with 56 additions and 8 deletions.
64 changes: 56 additions & 8 deletions include/dr_kdl/dr_kdl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,66 @@ class KdlTree : public KDL::Tree {
std::string const & end /// The end segment.
) const;

/// Get a transform from one frame to another.
/// Get a pose of one frame relative to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint.
*/
Eigen::Isometry3d pose(
std::string const & source, ///< The source frame.
std::string const & target ///< The target frame.
) const {
return getPose(getChain(source, target));
}

/// Get a pose of one frame relative to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint for which no joint position is given.
*/
Eigen::Isometry3d pose(
std::string const & source, ///< The source frame.
std::string const & target, ///< The target frame.
std::map<std::string, double> const & joints ///< The map holding joint positions.
) const {
return getPose(getChain(source, target), joints);
}

/// Get a pose of one frame relative to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint for which no joint position is given.
*/
Eigen::Isometry3d pose(
std::string const & source, ///< The source frame.
std::string const & target, ///< The target frame.
std::vector<std::string> const & joint_names, ///< The names of the joints in same order as the joint position vector.
std::vector<double> const & joint_positions ///< The positions of the joints in the same order as the joint name vector.
) const {
return getPose(getChain(source, target), joint_names, joint_positions);
}

/// Get a pose of one frame relative to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint for which no joint position is given.
*/
Eigen::Isometry3d pose(
std::string const & source, ///< The source frame.
std::string const & target, ///< The target frame.
sensor_msgs::JointState const & joints ///< The joint positions.
) const {
return getPose(getChain(source, target), joints.name, joints.position);
}

/// Get a transformation that transforms coordinates from one frame to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint.
*/
Eigen::Isometry3d transform(
std::string const & source, ///< The source frame.
std::string const & target ///< The target frame.
) const {
return getPose(getChain(target, source));
return pose(target, source);
}

/// Get a transform from one frame to another.
/// Get a transformation that transforms coordinates from one frame to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint for which no joint position is given.
*/
Expand All @@ -81,10 +129,10 @@ class KdlTree : public KDL::Tree {
std::string const & target, ///< The target frame.
std::map<std::string, double> const & joints ///< The map holding joint positions.
) const {
return getPose(getChain(target, source), joints);
return pose(target, source, joints);
}

/// Get a transform from one frame to another.
/// Get a transformation that transforms coordinates from one frame to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint for which no joint position is given.
*/
Expand All @@ -94,10 +142,10 @@ class KdlTree : public KDL::Tree {
std::vector<std::string> const & joint_names, ///< The names of the joints in same order as the joint position vector.
std::vector<double> const & joint_positions ///< The positions of the joints in the same order as the joint name vector.
) const {
return getPose(getChain(target, source), joint_names, joint_positions);
return pose(target, source, joint_names, joint_positions);
}

/// Get a transform from one frame to another.
/// Get a transformation that transforms coordinates from one frame to another.
/**
* Throws if there is no chain between the frames or the chain contains a non-fixed joint for which no joint position is given.
*/
Expand All @@ -106,7 +154,7 @@ class KdlTree : public KDL::Tree {
std::string const & target, ///< The target frame.
sensor_msgs::JointState const & joints ///< The joint positions.
) const {
return getPose(getChain(target, source), joints.name, joints.position);
return pose(target, source, joints);
}

};
Expand Down

0 comments on commit d7eabd8

Please sign in to comment.