Skip to content

Commit

Permalink
load tag config
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Jun 10, 2024
1 parent 7a1fc21 commit 06b48ca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ find_package(Eigen3 REQUIRED NO_MODULE)
find_package(Threads REQUIRED)
find_package(OpenCV REQUIRED COMPONENTS core calib3d)
find_package(apriltag 3.2 REQUIRED)
find_package(yaml-cpp REQUIRED)

if(cv_bridge_VERSION VERSION_GREATER_EQUAL 3.3.0)
add_compile_definitions(cv_bridge_HPP)
Expand Down Expand Up @@ -110,9 +111,11 @@ ament_target_dependencies(AprilTagNode
tf2_ros
image_transport
cv_bridge
ament_index_cpp
)
target_link_libraries(AprilTagNode
apriltag::apriltag
yaml-cpp::yaml-cpp
tags
pose_estimation
)
Expand All @@ -128,6 +131,10 @@ install(TARGETS AprilTagNode
LIBRARY DESTINATION lib
)

install(DIRECTORY tag
DESTINATION share/${PROJECT_NAME}
)

install(DIRECTORY cfg
DESTINATION share/${PROJECT_NAME}
)
Expand Down
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<depend>apriltag</depend>
<depend>image_transport</depend>
<depend>cv_bridge</depend>
<depend>yaml-cpp</depend>
<depend>ament_index_cpp</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_cmake_clang_format</test_depend>
Expand Down
12 changes: 12 additions & 0 deletions src/AprilTagNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#else
#include <cv_bridge/cv_bridge.h>
#endif
#include <ament_index_cpp/get_package_share_directory.hpp>
#include <image_transport/camera_subscriber.hpp>
#include <image_transport/image_transport.hpp>
#include <rclcpp/rclcpp.hpp>
Expand All @@ -18,6 +19,11 @@
// apriltag
#include "tag_functions.hpp"
#include <apriltag.h>
#include <filesystem>
#include <yaml-cpp/yaml.h>


namespace fs = std::filesystem;


#define IF(N, V) \
Expand Down Expand Up @@ -145,6 +151,12 @@ AprilTagNode::AprilTagNode(const rclcpp::NodeOptions& options)
for(size_t i = 0; i < ids.size(); i++) { tag_sizes[ids[i]] = sizes[i]; }
}

// tag_family
const fs::path ros_pkg_share_path =
ament_index_cpp::get_package_share_directory("apriltag_ros");
const fs::path tag_config_path = ros_pkg_share_path / "tag" / (tag_family + ".yaml");
const YAML::Node tag_config = YAML::LoadFile(tag_config_path);

if(tag_fun.count(tag_family)) {
tf = tag_fun.at(tag_family).first();
tf_destructor = tag_fun.at(tag_family).second;
Expand Down

0 comments on commit 06b48ca

Please sign in to comment.