From 9fd6d551e9609e5f0bc020b253cf44dd79f47708 Mon Sep 17 00:00:00 2001 From: oguzkaganozt Date: Mon, 10 Jun 2024 13:15:57 +0300 Subject: [PATCH] refactor(sensing/image_transport_decompressor): rework parameters (#6746) * add param, schema file, update readme Signed-off-by: oguzkaganozt * style(pre-commit): autofix --------- Signed-off-by: oguzkaganozt Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Kenzo Lobos Tsunekawa Co-authored-by: Yoshi Ri --- .../image_transport_decompressor/README.md | 2 ++ .../image_transport_decompressor.param.yaml | 3 ++ .../image_transport_decompressor.launch.xml | 2 ++ .../image_transport_decompressor.schema.json | 30 +++++++++++++++++++ .../src/image_transport_decompressor.cpp | 2 +- 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 sensing/image_transport_decompressor/config/image_transport_decompressor.param.yaml create mode 100644 sensing/image_transport_decompressor/schema/image_transport_decompressor.schema.json diff --git a/sensing/image_transport_decompressor/README.md b/sensing/image_transport_decompressor/README.md index 1a2b18f91c17a..97e0178eb00d6 100644 --- a/sensing/image_transport_decompressor/README.md +++ b/sensing/image_transport_decompressor/README.md @@ -22,6 +22,8 @@ The `image_transport_decompressor` is a node that decompresses images. ## Parameters +{{ json_to_markdown("sensing/image_transport_decompressor/schema/image_transport_decompressor.schema.json") }} + ## Assumptions / Known limits ## (Optional) Error detection and handling diff --git a/sensing/image_transport_decompressor/config/image_transport_decompressor.param.yaml b/sensing/image_transport_decompressor/config/image_transport_decompressor.param.yaml new file mode 100644 index 0000000000000..05b0f0b64a09a --- /dev/null +++ b/sensing/image_transport_decompressor/config/image_transport_decompressor.param.yaml @@ -0,0 +1,3 @@ +/**: + ros__parameters: + encoding: default diff --git a/sensing/image_transport_decompressor/launch/image_transport_decompressor.launch.xml b/sensing/image_transport_decompressor/launch/image_transport_decompressor.launch.xml index f608d504733bf..61296531f17f2 100644 --- a/sensing/image_transport_decompressor/launch/image_transport_decompressor.launch.xml +++ b/sensing/image_transport_decompressor/launch/image_transport_decompressor.launch.xml @@ -1,9 +1,11 @@ + + diff --git a/sensing/image_transport_decompressor/schema/image_transport_decompressor.schema.json b/sensing/image_transport_decompressor/schema/image_transport_decompressor.schema.json new file mode 100644 index 0000000000000..fdbe1bcd721dd --- /dev/null +++ b/sensing/image_transport_decompressor/schema/image_transport_decompressor.schema.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Parameters for Image Transport Decompressor", + "type": "object", + "definitions": { + "image_transport_decompressor": { + "type": "object", + "properties": { + "encoding": { + "type": "string", + "description": "The image encoding to use for the decompressed image", + "default": "default" + } + }, + "required": ["encoding"] + } + }, + "properties": { + "/**": { + "type": "object", + "properties": { + "ros__parameters": { + "$ref": "#/definitions/image_transport_decompressor" + } + }, + "required": ["ros__parameters"] + } + }, + "required": ["/**"] +} diff --git a/sensing/image_transport_decompressor/src/image_transport_decompressor.cpp b/sensing/image_transport_decompressor/src/image_transport_decompressor.cpp index 4244facf7af12..ffc1e5865c856 100644 --- a/sensing/image_transport_decompressor/src/image_transport_decompressor.cpp +++ b/sensing/image_transport_decompressor/src/image_transport_decompressor.cpp @@ -69,7 +69,7 @@ namespace image_preprocessor { ImageTransportDecompressor::ImageTransportDecompressor(const rclcpp::NodeOptions & node_options) : rclcpp::Node("image_transport_decompressor", node_options), - encoding_(declare_parameter("encoding", "default")) + encoding_(declare_parameter("encoding")) { compressed_image_sub_ = create_subscription( "~/input/compressed_image", rclcpp::SensorDataQoS(),