From 1b038ce2b4df1fa56bef95ef18d2dee0655421ed Mon Sep 17 00:00:00 2001 From: mitukou1109 Date: Fri, 13 Sep 2024 10:17:26 +0900 Subject: [PATCH 1/2] add parameter description Signed-off-by: mitukou1109 --- control/autoware_shift_decider/CMakeLists.txt | 8 ++++++++ control/autoware_shift_decider/package.xml | 1 + .../param/shift_decider_parameters.yaml | 4 ++++ 3 files changed, 13 insertions(+) create mode 100644 control/autoware_shift_decider/param/shift_decider_parameters.yaml diff --git a/control/autoware_shift_decider/CMakeLists.txt b/control/autoware_shift_decider/CMakeLists.txt index 269b0fcc33690..7d26ce72188de 100644 --- a/control/autoware_shift_decider/CMakeLists.txt +++ b/control/autoware_shift_decider/CMakeLists.txt @@ -4,10 +4,18 @@ project(autoware_shift_decider) find_package(autoware_cmake REQUIRED) autoware_package() +generate_parameter_library(shift_decider_parameters + param/shift_decider_parameters.yaml +) + ament_auto_add_library(${PROJECT_NAME}_node SHARED src/${PROJECT_NAME}.cpp ) +target_link_libraries(${PROJECT_NAME}_node + shift_decider_parameters +) + rclcpp_components_register_node(${PROJECT_NAME}_node PLUGIN "autoware::shift_decider::ShiftDecider" EXECUTABLE ${PROJECT_NAME} diff --git a/control/autoware_shift_decider/package.xml b/control/autoware_shift_decider/package.xml index fb7811e094dc2..27e814aac8401 100644 --- a/control/autoware_shift_decider/package.xml +++ b/control/autoware_shift_decider/package.xml @@ -17,6 +17,7 @@ autoware_system_msgs autoware_universe_utils autoware_vehicle_msgs + generate_parameter_library rclcpp rclcpp_components diff --git a/control/autoware_shift_decider/param/shift_decider_parameters.yaml b/control/autoware_shift_decider/param/shift_decider_parameters.yaml new file mode 100644 index 0000000000000..294421d79cd6e --- /dev/null +++ b/control/autoware_shift_decider/param/shift_decider_parameters.yaml @@ -0,0 +1,4 @@ +shift_decider: + park_on_goal: + type: bool + description: Whether to put the gear in park when vehicle reaches the goal. From 046c7f30932ce7046d14b098a7acff4dfd587cac Mon Sep 17 00:00:00 2001 From: mitukou1109 Date: Fri, 13 Sep 2024 11:45:35 +0900 Subject: [PATCH 2/2] use parameter listener Signed-off-by: mitukou1109 --- .../autoware/shift_decider/autoware_shift_decider.hpp | 4 +++- .../autoware_shift_decider/src/autoware_shift_decider.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/control/autoware_shift_decider/include/autoware/shift_decider/autoware_shift_decider.hpp b/control/autoware_shift_decider/include/autoware/shift_decider/autoware_shift_decider.hpp index c7ce822d1ac18..74990aa55a992 100644 --- a/control/autoware_shift_decider/include/autoware/shift_decider/autoware_shift_decider.hpp +++ b/control/autoware_shift_decider/include/autoware/shift_decider/autoware_shift_decider.hpp @@ -16,6 +16,7 @@ #define AUTOWARE__SHIFT_DECIDER__AUTOWARE_SHIFT_DECIDER_HPP_ #include "autoware/universe_utils/ros/polling_subscriber.hpp" +#include "shift_decider_parameters.hpp" #include @@ -58,7 +59,8 @@ class ShiftDecider : public rclcpp::Node autoware_vehicle_msgs::msg::GearReport::ConstSharedPtr current_gear_ptr_; uint8_t prev_shift_command = autoware_vehicle_msgs::msg::GearCommand::PARK; - bool park_on_goal_; + std::shared_ptr<::shift_decider::ParamListener> param_listener_; + ::shift_decider::Params param_; }; } // namespace autoware::shift_decider diff --git a/control/autoware_shift_decider/src/autoware_shift_decider.cpp b/control/autoware_shift_decider/src/autoware_shift_decider.cpp index 846eaabee4b88..c9c3b5cc6ad6d 100644 --- a/control/autoware_shift_decider/src/autoware_shift_decider.cpp +++ b/control/autoware_shift_decider/src/autoware_shift_decider.cpp @@ -31,7 +31,9 @@ ShiftDecider::ShiftDecider(const rclcpp::NodeOptions & node_options) rclcpp::QoS durable_qos(queue_size); durable_qos.transient_local(); - park_on_goal_ = declare_parameter("park_on_goal"); + param_listener_ = + std::make_shared<::shift_decider::ParamListener>(this->get_node_parameters_interface()); + param_ = param_listener_->get_params(); pub_shift_cmd_ = create_publisher("output/gear_cmd", durable_qos); @@ -71,7 +73,7 @@ void ShiftDecider::updateCurrentShiftCmd() if ( (autoware_state_->state == AutowareState::ARRIVED_GOAL || autoware_state_->state == AutowareState::WAITING_FOR_ROUTE) && - park_on_goal_) { + param_.park_on_goal) { shift_cmd_.command = GearCommand::PARK; } else { shift_cmd_.command = current_gear_ptr_->report;