32 #include <gtest/gtest.h>
38 int rand_num = rand()%100+1;
39 double result =
min + (double)((max-
min)*rand_num)/101.0;
43 TEST(TFKDLConversions, tf_kdl_vector)
53 ASSERT_NEAR(t[0],k[0],1e-6);
54 ASSERT_NEAR(t[1],k[1],1e-6);
55 ASSERT_NEAR(t[2],k[2],1e-6);
58 TEST(TFKDLConversions, tf_kdl_rotation)
71 k.GetQuaternion(x,y,z,w);
73 ASSERT_NEAR(fabs(t[0]),fabs(x),1e-6);
74 ASSERT_NEAR(fabs(t[1]),fabs(y),1e-6);
75 ASSERT_NEAR(fabs(t[2]),fabs(z),1e-6);
76 ASSERT_NEAR(fabs(t[3]),fabs(w),1e-6);
77 ASSERT_NEAR(t[0]*t[1]*t[2]*t[3],x*y*z*w,1e-6);
82 TEST(TFKDLConversions, tf_kdl_transform)
98 for(
int i=0; i < 3; i++)
100 ASSERT_NEAR(t.
getOrigin()[i],k.p[i],1e-6);
101 for(
int j=0; j < 3; j++)
103 ASSERT_NEAR(t.
getBasis()[i][j],k.M(i,j),1e-6);
110 for(
int i=0; i< 3; i++)
113 for(
int j=0; j < 3; j++)
121 TEST(TFKDLConversions, tf_kdl_pose)
137 for(
int i=0; i < 3; i++)
139 ASSERT_NEAR(t.
getOrigin()[i],k.p[i],1e-6);
140 for(
int j=0; j < 3; j++)
142 ASSERT_NEAR(t.
getBasis()[i][j],k.M(i,j),1e-6);
150 for(
int i=0; i< 3; i++)
153 for(
int j=0; j < 3; j++)
161 TEST(TFKDLConversions, msg_kdl_twist)
163 geometry_msgs::Twist m;
175 ASSERT_NEAR(m.linear.x,t.vel[0],1e-6);
176 ASSERT_NEAR(m.linear.y,t.vel[1],1e-6);
177 ASSERT_NEAR(m.linear.z,t.vel[2],1e-6);
178 ASSERT_NEAR(m.angular.x,t.rot[0],1e-6);
179 ASSERT_NEAR(m.angular.y,t.rot[1],1e-6);
180 ASSERT_NEAR(m.angular.z,t.rot[2],1e-6);
184 geometry_msgs::Twist r;
187 ASSERT_NEAR(r.linear.x,t.vel[0],1e-6);
188 ASSERT_NEAR(r.linear.y,t.vel[1],1e-6);
189 ASSERT_NEAR(r.linear.z,t.vel[2],1e-6);
190 ASSERT_NEAR(r.angular.x,t.rot[0],1e-6);
191 ASSERT_NEAR(r.angular.y,t.rot[1],1e-6);
192 ASSERT_NEAR(r.angular.z,t.rot[2],1e-6);
198 int main(
int argc,
char **argv){
200 srand ( time(NULL) );
201 testing::InitGoogleTest(&argc, argv);
202 return RUN_ALL_TESTS();