Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component_interface_tools): componentize node #7023

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion common/component_interface_tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@ project(component_interface_tools)

find_package(autoware_cmake REQUIRED)
autoware_package()
ament_auto_add_executable(service_log_checker src/service_log_checker.cpp)

ament_auto_add_library(${PROJECT_NAME} SHARED
src/service_log_checker.cpp
)

rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "ServiceLogChecker"
EXECUTABLE service_log_checker_node
)

ament_auto_package(INSTALL_TO_SHARE launch)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<launch>
<node pkg="component_interface_tools" exec="service_log_checker" name="service_log_checker"/>
<node pkg="component_interface_tools" exec="service_log_checker_node"/>
</launch>
1 change: 1 addition & 0 deletions common/component_interface_tools/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<depend>diagnostic_updater</depend>
<depend>fmt</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>tier4_system_msgs</depend>
<depend>yaml_cpp_vendor</depend>

Expand Down
15 changes: 4 additions & 11 deletions common/component_interface_tools/src/service_log_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define FMT_HEADER_ONLY
#include <fmt/format.h>

ServiceLogChecker::ServiceLogChecker() : Node("service_log_checker"), diagnostics_(this)
ServiceLogChecker::ServiceLogChecker(const rclcpp::NodeOptions & options)
: Node("service_log_checker", options), diagnostics_(this)
{
sub_ = create_subscription<ServiceLog>(
"/service_log", 50, std::bind(&ServiceLogChecker::on_service_log, this, std::placeholders::_1));
Expand Down Expand Up @@ -98,13 +99,5 @@ void ServiceLogChecker::update_diagnostics(diagnostic_updater::DiagnosticStatusW
}
}

int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
rclcpp::executors::SingleThreadedExecutor executor;
auto node = std::make_shared<ServiceLogChecker>();
executor.add_node(node);
executor.spin();
executor.remove_node(node);
rclcpp::shutdown();
}
#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(ServiceLogChecker)
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class ServiceLogChecker : public rclcpp::Node
{
public:
ServiceLogChecker();
explicit ServiceLogChecker(const rclcpp::NodeOptions & options);

private:
using ServiceLog = tier4_system_msgs::msg::ServiceLog;
Expand Down
Loading