transform_tree.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #define BOOST_TEST_DYN_LINK
  2. #include "core/transform_tree.h"
  3. #include <boost/test/unit_test.hpp>
  4. #include <nlohmann/json.hpp>
  5. #include <fstream>
  6. using namespace nlohmann;
  7. using namespace sophiar;
  8. BOOST_AUTO_TEST_CASE(test_transform_tree) {
  9. std::ifstream config_file("data/transform_tree_config.json");
  10. BOOST_TEST(config_file.is_open());
  11. transform_tree tree;
  12. tree.load_construct_config(json::parse(config_file));
  13. auto index_c = tree.get_index_by_name("C");
  14. auto index_d = tree.get_index_by_name("D");
  15. auto query_result = tree.query_transform(index_d, index_c);
  16. BOOST_TEST(std::get<0>(query_result) == true);
  17. BOOST_TEST(std::get<1>(query_result).isApprox(
  18. (Eigen::Isometry3d) Eigen::Translation3d(3, 5, 7)));
  19. auto index_e = tree.get_index_by_name("E");
  20. query_result = tree.query_transform(index_e, index_c);
  21. BOOST_TEST(std::get<0>(query_result) == false);
  22. BOOST_TEST(std::get<1>(query_result).isApprox(
  23. (Eigen::Isometry3d) Eigen::Translation3d(4, 6, 8)));
  24. }