Skip to content

Commit

Permalink
feat(remaining_distance_time_calculator): integrate generate_paramete…
Browse files Browse the repository at this point in the history
…r_library (autowarefoundation#8826)

* add parameter description

Signed-off-by: mitukou1109 <[email protected]>

* use parameter listener

Signed-off-by: mitukou1109 <[email protected]>

* supress deprecated error

Signed-off-by: mitukou1109 <[email protected]>

* change scope of compile option to private

Signed-off-by: mitukou1109 <[email protected]>

---------

Signed-off-by: mitukou1109 <[email protected]>
  • Loading branch information
mitukou1109 authored and esteve committed Jan 15, 2025
1 parent 9ff93ff commit 6e97b7e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ project(autoware_remaining_distance_time_calculator)
find_package(autoware_cmake REQUIRED)
autoware_package()

generate_parameter_library(remaining_distance_time_calculator_parameters
param/remaining_distance_time_calculator_parameters.yaml
)

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

target_link_libraries(${PROJECT_NAME}
remaining_distance_time_calculator_parameters
)

target_compile_options(${PROJECT_NAME} PRIVATE
-Wno-error=deprecated-declarations
)

rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "autoware::remaining_distance_time_calculator::RemainingDistanceTimeCalculatorNode"
EXECUTABLE ${PROJECT_NAME}_node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<depend>autoware_route_handler</depend>
<depend>autoware_test_utils</depend>
<depend>autoware_universe_utils</depend>
<depend>generate_parameter_library</depend>
<depend>geometry_msgs</depend>
<depend>nav_msgs</depend>
<depend>rclcpp</depend>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
remaining_distance_time_calculator:
update_rate:
type: double
description: Timer callback period. [Hz]
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ RemainingDistanceTimeCalculatorNode::RemainingDistanceTimeCalculatorNode(
"~/output/mission_remaining_distance_time",
rclcpp::QoS(rclcpp::KeepLast(10)).durability_volatile().reliable());

node_param_.update_rate = declare_parameter<double>("update_rate");
param_listener_ = std::make_shared<::remaining_distance_time_calculator::ParamListener>(
this->get_node_parameters_interface());
const auto param = param_listener_->get_params();

const auto period_ns = rclcpp::Rate(node_param_.update_rate).period();
const auto period_ns = rclcpp::Rate(param.update_rate).period();
timer_ = rclcpp::create_timer(
this, get_clock(), period_ns, std::bind(&RemainingDistanceTimeCalculatorNode::on_timer, this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <autoware/route_handler/route_handler.hpp>
#include <rclcpp/rclcpp.hpp>
#include <remaining_distance_time_calculator_parameters.hpp>

#include <autoware_internal_msgs/msg/mission_remaining_distance_time.hpp>
#include <autoware_map_msgs/msg/lanelet_map_bin.hpp>
Expand All @@ -39,11 +40,6 @@
namespace autoware::remaining_distance_time_calculator
{

struct NodeParam
{
double update_rate{0.0};
};

class RemainingDistanceTimeCalculatorNode : public rclcpp::Node
{
public:
Expand Down Expand Up @@ -86,7 +82,7 @@ class RemainingDistanceTimeCalculatorNode : public rclcpp::Node
double remaining_time_;

// Parameter
NodeParam node_param_;
std::shared_ptr<::remaining_distance_time_calculator::ParamListener> param_listener_;

// Callbacks
void on_timer();
Expand Down

0 comments on commit 6e97b7e

Please sign in to comment.