From 92e00c3c119af4bfc7c9032f99e6bfea35f40ab1 Mon Sep 17 00:00:00 2001 From: santosh-interplai Date: Fri, 1 Dec 2023 14:30:43 +0530 Subject: [PATCH] refactor-traffic_light_map_based_detector Signed-off-by: santosh-interplai Signed-off-by: karishma --- ...raffic_light_map_based_detector.param.yaml | 13 +-- ...affic_light_map_based_detector.schema.json | 80 +++++++++++++++++++ .../src/node.cpp | 18 ++--- 3 files changed, 97 insertions(+), 14 deletions(-) create mode 100644 perception/traffic_light_map_based_detector/schema/traffic_light_map_based_detector.schema.json diff --git a/perception/traffic_light_map_based_detector/config/traffic_light_map_based_detector.param.yaml b/perception/traffic_light_map_based_detector/config/traffic_light_map_based_detector.param.yaml index 2b8ff4aa737b7..462cfecf46a6a 100644 --- a/perception/traffic_light_map_based_detector/config/traffic_light_map_based_detector.param.yaml +++ b/perception/traffic_light_map_based_detector/config/traffic_light_map_based_detector.param.yaml @@ -1,8 +1,11 @@ /**: ros__parameters: - max_vibration_pitch: 0.01745329251 # -0.5 ~ 0.5 deg - max_vibration_yaw: 0.01745329251 # -0.5 ~ 0.5 deg - max_vibration_height: 0.5 # -0.25 ~ 0.25 m - max_vibration_width: 0.5 # -0.25 ~ 0.25 m - max_vibration_depth: 0.5 # -0.25 ~ 0.25 m + max_vibration_pitch: 0.01745329251 # -0.5 ~ 0.5 deg + max_vibration_yaw: 0.01745329251 # -0.5 ~ 0.5 deg + max_vibration_height: 0.5 # -0.25 ~ 0.25 m + max_vibration_width: 0.5 # -0.25 ~ 0.25 m + max_vibration_depth: 0.5 # -0.25 ~ 0.25 m max_detection_range: 200.0 + min_timestamp_offset: 0.0 + max_timestamp_offset: 0.0 + timestamp_sample_len: 0.01 diff --git a/perception/traffic_light_map_based_detector/schema/traffic_light_map_based_detector.schema.json b/perception/traffic_light_map_based_detector/schema/traffic_light_map_based_detector.schema.json new file mode 100644 index 0000000000000..7321be6243710 --- /dev/null +++ b/perception/traffic_light_map_based_detector/schema/traffic_light_map_based_detector.schema.json @@ -0,0 +1,80 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Parameters for Traffic Light Map Based Detector", + "type": "object", + "definitions": { + "traffic_light_map_based_detector": { + "type": "object", + "properties": { + "max_vibration_pitch": { + "type": "number", + "default": 0.01745329251, + "description": "Maximum error in pitch direction. If -5~+5, it will be 10." + }, + "max_vibration_yaw": { + "type": "number", + "default": 0.01745329251, + "description": "Maximum error in yaw direction. If -5~+5, it will be 10." + }, + "max_vibration_height": { + "type": "number", + "default": 0.5, + "description": "Maximum error in height direction. If -5~+5, it will be 10." + }, + "max_vibration_width": { + "type": "number", + "default": 0.5, + "description": "Maximum error in width direction. If -5~+5, it will be 10." + }, + "max_vibration_depth": { + "type": "number", + "default": 0.5, + "description": "Maximum error in depth direction. If -5~+5, it will be 10." + }, + "max_detection_range": { + "type": "number", + "default": 200.0, + "description": "Maximum detection range in meters. Must be positive" + }, + "min_timestamp_offset": { + "type": "number", + "default": 0.0, + "description": "Minimum timestamp offset when searching for corresponding tf" + }, + "max_timestamp_offset": { + "type": "number", + "default": 0.0, + "description": "Maximum timestamp offset when searching for corresponding tf" + }, + "timestamp_sample_len": { + "type": "number", + "default": 0.01, + "description": "sampling length between min_timestamp_offset and max_timestamp_offset" + } + }, + "required": [ + "max_vibration_pitch", + "max_vibration_yaw", + "max_vibration_height", + "max_vibration_width", + "max_vibration_depth", + "max_detection_range", + "min_timestamp_offset", + "max_timestamp_offset", + "timestamp_sample_len" + ] + } + }, + "properties": { + "/**": { + "type": "object", + "properties": { + "ros__parameters": { + "$ref": "#/definitions/traffic_light_map_based_detector" + } + }, + "required": ["ros__parameters"] + } + }, + "required": ["/**"] +} diff --git a/perception/traffic_light_map_based_detector/src/node.cpp b/perception/traffic_light_map_based_detector/src/node.cpp index f0a5d7b7b1fde..65a9b3f99dee8 100644 --- a/perception/traffic_light_map_based_detector/src/node.cpp +++ b/perception/traffic_light_map_based_detector/src/node.cpp @@ -128,15 +128,15 @@ MapBasedDetector::MapBasedDetector(const rclcpp::NodeOptions & node_options) using std::placeholders::_1; // parameter declaration needs default values: are 0.0 goof defaults for this? - config_.max_vibration_pitch = declare_parameter("max_vibration_pitch", 0.0); - config_.max_vibration_yaw = declare_parameter("max_vibration_yaw", 0.0); - config_.max_vibration_height = declare_parameter("max_vibration_height", 0.0); - config_.max_vibration_width = declare_parameter("max_vibration_width", 0.0); - config_.max_vibration_depth = declare_parameter("max_vibration_depth", 0.0); - config_.min_timestamp_offset = declare_parameter("min_timestamp_offset", 0.0); - config_.max_timestamp_offset = declare_parameter("max_timestamp_offset", 0.0); - config_.timestamp_sample_len = declare_parameter("timestamp_sample_len", 0.01); - config_.max_detection_range = declare_parameter("max_detection_range", 200.0); + config_.max_vibration_pitch = declare_parameter("max_vibration_pitch"); + config_.max_vibration_yaw = declare_parameter("max_vibration_yaw"); + config_.max_vibration_height = declare_parameter("max_vibration_height"); + config_.max_vibration_width = declare_parameter("max_vibration_width"); + config_.max_vibration_depth = declare_parameter("max_vibration_depth"); + config_.min_timestamp_offset = declare_parameter("min_timestamp_offset"); + config_.max_timestamp_offset = declare_parameter("max_timestamp_offset"); + config_.timestamp_sample_len = declare_parameter("timestamp_sample_len"); + config_.max_detection_range = declare_parameter("max_detection_range"); if (config_.max_detection_range <= 0) { RCLCPP_ERROR_STREAM(