From 5e3684065d84ebaa6334f255455e24647a13fb1b Mon Sep 17 00:00:00 2001 From: Vishal Chauhan <40782713+vish0012@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:01:51 +0900 Subject: [PATCH] feat(autoware_traffic_light_fine_detector): created the schema file,updated the readme file and deleted the default parameter in node files code (#10106) * feat(autoware_traffic_light_fine_detector): Created the schema file, updated the readme file and deleted the default parameter in node files code Signed-off-by: vish0012 * style(pre-commit): autofix * fix declare_parameter Signed-off-by: MasatoSaeki * chore Signed-off-by: MasatoSaeki * change launch file Signed-off-by: MasatoSaeki * change type Signed-off-by: MasatoSaeki * style(pre-commit): autofix * fix definition name Signed-off-by: MasatoSaeki * run build Signed-off-by: MasatoSaeki --------- Signed-off-by: vish0012 Signed-off-by: MasatoSaeki Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: MasatoSaeki --- .../README.md | 18 +---- .../traffic_light_fine_detector.launch.xml | 4 ++ .../traffic_light_fine_detector.schema.json | 71 +++++++++++++++++++ .../src/traffic_light_fine_detector_node.cpp | 17 ++--- 4 files changed, 85 insertions(+), 25 deletions(-) create mode 100644 perception/autoware_traffic_light_fine_detector/schema/traffic_light_fine_detector.schema.json diff --git a/perception/autoware_traffic_light_fine_detector/README.md b/perception/autoware_traffic_light_fine_detector/README.md index 05a3da5d82e64..1216deda552c1 100644 --- a/perception/autoware_traffic_light_fine_detector/README.md +++ b/perception/autoware_traffic_light_fine_detector/README.md @@ -43,23 +43,7 @@ ROIs detected from YOLOX will be selected by a combination of `expect/rois`. At ## Parameters -### Core Parameters - -| Name | Type | Default Value | Description | -| ---------------------------- | ------ | ------------- | ---------------------------------------------------------------------- | -| `fine_detector_score_thresh` | double | 0.3 | If the objectness score is less than this value, the object is ignored | -| `fine_detector_nms_thresh` | double | 0.65 | IoU threshold to perform Non-Maximum Suppression | - -### Node Parameters - -| Name | Type | Default Value | Description | -| -------------------------- | ------- | --------------------------- | ------------------------------------------------------------------ | -| `data_path` | string | "$(env HOME)/autoware_data" | packages data and artifacts directory path | -| `fine_detector_model_path` | string | "" | The onnx file name for yolo model | -| `fine_detector_label_path` | string | "" | The label file with label names for detected objects written on it | -| `fine_detector_precision` | string | "fp16" | The inference mode: "fp32", "fp16" | -| `approximate_sync` | bool | false | Flag for whether to ues approximate sync policy | -| `gpu_id` | integer | 0 | ID for the selecting CUDA GPU device | +{{ json_to_markdown("perception/autoware_traffic_light_fine_detector/schema/traffic_light_fine_detector.schema.json") }} | ## Assumptions / Known limits diff --git a/perception/autoware_traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml b/perception/autoware_traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml index 3a44e0c3bdfe0..4f876311621de 100644 --- a/perception/autoware_traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml +++ b/perception/autoware_traffic_light_fine_detector/launch/traffic_light_fine_detector.launch.xml @@ -3,11 +3,15 @@ + + + + diff --git a/perception/autoware_traffic_light_fine_detector/schema/traffic_light_fine_detector.schema.json b/perception/autoware_traffic_light_fine_detector/schema/traffic_light_fine_detector.schema.json new file mode 100644 index 0000000000000..a560b903188be --- /dev/null +++ b/perception/autoware_traffic_light_fine_detector/schema/traffic_light_fine_detector.schema.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "autoware_traffic_light_fine_detector parameter", + "type": "object", + "definitions": { + "traffic_light_fine_detector": { + "type": "object", + "properties": { + "fine_detector_label_path": { + "type": "string", + "description": "The label file with label names for detected objects written on it.", + "default": "$(var traffic_light_fine_detector_model_path)/$(var traffic_light_fine_detector_label_name)" + }, + "fine_detector_model_path": { + "type": "string", + "description": "The ONNX file name for the YOLO model.", + "default": "$(var traffic_light_fine_detector_model_path)/$(var traffic_light_fine_detector_model_name).onnx" + }, + "fine_detector_precision": { + "type": "string", + "description": "Precision used for traffic light fine detector inference. Valid values: [fp32, fp16].", + "default": "fp16" + }, + "fine_detector_score_thresh": { + "type": "number", + "description": "If the objectness score is less than this value, the object is ignored.", + "default": 0.3 + }, + "fine_detector_nms_thresh": { + "type": "number", + "description": "IoU threshold to perform Non-Maximum Suppression (NMS).", + "default": 0.65 + }, + "approximate_sync": { + "type": "boolean", + "description": "Flag for whether to use approximate sync policy.", + "default": false + }, + "gpu_id": { + "type": "integer", + "description": "ID for selecting the CUDA GPU device.", + "default": 0 + } + }, + "required": [ + "fine_detector_label_path", + "fine_detector_model_path", + "fine_detector_precision", + "fine_detector_score_thresh", + "fine_detector_nms_thresh", + "approximate_sync", + "gpu_id" + ], + "additionalProperties": false + } + }, + "properties": { + "/**": { + "type": "object", + "properties": { + "ros__parameters": { + "$ref": "#/definitions/traffic_light_fine_detector" + } + }, + "required": ["ros__parameters"], + "additionalProperties": false + } + }, + "required": ["/**"], + "additionalProperties": false +} diff --git a/perception/autoware_traffic_light_fine_detector/src/traffic_light_fine_detector_node.cpp b/perception/autoware_traffic_light_fine_detector/src/traffic_light_fine_detector_node.cpp index 8e2b2d5b3cfbb..e15908e82bb52 100644 --- a/perception/autoware_traffic_light_fine_detector/src/traffic_light_fine_detector_node.cpp +++ b/perception/autoware_traffic_light_fine_detector/src/traffic_light_fine_detector_node.cpp @@ -59,17 +59,18 @@ TrafficLightFineDetectorNode::TrafficLightFineDetectorNode(const rclcpp::NodeOpt using std::placeholders::_2; using std::placeholders::_3; - std::string model_path = declare_parameter("fine_detector_model_path", ""); - std::string label_path = declare_parameter("fine_detector_label_path", ""); - std::string precision = declare_parameter("fine_detector_precision", "fp16"); - const uint8_t gpu_id = declare_parameter("gpu_id", 0); + std::string model_path = this->declare_parameter("fine_detector_model_path"); + std::string label_path = this->declare_parameter("fine_detector_label_path"); + std::string precision = this->declare_parameter("fine_detector_precision"); + const uint8_t gpu_id = this->declare_parameter("gpu_id"); // Objects with a score lower than this value will be ignored. // This threshold will be ignored if specified model contains EfficientNMS_TRT module in it - score_thresh_ = declare_parameter("fine_detector_score_thresh", 0.3); + score_thresh_ = this->declare_parameter("fine_detector_score_thresh"); // Detection results will be ignored if IoU over this value. // This threshold will be ignored if specified model contains EfficientNMS_TRT module in it - float nms_threshold = declare_parameter("fine_detector_nms_thresh", 0.65); - is_approximate_sync_ = this->declare_parameter("approximate_sync", false); + float nms_threshold = + static_cast(this->declare_parameter("fine_detector_nms_thresh")); + is_approximate_sync_ = this->declare_parameter("approximate_sync"); if (!readLabelFile(label_path, tlr_label_id_, num_class)) { RCLCPP_ERROR(this->get_logger(), "Could not find tlr id"); @@ -113,7 +114,7 @@ TrafficLightFineDetectorNode::TrafficLightFineDetectorNode(const rclcpp::NodeOpt sync_->registerCallback(std::bind(&TrafficLightFineDetectorNode::callback, this, _1, _2, _3)); } - if (declare_parameter("build_only", false)) { + if (this->declare_parameter("build_only")) { RCLCPP_INFO(get_logger(), "TensorRT engine is built and shutdown node."); rclcpp::shutdown(); }