18 #include <gtest/gtest.h> 20 #include <Eigen/Dense> 21 #include <moveit/robot_model_loader/robot_model_loader.h> 22 #include <moveit/robot_model/robot_model.h> 23 #include <moveit/robot_state/robot_state.h> 25 #define _USE_MATH_DEFINES 31 static constexpr
double L0 {0.2604};
32 static constexpr
double L1 {0.3500};
33 static constexpr
double L2 {0.3070};
34 static constexpr
double L3 {0.0840};
35 static constexpr
double delta {1.0e-10};
39 typedef std::tuple<std::string, std::vector<double>, Eigen::Vector3d>
TestDataPoint;
42 return std::get<0>(tdp);
46 return std::get<1>(tdp);
50 return std::get<2>(tdp);
54 return std::string(vec.begin(), vec.end());
69 robot_model_loader::RobotModelLoader(GetParam()).getModel()};
115 std::string name =
getName(testData);
116 std::vector<double> joints =
getJoints(testData);
117 Eigen::Vector3d posExp =
getPos(testData);
120 rstate.setJointGroupPositions(
group_name_, joints);
123 Eigen::Affine3d transform = rstate.getFrameTransform(
tip_link_name_);
126 double error_norm = (transform.translation() - posExp).norm();
127 EXPECT_NEAR(error_norm, 0,
delta)
128 <<
"TestPosition \"" << name <<
"\" failed\n" 129 <<
"\t Joints: [" << Eigen::VectorXd::Map(joints.data(), joints.size()).transpose() <<
"]\n" 130 <<
"\t Expected position [" << posExp.transpose() <<
"]\n" 131 <<
"\t Real position [" << transform.translation().transpose() <<
"]";
135 int main(
int argc,
char **argv)
138 testing::InitGoogleTest(&argc, argv);
139 return RUN_ALL_TESTS();
std::vector< TestDataPoint > testDataSet_
std::tuple< std::string, std::vector< double >, Eigen::Vector3d > TestDataPoint
Eigen::Vector3d getPos(TestDataPoint &tdp)
const std::string ARM_GROUP_NAME
std::vector< double > getJoints(TestDataPoint &tdp)
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
robot_model::RobotModelConstPtr robot_model_
TEST_P(URDFKinematicsTest, forwardKinematics)
test the kinematics of urdf model
std::string getName(TestDataPoint &tdp)
std::string vecToString(std::vector< double > &vec)
std::string tip_link_name_
static constexpr double L1
const std::string ARM_GROUP_TIP_LINK_NAME
static constexpr double L3
const std::string PARAM_MODEL
INSTANTIATE_TEST_CASE_P(InstantiationName, URDFKinematicsTest,::testing::Values(PARAM_MODEL))
bool getParam(const std::string &key, std::string &s) const
static constexpr double L2
static constexpr double L0
static constexpr double delta