Skip to content

Commit

Permalink
fix(map_loader, map_projection_loader): use component interface specs (
Browse files Browse the repository at this point in the history
…autowarefoundation#4585)

* feat(map): use component_interface_specs in map_projection_loader

Signed-off-by: kminoda <koji.minoda@tier4.jp>

* update map_loader

Signed-off-by: kminoda <koji.minoda@tier4.jp>

* style(pre-commit): autofix

* feat: add dummy typo

Signed-off-by: kminoda <koji.minoda@tier4.jp>

* update name

Signed-off-by: kminoda <koji.minoda@tier4.jp>

* fix test

Signed-off-by: kminoda <koji.minoda@tier4.jp>

* fix test

Signed-off-by: kminoda <koji.minoda@tier4.jp>

---------

Signed-off-by: kminoda <koji.minoda@tier4.jp>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
kminoda and pre-commit-ci[bot] committed Aug 21, 2023
1 parent d123bb2 commit 1bfdede
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 18 deletions.
1 change: 0 additions & 1 deletion launch/tier4_map_launch/launch/map.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def launch_setup(context, *args, **kwargs):
name="lanelet2_map_loader",
remappings=[
("output/lanelet2_map", "vector_map"),
("input/map_projector_info", "map_projector_type"),
],
parameters=[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#ifndef MAP_LOADER__LANELET2_MAP_LOADER_NODE_HPP_
#define MAP_LOADER__LANELET2_MAP_LOADER_NODE_HPP_

#include <component_interface_specs/map.hpp>
#include <component_interface_utils/rclcpp.hpp>
#include <rclcpp/rclcpp.hpp>

#include <autoware_auto_mapping_msgs/msg/had_map_bin.hpp>
Expand All @@ -41,9 +43,11 @@ class Lanelet2MapLoaderNode : public rclcpp::Node
const rclcpp::Time & now);

private:
void on_map_projector_info(const MapProjectorInfo::ConstSharedPtr msg);
using MapProjectorInfo = map_interface::MapProjectorInfo;

rclcpp::Subscription<MapProjectorInfo>::SharedPtr sub_map_projector_type_;
void on_map_projector_info(const MapProjectorInfo::Message::ConstSharedPtr msg);

component_interface_utils::Subscription<MapProjectorInfo>::SharedPtr sub_map_projector_type_;
rclcpp::Publisher<HADMapBin>::SharedPtr pub_map_bin_;
};

Expand Down
2 changes: 2 additions & 0 deletions map/map_loader/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

<depend>autoware_auto_mapping_msgs</depend>
<depend>autoware_map_msgs</depend>
<depend>component_interface_specs</depend>
<depend>component_interface_utils</depend>
<depend>fmt</depend>
<depend>geometry_msgs</depend>
<depend>lanelet2_extension</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@
Lanelet2MapLoaderNode::Lanelet2MapLoaderNode(const rclcpp::NodeOptions & options)
: Node("lanelet2_map_loader", options)
{
const auto adaptor = component_interface_utils::NodeAdaptor(this);

// subscription
sub_map_projector_type_ = create_subscription<MapProjectorInfo>(
"input/map_projector_info", rclcpp::QoS{1}.transient_local(),
[this](const MapProjectorInfo::ConstSharedPtr msg) { on_map_projector_info(msg); });
adaptor.init_sub(
sub_map_projector_type_,
[this](const MapProjectorInfo::Message::ConstSharedPtr msg) { on_map_projector_info(msg); });
}

void Lanelet2MapLoaderNode::on_map_projector_info(const MapProjectorInfo::ConstSharedPtr msg)
void Lanelet2MapLoaderNode::on_map_projector_info(
const MapProjectorInfo::Message::ConstSharedPtr msg)
{
const auto lanelet2_filename = declare_parameter("lanelet2_map_path", "");
const auto center_line_resolution = declare_parameter("center_line_resolution", 5.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

#include "rclcpp/rclcpp.hpp"

#include "tier4_map_msgs/msg/map_projector_info.hpp"
#include <component_interface_specs/map.hpp>
#include <component_interface_utils/rclcpp.hpp>

#include <string>

Expand All @@ -29,7 +30,8 @@ class MapProjectionLoader : public rclcpp::Node
MapProjectionLoader();

private:
rclcpp::Publisher<tier4_map_msgs::msg::MapProjectorInfo>::SharedPtr publisher_;
using MapProjectorInfo = map_interface::MapProjectorInfo;
component_interface_utils::Publisher<MapProjectorInfo>::SharedPtr publisher_;
};

#endif // MAP_PROJECTION_LOADER__MAP_PROJECTION_LOADER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<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">
<remap from="~/map_projector_info" to="/map/map_projector_type"/>
<param name="map_projector_info_path" value="$(var map_projector_info_path)"/>
<param name="lanelet2_map_path" value="$(var lanelet2_map_path)"/>
</node>
Expand Down
2 changes: 2 additions & 0 deletions map/map_projection_loader/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>component_interface_specs</depend>
<depend>component_interface_utils</depend>
<depend>lanelet2_extension</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
Expand Down
6 changes: 4 additions & 2 deletions map/map_projection_loader/src/map_projection_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "map_projection_loader/load_info_from_lanelet2_map.hpp"

#include <tier4_map_msgs/msg/map_projector_info.hpp>

#include <yaml-cpp/yaml.h>

#include <fstream>
Expand Down Expand Up @@ -64,7 +66,7 @@ MapProjectionLoader::MapProjectionLoader() : Node("map_projection_loader")
}

// Publish the message
publisher_ = this->create_publisher<tier4_map_msgs::msg::MapProjectorInfo>(
"~/map_projector_info", rclcpp::QoS(rclcpp::KeepLast(1)).transient_local());
const auto adaptor = component_interface_utils::NodeAdaptor(this);
adaptor.init_pub(publisher_);
publisher_->publish(msg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_node_link(self):
# Create subscription to map_projector_info topic
subscription = self.test_node.create_subscription(
MapProjectorInfo,
"/map_projection_loader/map_projector_info",
"/map/map_projector_type",
self.callback,
custom_qos_profile,
)
Expand All @@ -125,7 +125,7 @@ def test_node_link(self):
get_package_share_directory("map_projection_loader"), YAML_FILE_PATH
)
with open(map_projection_info_path) as f:
yaml_data = yaml.load(f)
yaml_data = yaml.load(f, Loader=yaml.FullLoader)

# Test if message received
self.assertIsNotNone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_node_link(self):
# Create subscription to map_projector_info topic
subscription = self.test_node.create_subscription(
MapProjectorInfo,
"/map_projection_loader/map_projector_info",
"/map/map_projector_type",
self.callback,
custom_qos_profile,
)
Expand All @@ -125,7 +125,7 @@ def test_node_link(self):
get_package_share_directory("map_projection_loader"), YAML_FILE_PATH
)
with open(map_projection_info_path) as f:
yaml_data = yaml.load(f)
yaml_data = yaml.load(f, Loader=yaml.FullLoader)

# Test if message received
self.assertIsNotNone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_node_link(self):
# Create subscription to map_projector_info topic
subscription = self.test_node.create_subscription(
MapProjectorInfo,
"/map_projection_loader/map_projector_info",
"/map/map_projector_type",
self.callback,
custom_qos_profile,
)
Expand All @@ -125,7 +125,7 @@ def test_node_link(self):
get_package_share_directory("map_projection_loader"), YAML_FILE_PATH
)
with open(map_projection_info_path) as f:
yaml_data = yaml.load(f)
yaml_data = yaml.load(f, Loader=yaml.FullLoader)

# Test if message received
self.assertIsNotNone(
Expand Down

0 comments on commit 1bfdede

Please sign in to comment.