Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ROBOT_MODEL_TEST_HPP_
00020 #define ROBOT_MODEL_TEST_HPP_
00021
00022 #include "descartes_core/pretty_print.hpp"
00023 #include "descartes_core/robot_model.h"
00024 #include "ros/console.h"
00025 #include <gtest/gtest.h>
00026
00036 namespace descartes_trajectory_test
00037 {
00038 template <class T>
00039 descartes_core::RobotModelPtr CreateRobotModel();
00040
00041 template <class T>
00042 class RobotModelTest : public ::testing::Test
00043 {
00044 public:
00045 RobotModelTest() : model_(CreateRobotModel<T>())
00046 {
00047 ROS_INFO("Instantiated RobotModelTest fixture(base) (parameterized)");
00048 }
00049
00050 virtual void SetUp()
00051 {
00052 ROS_INFO("Setting up RobotModelTest fixture(base) (parameterized)");
00053 ASSERT_TRUE(static_cast<bool>(this->model_));
00054 }
00055
00056 virtual void TearDown()
00057 {
00058 ROS_INFO("Tearing down RobotModelTest fixture(base) (parameterized)");
00059 }
00060
00061 virtual ~RobotModelTest()
00062 {
00063 ROS_INFO("Desctructing RobotModelTest fixture(base) (parameterized)");
00064 }
00065
00066 descartes_core::RobotModelPtr model_;
00067 };
00068
00069 using namespace descartes_core;
00070
00071 TYPED_TEST_CASE_P(RobotModelTest);
00072
00073 const double TF_EQ_TOL = 0.001;
00074 const double JOINT_EQ_TOL = 0.001;
00075
00076 TYPED_TEST_P(RobotModelTest, construction)
00077 {
00078 ROS_INFO_STREAM("Robot model test construction");
00079 }
00080
00081 TYPED_TEST_P(RobotModelTest, getIK)
00082 {
00083 ROS_INFO_STREAM("Testing getIK");
00084 std::vector<double> fk_joint(6, 0.0);
00085 std::vector<double> ik_joint;
00086 Eigen::Affine3d ik_pose, fk_pose;
00087 EXPECT_TRUE(this->model_->getFK(fk_joint, ik_pose));
00088 EXPECT_TRUE(this->model_->getIK(ik_pose, fk_joint, ik_joint));
00089
00090
00091 EXPECT_TRUE(this->model_->getFK(ik_joint, fk_pose));
00092 EXPECT_TRUE(ik_pose.matrix().isApprox(fk_pose.matrix(), TF_EQ_TOL));
00093 ROS_INFO_STREAM("getIK Test completed");
00094 }
00095
00096 TYPED_TEST_P(RobotModelTest, getAllIK)
00097 {
00098 ROS_INFO_STREAM("Testing getAllIK");
00099 std::vector<double> fk_joint(6, 0.5);
00100 std::vector<std::vector<double> > joint_poses;
00101 Eigen::Affine3d ik_pose, fk_pose;
00102
00103 EXPECT_TRUE(this->model_->getFK(fk_joint, ik_pose));
00104 EXPECT_TRUE(this->model_->getAllIK(ik_pose, joint_poses));
00105 ROS_INFO_STREAM("Get all IK returned " << joint_poses.size() << " solutions");
00106 std::vector<std::vector<double> >::iterator it;
00107 for (it = joint_poses.begin(); it != joint_poses.end(); ++it)
00108 {
00109 ROS_INFO_STREAM("GetIK joint solution: " << *it);
00110 EXPECT_TRUE(this->model_->getFK(*it, fk_pose));
00111 EXPECT_TRUE(ik_pose.matrix().isApprox(fk_pose.matrix(), TF_EQ_TOL));
00112 }
00113 }
00114
00115 REGISTER_TYPED_TEST_CASE_P(RobotModelTest, construction, getIK, getAllIK);
00116
00117 }
00118
00119 #endif // ROBOT_MODEL_TEST_HPP_