Skip to content

Commit

Permalink
add forward kinematics to robot state
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdavidfagan committed Sep 3, 2022
1 parent 79cdab9 commit b2ed79c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/moveit_py/src/moveit_py/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,19 @@ PYBIND11_MODULE(core, m)
:py:class:`numpy.ndarray`: The accelerations of the joints in the joint model group.
)mydelimiter")

// Forward kinematics
.def("get_global_link_transform", &moveit_py::bind_robot_state::get_global_link_transform,
py::arg("link_name"),
R"mydelimiter(
Returns the transform of the specified link in the global frame.
Args:
link_name (str): The name of the link to get the transform for.
Returns:
:py:class:`numpy.ndarray`: The transform of the specified link in the global frame.
)mydelimiter")

// Setting state from inverse kinematics
.def("set_from_ik", &moveit_py::bind_robot_state::set_from_ik, py::arg("joint_model_group_name"),
py::arg("geometry_pose"), py::arg("tip_name"), py::arg("timeout") = 0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ Eigen::MatrixXd get_frame_transform(std::shared_ptr<moveit::core::RobotState>& r
return transformation.matrix();
}

std::vector<Eigen::MatrixXd> get_global_link_transform(std::shared_ptr<moveit::core::RobotState>& robot_state, std::string& link_name)
{
auto transformation = robot_state->getGlobalLinkTransform(link_name);
std::vector<Eigen::MatrixXd> transforms;
transforms.push_back(transformation.rotation());
transforms.push_back(transformation.translation());
return transforms;
}

py::object get_pose(std::shared_ptr<moveit::core::RobotState>& robot_state, std::string link_name)
{
Eigen::Isometry3d pose = robot_state->getGlobalLinkTransform(link_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ namespace bind_robot_state

Eigen::MatrixXd get_frame_transform(std::shared_ptr<moveit::core::RobotState>& robot_state, std::string& frame_id);

std::vector<Eigen::MatrixXd> get_global_link_transform(std::shared_ptr<moveit::core::RobotState>& robot_state, std::string& link_name);

py::object get_pose(std::shared_ptr<moveit::core::RobotState>& robot_state, std::string link_name);

Eigen::VectorXd copy_joint_group_positions(std::shared_ptr<moveit::core::RobotState>& robot_state,
Expand Down

0 comments on commit b2ed79c

Please sign in to comment.