30 #include <gtest/gtest.h>
40 timeval temp_time_struct;
41 gettimeofday(&temp_time_struct,NULL);
42 srand(temp_time_struct.tv_usec);
50 unsigned int runs = 100;
55 std::vector<double>
values(runs);
60 for ( uint64_t i = 1; i < runs ; i++ )
62 values[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
74 for ( uint64_t i = 1; i < runs ; i++ )
86 unsigned int runs = 100;
91 std::vector<double>
values(runs);
96 for (
int i = runs -1; i >= 0 ; i-- )
98 values[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
107 for ( uint64_t i = 1; i < runs ; i++ )
121 double my_vals[] = {13,2,5,4,9,7,3,11,15,14,12,1,6,10,0,8};
122 std::vector<double>
values (my_vals, my_vals +
sizeof(my_vals)/
sizeof(
double));
123 unsigned int runs =
values.size();
128 for ( uint64_t i = 0; i <runs ; i++ )
130 values[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
139 for ( uint64_t i = 1; i < runs ; i++ )
154 std::vector<double>
values(runs);
159 for ( uint64_t i = 0; i <runs ; i++ )
161 values[i] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
173 for ( uint64_t i = 1; i < runs ; i++ )
202 std::vector<double> xvalues(2);
203 std::vector<double> yvalues(2);
204 std::vector<double> zvalues(2);
206 uint64_t offset = 200;
211 for ( uint64_t i = 1; i < runs ; i++ )
215 xvalues[
step] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
216 yvalues[
step] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
217 zvalues[
step] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX;
226 for (
int pos = 0; pos < 100 ; pos++)
232 EXPECT_NEAR(xvalues[0] + (xvalues[1] - xvalues[0]) * (
double)pos/100.0, x_out,
epsilon);
233 EXPECT_NEAR(yvalues[0] + (yvalues[1] - yvalues[0]) * (
double)pos/100.0, y_out,
epsilon);
234 EXPECT_NEAR(zvalues[0] + (zvalues[1] - zvalues[0]) * (
double)pos/100.0, z_out,
epsilon);
350 for (uint64_t i = 0 ; i < runs ; i++)
352 q2.
setEuler(1.0 * ((
double) rand() - (
double)RAND_MAX /2.0) /(
double)RAND_MAX,
353 1.0 * ((
double) rand() - (
double)RAND_MAX /2.0) /(
double)RAND_MAX,
354 1.0 * ((
double) rand() - (
double)RAND_MAX /2.0) /(
double)RAND_MAX);
359 EXPECT_NEAR(q3.
angle(q1), q2.
angle(q3), 1e-5);
372 std::vector<double> yawvalues(2);
373 std::vector<double> pitchvalues(2);
374 std::vector<double> rollvalues(2);
375 uint64_t offset = 200;
377 std::vector<tf::Quaternion> quats(2);
382 for ( uint64_t i = 1; i < runs ; i++ )
386 yawvalues[
step] = 10.0 * ((double) rand() - (double)RAND_MAX /2.0) /(double)RAND_MAX / 100.0;
387 pitchvalues[
step] = 0;
388 rollvalues[
step] = 0;
397 for (
int pos = 0; pos < 100 ; pos ++)
431 EXPECT_TRUE(!std::isnan(stor.
rotation_.x()));
432 EXPECT_TRUE(!std::isnan(stor.
rotation_.y()));
433 EXPECT_TRUE(!std::isnan(stor.
rotation_.z()));
434 EXPECT_TRUE(!std::isnan(stor.
rotation_.w()));
438 int main(
int argc,
char **argv){
439 testing::InitGoogleTest(&argc, argv);
440 return RUN_ALL_TESTS();