Skip to content

Commit

Permalink
feat(map_projection_loader): componentize MapProjectionLoader (#7108)
Browse files Browse the repository at this point in the history
* remove unusing main func file

Signed-off-by: a-maumau <[email protected]>

* mod to componentize and use glog

Signed-off-by: a-maumau <[email protected]>

* change log output from screen to both

Signed-off-by: a-maumau <[email protected]>

* change executable name to match CMakelists

Signed-off-by: a-maumau <[email protected]>

---------

Signed-off-by: a-maumau <[email protected]>
  • Loading branch information
a-maumau authored May 27, 2024
1 parent cbaf62a commit 54dfc05
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 40 deletions.
20 changes: 10 additions & 10 deletions map/map_projection_loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@ autoware_package()

ament_auto_find_build_dependencies()

ament_auto_add_library(map_projection_loader_lib SHARED
ament_auto_add_library(${PROJECT_NAME} SHARED
src/map_projection_loader.cpp
src/load_info_from_lanelet2_map.cpp
)

target_link_libraries(map_projection_loader_lib yaml-cpp)

ament_auto_add_executable(map_projection_loader src/map_projection_loader_node.cpp)

target_compile_options(map_projection_loader PUBLIC -g -Wall -Wextra -Wpedantic -Werror)
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "MapProjectionLoader"
EXECUTABLE ${PROJECT_NAME}_node
EXECUTOR SingleThreadedExecutor
)

target_link_libraries(map_projection_loader map_projection_loader_lib)
target_include_directories(map_projection_loader PUBLIC include)
target_link_libraries(${PROJECT_NAME} yaml-cpp)

function(add_testcase filepath)
get_filename_component(filename ${filepath} NAME)
string(REGEX REPLACE ".cpp" "" test_name ${filename})
ament_add_gmock(${test_name} ${filepath})
target_link_libraries("${test_name}" map_projection_loader_lib)
target_link_libraries("${test_name}" ${PROJECT_NAME})
ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
endfunction()

Expand Down Expand Up @@ -57,7 +56,8 @@ if(BUILD_TESTING)
add_testcase(test/test_load_info_from_lanelet2_map.cpp)
endif()

ament_auto_package(INSTALL_TO_SHARE
ament_auto_package(
INSTALL_TO_SHARE
launch
config
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tier4_map_msgs::msg::MapProjectorInfo load_map_projector_info(
class MapProjectionLoader : public rclcpp::Node
{
public:
MapProjectionLoader();
explicit MapProjectionLoader(const rclcpp::NodeOptions & options);

private:
using MapProjectorInfo = map_interface::MapProjectorInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<arg name="map_projector_info_path" description="Path to the yaml file"/>
<arg name="lanelet2_map_path" description="Path to the lanelet2 map file"/>

<node pkg="map_projection_loader" exec="map_projection_loader" name="map_projection_loader" output="screen">
<node pkg="map_projection_loader" exec="map_projection_loader_node" output="both">
<param from="$(var param_path)" allow_substs="true"/>
</node>
</launch>
1 change: 1 addition & 0 deletions map/map_projection_loader/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<depend>component_interface_utils</depend>
<depend>lanelet2_extension</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>tier4_map_msgs</depend>
<depend>yaml-cpp</depend>

Expand Down
6 changes: 5 additions & 1 deletion map/map_projection_loader/src/map_projection_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ tier4_map_msgs::msg::MapProjectorInfo load_map_projector_info(
return msg;
}

MapProjectionLoader::MapProjectionLoader() : Node("map_projection_loader")
MapProjectionLoader::MapProjectionLoader(const rclcpp::NodeOptions & options)
: rclcpp::Node("map_projection_loader", options)
{
const std::string yaml_filename = this->declare_parameter<std::string>("map_projector_info_path");
const std::string lanelet2_map_filename =
Expand All @@ -96,3 +97,6 @@ MapProjectionLoader::MapProjectionLoader() : Node("map_projection_loader")
adaptor.init_pub(publisher_);
publisher_->publish(msg);
}

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(MapProjectionLoader)
23 changes: 0 additions & 23 deletions map/map_projection_loader/src/map_projection_loader_node.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_test_description():

map_projection_loader_node = Node(
package="map_projection_loader",
executable="map_projection_loader",
executable="map_projection_loader_node",
output="screen",
parameters=[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_test_description():

map_projection_loader_node = Node(
package="map_projection_loader",
executable="map_projection_loader",
executable="map_projection_loader_node",
output="screen",
parameters=[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_test_description():

map_projection_loader_node = Node(
package="map_projection_loader",
executable="map_projection_loader",
executable="map_projection_loader_node",
output="screen",
parameters=[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_test_description():

map_projection_loader_node = Node(
package="map_projection_loader",
executable="map_projection_loader",
executable="map_projection_loader_node",
output="screen",
parameters=[
{
Expand Down

0 comments on commit 54dfc05

Please sign in to comment.