18 #include "gtest/gtest.h" 23 #include <boost/shared_ptr.hpp> 24 #include <boost/thread/thread.hpp> 25 #include <boost/date_time/posix_time/posix_time.hpp> 26 #include <eigen3/Eigen/Geometry> 28 #include "asr_robot_model_services/GetDistance.h" 48 n.
setParam(
"viewCenterPositionDistanceThreshold", 0.17);
49 n.
setParam(
"/nbv/mHypothesisUpdaterAngleThreshold", 45.0);
63 n.setParam(
"distanceFunc", 2);
67 geometry_msgs::Pose pose1;
68 geometry_msgs::Pose pose2;
70 EXPECT_DOUBLE_EQ(0.0, poseHelperPtr->calculateDistance(pose1, pose2));
73 pose1.orientation.x = 0.444;
74 pose2.orientation.w = -0.666;
76 EXPECT_DOUBLE_EQ(0.0, poseHelperPtr->calculateDistance(pose1, pose2));
78 pose2.position.x = 13.33;
79 pose2.position.y = -14.55;
81 EXPECT_NEAR(19.733, poseHelperPtr->calculateDistance(pose1, pose2),
EPSILON);
83 pose1.position.x = -13.33;
84 pose1.position.y = -14.55;
86 EXPECT_DOUBLE_EQ(26.66, poseHelperPtr->calculateDistance(pose1, pose2));
92 geometry_msgs::Pose pose1;
93 pose1.orientation.w = 1.0;
94 geometry_msgs::Pose pose2;
95 pose2.orientation.w = 1.0;
96 EXPECT_NEAR(0.0, poseHelperPtr->calcAngularDistanceInRad(pose1, pose2),
EPSILON);
99 pose1.position.x = 13.33;
100 pose2.position.y = -14.55;
101 EXPECT_NEAR(0.0, poseHelperPtr->calcAngularDistanceInRad(pose1, pose2),
EPSILON);
104 pose2.orientation.w = 0.0;
105 pose2.orientation.x = 1.0;
106 EXPECT_NEAR(180.0 * M_PI / 180.0, poseHelperPtr->calcAngularDistanceInRad(pose1, pose2),
EPSILON);
109 pose2.orientation.w = 0.5;
110 pose2.orientation.x = 0.5;
111 pose2.orientation.y = -0.5;
112 pose2.orientation.z = -0.5;
113 EXPECT_NEAR(120.0 * M_PI / 180.0, poseHelperPtr->calcAngularDistanceInRad(pose1, pose2),
EPSILON);
119 geometry_msgs::Pose pose1;
120 pose1.orientation.w = 1.0;
121 geometry_msgs::Pose pose2;
122 pose2.orientation.w = 1.0;
123 EXPECT_TRUE(poseHelperPtr->checkViewCenterPointsAreApproxEquale(pose1, pose2));
127 pose2.orientation.w = 0.997;
128 pose2.orientation.z = 0.083;
129 EXPECT_TRUE(poseHelperPtr->checkViewCenterPointsAreApproxEquale(pose1, pose2));
133 pose2.orientation.w = 0.995;
134 pose2.orientation.z = 0.099;
135 EXPECT_FALSE(poseHelperPtr->checkViewCenterPointsAreApproxEquale(pose1, pose2));
138 pose2.position.x = 0.95;
139 pose2.position.y = -0.95;
141 pose2.orientation.w = 0.707;
142 pose2.orientation.z = 0.707;
143 EXPECT_FALSE(poseHelperPtr->checkViewCenterPointsAreApproxEquale(pose1, pose2));
146 pose2.position.x = 0.95 * 2;
147 pose2.position.y = 0.0;
149 pose2.orientation.w = 0.0;
150 pose2.orientation.z = 1.0;
151 EXPECT_FALSE(poseHelperPtr->checkViewCenterPointsAreApproxEquale(pose1, pose2));
155 bool getDistance(asr_robot_model_services::GetDistance::Request &req, asr_robot_model_services::GetDistance::Response &res) {
167 boost::this_thread::sleep(boost::posix_time::milliseconds(10));
173 n.setParam(
"distanceFunc", 2);
177 geometry_msgs::Pose pose1;
178 geometry_msgs::Pose pose2;
180 pose2.position.x = 1.0;
181 pose2.position.y = 0.0;
183 EXPECT_NEAR(1.0, poseHelperPtr->calculateDistance(pose1, pose2),
EPSILON);
185 n.setParam(
"distanceFunc", 1);
192 EXPECT_NEAR(0.0, poseHelperPtr->calculateDistance(pose1, pose2),
EPSILON);
std::string getName(void *handle)
ROSCPP_DECL const std::string & getName()
bool getDistance(asr_robot_model_services::GetDistance::Request &req, asr_robot_model_services::GetDistance::Response &res)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
static void resetInstance()
static boost::shared_ptr< PoseHelper > getInstance()
TEST_F(PoseHelperSetup, CalcDistPositionEucl)
ROSCPP_DECL void spinOnce()
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const