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;
43 return std::get<0>(tdp);
48 return std::get<1>(tdp);
53 return std::get<2>(tdp);
58 return std::string(vec.begin(), vec.end());
67 void SetUp()
override;
74 robot_model::RobotModelConstPtr
robot_model_{ robot_model_loader::RobotModelLoader(GetParam(),
false).getModel() };
99 TestDataPoint(
"TestPos6", { -M_PI_2, -M_PI_2, -M_PI_2, 0, 0, 0 }, Eigen::Vector3d(0,
L1,
L0 +
L2 +
L3)));
126 std::string name =
getName(test_data);
127 std::vector<double> joints =
getJoints(test_data);
128 Eigen::Vector3d pos_exp =
getPos(test_data);
131 rstate.setVariablePositions(joints);
133 Eigen::Affine3d transform = rstate.getFrameTransform(
tip_link_name_);
136 double error_norm = (transform.translation() - pos_exp).norm();
137 EXPECT_NEAR(error_norm, 0,
DELTA) <<
"TestPosition \"" << name <<
"\" failed\n" 139 << Eigen::VectorXd::Map(joints.data(),
static_cast<long>(joints.size()))
142 <<
"\t Expected position [" << pos_exp.transpose() <<
"]\n" 143 <<
"\t Real position [" << transform.translation().transpose() <<
"]";
147 int main(
int argc,
char** argv)
150 testing::InitGoogleTest(&argc, argv);
151 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_
static constexpr double DELTA
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
bool getParam(const std::string &key, std::string &s) const
static constexpr double L2
static constexpr double L0
INSTANTIATE_TEST_CASE_P(InstantiationName, URDFKinematicsTest,::testing::Values(PARAM_MODEL),)