From c4cb3f2141e8ec27e04590b3bc85a33297a67108 Mon Sep 17 00:00:00 2001 From: shalenikol Date: Wed, 7 May 2025 17:45:46 +0300 Subject: [PATCH] add launch for compressed images --- .../launch/image_compressed_to_raw.launch.py | 75 ++++++++++++++++++ .../launch/image_raw_to_compressed.launch.py | 76 +++++++++++++++++++ rbs_utils/rbs_utils/package.xml | 1 + 3 files changed, 152 insertions(+) create mode 100644 rbs_utils/rbs_utils/launch/image_compressed_to_raw.launch.py create mode 100644 rbs_utils/rbs_utils/launch/image_raw_to_compressed.launch.py diff --git a/rbs_utils/rbs_utils/launch/image_compressed_to_raw.launch.py b/rbs_utils/rbs_utils/launch/image_compressed_to_raw.launch.py new file mode 100644 index 0000000..a0ed023 --- /dev/null +++ b/rbs_utils/rbs_utils/launch/image_compressed_to_raw.launch.py @@ -0,0 +1,75 @@ +""" + https://github.com/clearpathrobotics/clearpath_robot + +# Software License Agreement (BSD) +# +# @author Roni Kreinin +# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of Clearpath Robotics nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +""" +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + namespace = LaunchConfiguration('namespace') + in_compressed = LaunchConfiguration('in_compressed') + out_raw = LaunchConfiguration('out_raw') + + arg_namespace = DeclareLaunchArgument( + 'namespace', + default_value='' + ) + + arg_in_compressed = DeclareLaunchArgument( + 'in_compressed', + default_value='compressed' + ) + + arg_out_raw = DeclareLaunchArgument( + 'out_raw', + default_value='image' + ) + + compressed_transport_node = Node( + name='image_compressed_to_raw', + namespace=namespace, + package='image_transport', + executable='republish', + remappings=[ + ('in/compressed', in_compressed), + ('out', out_raw), + ], + arguments=['compressed', 'raw'], + ) + + ld = LaunchDescription() + ld.add_action(arg_namespace) + ld.add_action(arg_in_compressed) + ld.add_action(arg_out_raw) + ld.add_action(compressed_transport_node) + return ld diff --git a/rbs_utils/rbs_utils/launch/image_raw_to_compressed.launch.py b/rbs_utils/rbs_utils/launch/image_raw_to_compressed.launch.py new file mode 100644 index 0000000..2e99fbb --- /dev/null +++ b/rbs_utils/rbs_utils/launch/image_raw_to_compressed.launch.py @@ -0,0 +1,76 @@ +""" + https://github.com/clearpathrobotics/clearpath_robot + +# Software License Agreement (BSD) +# +# @author Roni Kreinin +# @copyright (c) 2023, Clearpath Robotics, Inc., All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# * Neither the name of Clearpath Robotics nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +""" + +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration +from launch_ros.actions import Node + + +def generate_launch_description(): + namespace = LaunchConfiguration('namespace') + in_raw = LaunchConfiguration('in_raw') + out_compressed = LaunchConfiguration('out_compressed') + + arg_namespace = DeclareLaunchArgument( + 'namespace', + default_value='' + ) + + arg_in_raw = DeclareLaunchArgument( + 'in_raw', + default_value='image' + ) + + arg_out_compressed = DeclareLaunchArgument( + 'out_compressed', + default_value='compressed' + ) + + compressed_transport_node = Node( + name='image_raw_to_compressed', + namespace=namespace, + package='image_transport', + executable='republish', + remappings=[ + ('in', in_raw), + ('out/compressed', out_compressed), + ], + arguments=['raw', 'compressed'], + ) + + ld = LaunchDescription() + ld.add_action(arg_namespace) + ld.add_action(arg_in_raw) + ld.add_action(arg_out_compressed) + ld.add_action(compressed_transport_node) + return ld diff --git a/rbs_utils/rbs_utils/package.xml b/rbs_utils/rbs_utils/package.xml index 7a1e0da..cdf36f6 100644 --- a/rbs_utils/rbs_utils/package.xml +++ b/rbs_utils/rbs_utils/package.xml @@ -22,6 +22,7 @@ sensor_msgs nlohmann-json-dev rosbag2_cpp + image_transport ament_lint_auto ament_lint_common