ur_kinematics_unit.cpp
Go to the documentation of this file.
1 
28 #include <gtest/gtest.h>
29 #include <fstream>
31 
32 #include "kinematics_test_utils.h"
35 
36 using namespace tesseract_kinematics::test_suite;
37 using namespace tesseract_kinematics;
38 
40  double shoulder_offset,
41  double elbow_offset,
42  const Eigen::Isometry3d& pose)
43 {
44  Eigen::VectorXd seed = Eigen::VectorXd::Zero(6);
45 
46  // Setup test
47  auto scene_graph = getSceneGraphUR(params, shoulder_offset, elbow_offset);
48 
49  std::string manip_name = "manip";
50  std::string base_link_name = "base_link";
51  std::string tip_link_name = "tool0";
52  std::vector<std::string> joint_names{ "shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint",
53  "wrist_1_joint", "wrist_2_joint", "wrist_3_joint" };
54 
55  KDLFwdKinChain fwd_kin(*scene_graph, base_link_name, tip_link_name);
56  auto inv_kin = std::make_unique<URInvKin>(params, base_link_name, tip_link_name, joint_names);
57 
58  EXPECT_EQ(inv_kin->getSolverName(), UR_INV_KIN_CHAIN_SOLVER_NAME);
59  EXPECT_EQ(inv_kin->numJoints(), 6);
60  EXPECT_EQ(inv_kin->getBaseLinkName(), base_link_name);
61  EXPECT_EQ(inv_kin->getWorkingFrame(), base_link_name);
62  EXPECT_EQ(inv_kin->getTipLinkNames().size(), 1);
63  EXPECT_EQ(inv_kin->getTipLinkNames()[0], tip_link_name);
64  EXPECT_EQ(inv_kin->getJointNames(), joint_names);
65 
66  runInvKinTest(*inv_kin, fwd_kin, pose, tip_link_name, seed);
67 
68  // Check cloned
69  InverseKinematics::Ptr inv_kin2 = inv_kin->clone();
70  EXPECT_TRUE(inv_kin2 != nullptr);
71  EXPECT_EQ(inv_kin2->getSolverName(), UR_INV_KIN_CHAIN_SOLVER_NAME);
72  EXPECT_EQ(inv_kin2->numJoints(), 6);
73  EXPECT_EQ(inv_kin2->getBaseLinkName(), base_link_name);
74  EXPECT_EQ(inv_kin2->getWorkingFrame(), base_link_name);
75  EXPECT_EQ(inv_kin2->getTipLinkNames().size(), 1);
76  EXPECT_EQ(inv_kin2->getTipLinkNames()[0], tip_link_name);
77  EXPECT_EQ(inv_kin2->getJointNames(), joint_names);
78 
79  runInvKinTest(*inv_kin2, fwd_kin, pose, tip_link_name, seed);
80 }
81 
82 TEST(TesseractKinematicsUnit, UR10InvKinUnit) // NOLINT
83 {
84  // Inverse target pose and seed
85  Eigen::Isometry3d pose;
86  pose.setIdentity();
87  pose.translation()[0] = 0.75;
88  pose.translation()[1] = 0;
89  pose.translation()[2] = 0.75;
90 
91  double shoulder_offset{ 0.220941 };
92  double elbow_offset{ -0.1719 };
93 
94  runURKinematicsTests(UR10Parameters, shoulder_offset, elbow_offset, pose);
95 }
96 
97 TEST(TesseractKinematicsUnit, UR5InvKinUnit) // NOLINT
98 {
99  // Inverse target pose and seed
100  Eigen::Isometry3d pose;
101  pose.setIdentity();
102  pose.translation()[0] = 0.5;
103  pose.translation()[1] = 0;
104  pose.translation()[2] = 0.5;
105 
106  double shoulder_offset{ 0.13585 };
107  double elbow_offset{ -0.1197 };
108 
109  runURKinematicsTests(UR5Parameters, shoulder_offset, elbow_offset, pose);
110 }
111 
112 TEST(TesseractKinematicsUnit, UR3InvKinUnit) // NOLINT
113 {
114  // Inverse target pose and seed
115  Eigen::Isometry3d pose;
116  pose.setIdentity();
117  pose.translation()[0] = 0.25;
118  pose.translation()[1] = 0;
119  pose.translation()[2] = 0.25;
120 
121  double shoulder_offset{ 0.1198 };
122  double elbow_offset{ -0.0925 };
123 
124  runURKinematicsTests(UR3Parameters, shoulder_offset, elbow_offset, pose);
125 }
126 
127 TEST(TesseractKinematicsUnit, UR10eInvKinUnit) // NOLINT
128 {
129  // Inverse target pose and seed
130  Eigen::Isometry3d pose;
131  pose.setIdentity();
132  pose.translation()[0] = 0.75;
133  pose.translation()[1] = 0;
134  pose.translation()[2] = 0.75;
135 
136  double shoulder_offset{ 0.176 };
137  double elbow_offset{ -0.137 };
138 
139  runURKinematicsTests(UR10eParameters, shoulder_offset, elbow_offset, pose);
140 }
141 
142 TEST(TesseractKinematicsUnit, UR5eInvKinUnit) // NOLINT
143 {
144  // Inverse target pose and seed
145  Eigen::Isometry3d pose;
146  pose.setIdentity();
147  pose.translation()[0] = 0.5;
148  pose.translation()[1] = 0;
149  pose.translation()[2] = 0.5;
150 
151  double shoulder_offset{ 0.138 };
152  double elbow_offset{ -0.131 };
153 
154  runURKinematicsTests(UR5eParameters, shoulder_offset, elbow_offset, pose);
155 }
156 
157 TEST(TesseractKinematicsUnit, UR3eInvKinUnit) // NOLINT
158 {
159  // Inverse target pose and seed
160  Eigen::Isometry3d pose;
161  pose.setIdentity();
162  pose.translation()[0] = 0.25;
163  pose.translation()[1] = 0;
164  pose.translation()[2] = 0.25;
165 
166  double shoulder_offset{ 0.120 };
167  double elbow_offset{ -0.093 };
168 
169  runURKinematicsTests(UR3eParameters, shoulder_offset, elbow_offset, pose);
170 }
171 
172 int main(int argc, char** argv)
173 {
174  testing::InitGoogleTest(&argc, argv);
175 
176  return RUN_ALL_TESTS();
177 }
tesseract_kinematics::UR_INV_KIN_CHAIN_SOLVER_NAME
static const std::string UR_INV_KIN_CHAIN_SOLVER_NAME
Definition: ur_inv_kin.h:82
kdl_fwd_kin_chain.h
Tesseract KDL forward kinematics chain implementation.
tesseract_kinematics::UR3eParameters
const static URParameters UR3eParameters(0.15185, -0.24355, -0.2132, 0.13105, 0.08535, 0.0921)
The UR3e kinematic parameters.
kinematics_test_utils.h
TEST
TEST(TesseractKinematicsUnit, UR10InvKinUnit)
Definition: ur_kinematics_unit.cpp:82
tesseract_kinematics::test_suite::getSceneGraphUR
tesseract_scene_graph::SceneGraph::UPtr getSceneGraphUR(const tesseract_kinematics::URParameters &params, double shoulder_offset, double elbow_offset)
Definition: kinematics_test_utils.h:89
ur_inv_kin.h
runURKinematicsTests
void runURKinematicsTests(const URParameters &params, double shoulder_offset, double elbow_offset, const Eigen::Isometry3d &pose)
Definition: ur_kinematics_unit.cpp:39
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
main
int main(int argc, char **argv)
Definition: ur_kinematics_unit.cpp:172
tesseract_kinematics::UR10eParameters
const static URParameters UR10eParameters(0.1807, -0.6127, -0.57155, 0.17415, 0.11985, 0.11655)
The UR10e kinematic parameters.
tesseract_kinematics::URParameters
The Universal Robot kinematic parameters.
Definition: types.h:41
tesseract_kinematics::UR3Parameters
const static URParameters UR3Parameters(0.1519, -0.24365, -0.21325, 0.11235, 0.08535, 0.0819)
The UR3 kinematic parameters.
tesseract_kinematics::KDLFwdKinChain
KDL kinematic chain implementation.
Definition: kdl_fwd_kin_chain.h:49
tesseract_kinematics::UR5eParameters
const static URParameters UR5eParameters(0.1625, -0.425, -0.3922, 0.1333, 0.0997, 0.0996)
The UR5e kinematic parameters.
tesseract_kinematics::test_suite
Definition: kinematics_test_utils.h:53
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_kinematics::UR10Parameters
const static URParameters UR10Parameters(0.1273, -0.612, -0.5723, 0.163941, 0.1157, 0.0922)
The UR10 kinematic parameters.
tesseract_kinematics::UR5Parameters
const static URParameters UR5Parameters(0.089159, -0.42500, -0.39225, 0.10915, 0.09465, 0.0823)
The UR5 kinematic parameters.
tesseract_kinematics::InverseKinematics::Ptr
std::shared_ptr< InverseKinematics > Ptr
Definition: inverse_kinematics.h:50
tesseract_kinematics
Definition: forward_kinematics.h:40
macros.h
tesseract_kinematics::test_suite::runInvKinTest
void runInvKinTest(const tesseract_kinematics::InverseKinematics &inv_kin, const tesseract_kinematics::ForwardKinematics &fwd_kin, const Eigen::Isometry3d &target_pose, const std::string &tip_link_name, const Eigen::VectorXd &seed)
Run inverse kinematics test comparing the inverse solution to the forward solution.
Definition: kinematics_test_utils.h:458


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