timePose3.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* ----------------------------------------------------------------------------
  2. * GTSAM Copyright 2010, Georgia Tech Research Corporation,
  3. * Atlanta, Georgia 30332-0415
  4. * All Rights Reserved
  5. * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
  6. * See LICENSE for the license information
  7. * -------------------------------------------------------------------------- */
  8. /**
  9. * @file timePose3.cpp
  10. * @brief time Pose3 functions
  11. * @author Frank Dellaert
  12. */
  13. #include <iostream>
  14. #include <gtsam/base/timing.h>
  15. #include <gtsam/geometry/Pose3.h>
  16. using namespace std;
  17. using namespace gtsam;
  18. /* ************************************************************************* */
  19. #define TEST(TITLE,STATEMENT) \
  20. gttic_(TITLE); \
  21. for(int i = 0; i < n; i++) \
  22. STATEMENT; \
  23. gttoc_(TITLE);
  24. int main()
  25. {
  26. int n = 5000000;
  27. cout << "NOTE: Times are reported for " << n << " calls" << endl;
  28. double norm=sqrt(1.0+16.0+4.0);
  29. double x=1.0/norm, y=4.0/norm, z=2.0/norm;
  30. Vector v = (Vector(6) << x, y, z, 0.1, 0.2, -0.1).finished();
  31. Pose3 T = Pose3::Expmap((Vector(6) << 0.1, 0.1, 0.2, 0.1, 0.4, 0.2).finished()), T2 = T.retract(v);
  32. Matrix H1,H2;
  33. TEST(retract, T.retract(v))
  34. TEST(Expmap, T*Pose3::Expmap(v))
  35. TEST(localCoordinates, T.localCoordinates(T2))
  36. TEST(between, T.between(T2))
  37. TEST(between_derivatives, T.between(T2,H1,H2))
  38. TEST(Logmap, Pose3::Logmap(T.between(T2)))
  39. // Print timings
  40. tictoc_print_();
  41. return 0;
  42. }