Skip to content

Commit bf9ef9d

Browse files
a-maumaupre-commit-ci[bot]
authored and
KhalilSelyan
committed
feat(ar_tag_based_localizer): componentize ArTagBasedLocalizer (#7187)
* remove unusing main func Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * mod to componentize and use glog Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * change exec name and change log output from log to both Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * style(pre-commit): autofix --------- Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7188bff commit bf9ef9d

File tree

5 files changed

+19
-62
lines changed

5 files changed

+19
-62
lines changed

localization/landmark_based_localizer/ar_tag_based_localizer/CMakeLists.txt

+13-7
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,33 @@ ament_auto_find_build_dependencies()
1414

1515
find_package(OpenCV REQUIRED)
1616

17-
ament_auto_add_executable(ar_tag_based_localizer
18-
src/main.cpp
17+
ament_auto_add_library(${PROJECT_NAME} SHARED
1918
src/ar_tag_based_localizer.cpp
2019
)
21-
target_include_directories(ar_tag_based_localizer
20+
21+
target_include_directories(${PROJECT_NAME}
2222
SYSTEM PUBLIC
2323
${OpenCV_INCLUDE_DIRS}
2424
)
25-
target_link_libraries(ar_tag_based_localizer ${OpenCV_LIBRARIES})
25+
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})
26+
27+
rclcpp_components_register_node(${PROJECT_NAME}
28+
PLUGIN "ArTagBasedLocalizer"
29+
EXECUTABLE ${PROJECT_NAME}_node
30+
EXECUTOR SingleThreadedExecutor
31+
)
2632

2733
if(BUILD_TESTING)
2834
find_package(ament_cmake_gtest REQUIRED)
29-
ament_auto_add_gtest(test_ar_tag_based_localizer
35+
ament_auto_add_gtest(test_${PROJECT_NAME}
3036
test/test.cpp
3137
src/ar_tag_based_localizer.cpp
3238
)
33-
target_include_directories(test_ar_tag_based_localizer
39+
target_include_directories(test_${PROJECT_NAME}
3440
SYSTEM PUBLIC
3541
${OpenCV_INCLUDE_DIRS}
3642
)
37-
target_link_libraries(test_ar_tag_based_localizer ${OpenCV_LIBRARIES})
43+
target_link_libraries(test_${PROJECT_NAME} ${OpenCV_LIBRARIES})
3844
endif()
3945

4046
ament_auto_package(

localization/landmark_based_localizer/ar_tag_based_localizer/launch/ar_tag_based_localizer.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<arg name="debug_mapped_tag" default="~/debug/mapped_tag"/>
1515
<arg name="debug_detected_tag" default="~/debug/detected_tag"/>
1616

17-
<node pkg="ar_tag_based_localizer" exec="ar_tag_based_localizer" name="$(var node_name)" output="log">
17+
<node pkg="ar_tag_based_localizer" exec="ar_tag_based_localizer_node" name="$(var node_name)" output="both">
1818
<remap from="~/input/lanelet2_map" to="$(var input_lanelet2_map)"/>
1919
<remap from="~/input/image" to="$(var input_image)"/>
2020
<remap from="~/input/camera_info" to="$(var input_camera_info)"/>

localization/landmark_based_localizer/ar_tag_based_localizer/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<depend>lanelet2_extension</depend>
2525
<depend>localization_util</depend>
2626
<depend>rclcpp</depend>
27+
<depend>rclcpp_components</depend>
2728
<depend>tf2_eigen</depend>
2829
<depend>tf2_geometry_msgs</depend>
2930
<depend>tf2_ros</depend>

localization/landmark_based_localizer/ar_tag_based_localizer/src/ar_tag_based_localizer.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
#include <tier4_autoware_utils/geometry/geometry.hpp>
6666

6767
ArTagBasedLocalizer::ArTagBasedLocalizer(const rclcpp::NodeOptions & options)
68-
: Node("ar_tag_based_localizer", options), cam_info_received_(false)
68+
: rclcpp::Node("ar_tag_based_localizer", options), cam_info_received_(false)
6969
{
7070
/*
7171
Declare node parameters
@@ -346,3 +346,6 @@ std::vector<landmark_manager::Landmark> ArTagBasedLocalizer::detect_landmarks(
346346

347347
return landmarks;
348348
}
349+
350+
#include <rclcpp_components/register_node_macro.hpp>
351+
RCLCPP_COMPONENTS_REGISTER_NODE(ArTagBasedLocalizer)

localization/landmark_based_localizer/ar_tag_based_localizer/src/main.cpp

-53
This file was deleted.

0 commit comments

Comments
 (0)