test_kuka_specific.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <vector>
3 #include <string>
4 
5 #include <ros/ros.h>
6 #include <moveit/robot_model_loader/robot_model_loader.h>
9 
10 #include "test_utils.h"
11 
12 class TestKukaSpecific : public testing::Test
13 {
14 protected:
15  void SetUp() override
16  {
17  rdf_loader::RDFLoader rdf_loader("robot_description");
18  const srdf::ModelSharedPtr& srdf = rdf_loader.getSRDF();
19  const urdf::ModelInterfaceSharedPtr& urdf_model = rdf_loader.getURDF();
20 
21  robot_model_.reset(new robot_model::RobotModel(urdf_model, srdf));
22  plugin_.initialize(*robot_model_.get(), "manipulator", "base_link", { "tool0" }, 0.1);
23  }
24  void TearDown() override
25  {
26  }
27 
28 protected:
29  robot_model::RobotModelPtr robot_model_;
31 };
32 
40 TEST_F(TestKukaSpecific, positionFKAllZero)
41 {
42  using Eigen::AngleAxisd;
43  using Eigen::Translation3d;
44  using Eigen::Vector3d;
45 
46  std::vector<std::string> link_names;
47  std::vector<double> joint_angles = { 0, 0, 0, 0, 0, 0 };
48  std::vector<geometry_msgs::Pose> poses;
49 
50  plugin_.getPositionFK(plugin_.getLinkNames(), joint_angles, poses);
51 
52  Eigen::Isometry3d pose_actual, pose_desired;
53  tf::poseMsgToEigen(poses[0], pose_actual);
54 
55  pose_desired = Translation3d(0.785, 0, 0.435) * AngleAxisd(M_PI_2, Vector3d::UnitY());
56 
57  moveit_opw_kinematics_plugin::testing::comparePoses(pose_actual, pose_desired);
58 }
59 
67 TEST_F(TestKukaSpecific, positionFKCheckSigns)
68 {
69  using Eigen::AngleAxisd;
70  using Eigen::Translation3d;
71  using Eigen::Vector3d;
72 
73  const double J1 = M_PI_2, J4 = 0.3, J6 = 0.2;
74 
75  std::vector<std::string> link_names;
76  std::vector<double> joint_angles = { J1, 0, 0, J4, 0, J6 };
77  std::vector<geometry_msgs::Pose> poses;
78 
79  plugin_.getPositionFK(plugin_.getLinkNames(), joint_angles, poses);
80 
81  Eigen::Isometry3d pose_actual, pose_desired;
82  tf::poseMsgToEigen(poses[0], pose_actual);
83 
84  // rotation for the joint offset of joint 2
85  pose_desired = Translation3d(0, 0, 0) * AngleAxisd(M_PI_2, Vector3d::UnitY());
86 
87  // rotate around GLOBAL z to add rotation caused by joint 1
88  pose_desired = AngleAxisd(-J1, Vector3d::UnitZ()) * pose_desired;
89 
90  // rotate two times around LOCAL z-axis for joints J4 and J6
91  pose_desired = pose_desired * AngleAxisd(-J4, Vector3d::UnitZ()) * AngleAxisd(-J6, Vector3d::UnitZ());
92 
93  // put the frame at the expected position, non-zero y-value
94  // instead of x caused by the rotation of joint 1
95  pose_desired = Translation3d(0, -0.785, 0.435) * pose_desired;
96 
97  moveit_opw_kinematics_plugin::testing::comparePoses(pose_actual, pose_desired);
98 }
TEST_F(TestKukaSpecific, positionFKAllZero)
virtual bool getPositionFK(const std::vector< std::string > &link_names, const std::vector< double > &joint_angles, std::vector< geometry_msgs::Pose > &poses) const override
const std::vector< std::string > & getLinkNames() const override
Return all the link names in the order they are represented internally.
void poseMsgToEigen(const geometry_msgs::Pose &m, Eigen::Affine3d &e)
robot_model::RobotModelPtr robot_model_
#define M_PI_2
Specific implementation of kinematics using ROS service calls to communicate with external IK solvers...
void comparePoses(const Transform< T > &Ta, const Transform< T > &Tb)
Compare every element of two transforms.
Definition: test_utils.h:18
moveit_opw_kinematics_plugin::MoveItOPWKinematicsPlugin plugin_
void TearDown() override
std::shared_ptr< Model > ModelSharedPtr
virtual bool initialize(const moveit::core::RobotModel &robot_model, const std::string &group_name, const std::string &base_frame, const std::vector< std::string > &tip_frames, double search_discretization) override
void SetUp() override


moveit_opw_kinematics_plugin
Author(s): Jeroen De Maeyer, Simon Schmeisser (isys vision)
autogenerated on Mon Feb 28 2022 22:50:11