Skip to content

Commit f2ecf6b

Browse files
committed
feat(map_projection_loader): componentize MapProjectionLoader (autowarefoundation#7108)
* remove unusing main func file Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * mod to componentize and use glog Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * change log output from screen to both Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * change executable name to match CMakelists Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> --------- Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com>
1 parent 537374f commit f2ecf6b

10 files changed

+22
-40
lines changed

map/map_projection_loader/CMakeLists.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@ autoware_package()
66

77
ament_auto_find_build_dependencies()
88

9-
ament_auto_add_library(map_projection_loader_lib SHARED
9+
ament_auto_add_library(${PROJECT_NAME} SHARED
1010
src/map_projection_loader.cpp
1111
src/load_info_from_lanelet2_map.cpp
1212
)
1313

14-
target_link_libraries(map_projection_loader_lib yaml-cpp)
15-
16-
ament_auto_add_executable(map_projection_loader src/map_projection_loader_node.cpp)
17-
18-
target_compile_options(map_projection_loader PUBLIC -g -Wall -Wextra -Wpedantic -Werror)
14+
rclcpp_components_register_node(${PROJECT_NAME}
15+
PLUGIN "MapProjectionLoader"
16+
EXECUTABLE ${PROJECT_NAME}_node
17+
EXECUTOR SingleThreadedExecutor
18+
)
1919

20-
target_link_libraries(map_projection_loader map_projection_loader_lib)
21-
target_include_directories(map_projection_loader PUBLIC include)
20+
target_link_libraries(${PROJECT_NAME} yaml-cpp)
2221

2322
function(add_testcase filepath)
2423
get_filename_component(filename ${filepath} NAME)
2524
string(REGEX REPLACE ".cpp" "" test_name ${filename})
2625
ament_add_gmock(${test_name} ${filepath})
27-
target_link_libraries("${test_name}" map_projection_loader_lib)
26+
target_link_libraries("${test_name}" ${PROJECT_NAME})
2827
ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
2928
endfunction()
3029

@@ -57,7 +56,8 @@ if(BUILD_TESTING)
5756
add_testcase(test/test_load_info_from_lanelet2_map.cpp)
5857
endif()
5958

60-
ament_auto_package(INSTALL_TO_SHARE
59+
ament_auto_package(
60+
INSTALL_TO_SHARE
6161
launch
6262
config
6363
)

map/map_projection_loader/include/map_projection_loader/map_projection_loader.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tier4_map_msgs::msg::MapProjectorInfo load_map_projector_info(
2929
class MapProjectionLoader : public rclcpp::Node
3030
{
3131
public:
32-
MapProjectionLoader();
32+
explicit MapProjectionLoader(const rclcpp::NodeOptions & options);
3333

3434
private:
3535
using MapProjectorInfo = map_interface::MapProjectorInfo;

map/map_projection_loader/launch/map_projection_loader.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<arg name="map_projector_info_path" description="Path to the yaml file"/>
55
<arg name="lanelet2_map_path" description="Path to the lanelet2 map file"/>
66

7-
<node pkg="map_projection_loader" exec="map_projection_loader" name="map_projection_loader" output="screen">
7+
<node pkg="map_projection_loader" exec="map_projection_loader_node" output="both">
88
<param from="$(var param_path)" allow_substs="true"/>
99
</node>
1010
</launch>

map/map_projection_loader/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<depend>component_interface_utils</depend>
2222
<depend>lanelet2_extension</depend>
2323
<depend>rclcpp</depend>
24+
<depend>rclcpp_components</depend>
2425
<depend>tier4_map_msgs</depend>
2526
<depend>yaml-cpp</depend>
2627

map/map_projection_loader/src/map_projection_loader.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ tier4_map_msgs::msg::MapProjectorInfo load_map_projector_info(
8282
return msg;
8383
}
8484

85-
MapProjectionLoader::MapProjectionLoader() : Node("map_projection_loader")
85+
MapProjectionLoader::MapProjectionLoader(const rclcpp::NodeOptions & options)
86+
: rclcpp::Node("map_projection_loader", options)
8687
{
8788
const std::string yaml_filename = this->declare_parameter<std::string>("map_projector_info_path");
8889
const std::string lanelet2_map_filename =
@@ -96,3 +97,6 @@ MapProjectionLoader::MapProjectionLoader() : Node("map_projection_loader")
9697
adaptor.init_pub(publisher_);
9798
publisher_->publish(msg);
9899
}
100+
101+
#include <rclcpp_components/register_node_macro.hpp>
102+
RCLCPP_COMPONENTS_REGISTER_NODE(MapProjectionLoader)

map/map_projection_loader/src/map_projection_loader_node.cpp

-23
This file was deleted.

map/map_projection_loader/test/test_node_load_local_cartesian_utm_from_yaml.test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def generate_test_description():
4444

4545
map_projection_loader_node = Node(
4646
package="map_projection_loader",
47-
executable="map_projection_loader",
47+
executable="map_projection_loader_node",
4848
output="screen",
4949
parameters=[
5050
{

map/map_projection_loader/test/test_node_load_local_from_yaml.test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def generate_test_description():
4444

4545
map_projection_loader_node = Node(
4646
package="map_projection_loader",
47-
executable="map_projection_loader",
47+
executable="map_projection_loader_node",
4848
output="screen",
4949
parameters=[
5050
{

map/map_projection_loader/test/test_node_load_mgrs_from_yaml.test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def generate_test_description():
4444

4545
map_projection_loader_node = Node(
4646
package="map_projection_loader",
47-
executable="map_projection_loader",
47+
executable="map_projection_loader_node",
4848
output="screen",
4949
parameters=[
5050
{

map/map_projection_loader/test/test_node_load_transverse_mercator_from_yaml.test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def generate_test_description():
4444

4545
map_projection_loader_node = Node(
4646
package="map_projection_loader",
47-
executable="map_projection_loader",
47+
executable="map_projection_loader_node",
4848
output="screen",
4949
parameters=[
5050
{

0 commit comments

Comments
 (0)