Skip to content

Commit

Permalink
feat(dummy_diag_publisher): componentize node (autowarefoundation#7190)
Browse files Browse the repository at this point in the history
Signed-off-by: Takagi, Isamu <[email protected]>
  • Loading branch information
isamu-takagi authored and karishma1911 committed Jun 3, 2024
1 parent 65c6a36 commit 0850eb4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 36 deletions.
8 changes: 6 additions & 2 deletions system/dummy_diag_publisher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ project(dummy_diag_publisher)
find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_executable(${PROJECT_NAME}
src/dummy_diag_publisher_node.cpp
ament_auto_add_library(${PROJECT_NAME} SHARED
src/dummy_diag_publisher_core.cpp
)

rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "DummyDiagPublisher"
EXECUTABLE ${PROJECT_NAME}_node
)

ament_auto_package(INSTALL_TO_SHARE
launch
config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct DiagConfig
class DummyDiagPublisher : public rclcpp::Node
{
public:
DummyDiagPublisher();
explicit DummyDiagPublisher(const rclcpp::NodeOptions & options);

private:
enum Status {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<arg name="update_rate" default="10.0"/>

<group>
<node pkg="dummy_diag_publisher" exec="dummy_diag_publisher" name="dummy_diag_publisher" output="screen">
<node pkg="dummy_diag_publisher" exec="dummy_diag_publisher_node" name="dummy_diag_publisher" output="screen">
<param from="$(var config_file)"/>
<param from="$(var extra_config_file_sensor)"/>
<param name="update_rate" value="$(var update_rate)"/>
Expand Down
17 changes: 11 additions & 6 deletions system/dummy_diag_publisher/src/dummy_diag_publisher_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ void DummyDiagPublisher::onTimer()
updater_.force_update();
}

DummyDiagPublisher::DummyDiagPublisher()
: Node(
"dummy_diag_publisher", rclcpp::NodeOptions()
.allow_undeclared_parameters(true)
.automatically_declare_parameters_from_overrides(true)),
updater_(this)
rclcpp::NodeOptions override_options(rclcpp::NodeOptions options)
{
return options.allow_undeclared_parameters(true).automatically_declare_parameters_from_overrides(
true);
}

DummyDiagPublisher::DummyDiagPublisher(const rclcpp::NodeOptions & options)
: Node("dummy_diag_publisher", override_options(options)), updater_(this)

{
// Parameter
Expand All @@ -277,3 +279,6 @@ DummyDiagPublisher::DummyDiagPublisher()
timer_ = rclcpp::create_timer(
this, get_clock(), period_ns, std::bind(&DummyDiagPublisher::onTimer, this));
}

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(DummyDiagPublisher)
26 changes: 0 additions & 26 deletions system/dummy_diag_publisher/src/dummy_diag_publisher_node.cpp

This file was deleted.

0 comments on commit 0850eb4

Please sign in to comment.