Skip to content

Commit da49a97

Browse files
authored
Merge pull request #35 from NVIDIA-ISAAC-ROS/release-2.1
Isaac ROS 2.1.0
2 parents 8ed6f2a + 1137a5a commit da49a97

File tree

38 files changed

+819
-37
lines changed

38 files changed

+819
-37
lines changed

isaac_ros_gxf/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
1313
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
1414
<package format="3">
1515
<name>isaac_ros_gxf</name>
16-
<version>2.0.0</version>
16+
<version>2.1.0</version>
1717
<description>Isaac ROS GXF</description>
1818

1919
<maintainer email="[email protected]">CY Chen</maintainer>

isaac_ros_managed_nitros/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license agreement from NVIDIA CORPORATION is strictly prohibited.
1313
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
1414
<package format="3">
1515
<name>isaac_ros_managed_nitros</name>
16-
<version>2.0.0</version>
16+
<version>2.1.0</version>
1717
<description>Utilities for leveraging NITROS in custom ROS 2 nodes</description>
1818

1919
<maintainer email="[email protected]">Hemal Shah</maintainer>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
# Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
18+
cmake_minimum_required(VERSION 3.22.1)
19+
project(custom_nitros_dnn_image_encoder LANGUAGES C CXX CUDA)
20+
21+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
22+
add_compile_options(-Wall -Wextra -Wno-narrowing)
23+
endif()
24+
25+
26+
find_package(ament_cmake_auto REQUIRED)
27+
28+
ament_auto_find_build_dependencies()
29+
30+
# image Encoder node
31+
ament_auto_add_library(image_encoder_node SHARED src/image_encoder_node.cpp)
32+
target_link_libraries(image_encoder_node cvcuda nvcv_types)
33+
rclcpp_components_register_nodes(image_encoder_node "custom_nitros_dnn_image_encoder::ImageEncoderNode")
34+
set(node_plugins "${node_plugins}custom_nitros_dnn_image_encoder::ImageEncoderNode;$<TARGET_FILE:image_encoder_node>\n")
35+
36+
if(BUILD_TESTING)
37+
find_package(ament_lint_auto REQUIRED)
38+
ament_lint_auto_find_test_dependencies()
39+
40+
41+
# The FindPythonInterp and FindPythonLibs modules are removed
42+
if(POLICY CMP0148)
43+
cmake_policy(SET CMP0148 OLD)
44+
endif()
45+
46+
find_package(launch_testing_ament_cmake REQUIRED)
47+
add_launch_test(test/custom_nitros_dnn_image_encoder_pol.py TIMEOUT "600")
48+
endif()
49+
50+
ament_auto_package(INSTALL_TO_SHARE launch)

isaac_ros_managed_nitros_examples/custom_nitros_dnn_image_encoder/COLCON_IGNORE

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
// Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
// SPDX-License-Identifier: Apache-2.0
17+
18+
#ifndef CUSTOM_NITROS_DNN_IMAGE_ENCODER__IMAGE_ENCODER_NODE_HPP_
19+
#define CUSTOM_NITROS_DNN_IMAGE_ENCODER__IMAGE_ENCODER_NODE_HPP_
20+
21+
#include <memory>
22+
#include <string>
23+
#include <vector>
24+
25+
#include "rclcpp/rclcpp.hpp"
26+
#include "isaac_ros_managed_nitros/managed_nitros_publisher.hpp"
27+
#include "isaac_ros_nitros_tensor_list_type/nitros_tensor_list.hpp"
28+
#include "sensor_msgs/msg/image.hpp"
29+
30+
#include <nvcv/Tensor.hpp>
31+
32+
#include <cvcuda/OpResize.hpp>
33+
#include <cvcuda/OpCvtColor.hpp>
34+
#include <cvcuda/OpConvertTo.hpp>
35+
#include <cvcuda/OpNormalize.hpp>
36+
#include <cvcuda/OpReformat.hpp>
37+
38+
namespace custom_nitros_dnn_image_encoder
39+
{
40+
41+
struct NVCVImageFormat
42+
{
43+
nvcv::ImageFormat interleaved_format;
44+
nvcv::ImageFormat planar_float_format;
45+
nvcv::ImageFormat interleaved_float_format;
46+
};
47+
48+
class ImageEncoderNode : public rclcpp::Node
49+
{
50+
public:
51+
explicit ImageEncoderNode(const rclcpp::NodeOptions options = rclcpp::NodeOptions());
52+
53+
~ImageEncoderNode();
54+
55+
private:
56+
void InputCallback(const sensor_msgs::msg::Image::SharedPtr msg);
57+
58+
// Subscription to input image messages
59+
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr sub_;
60+
61+
// Publisher for output NitrosTensorList messages
62+
std::shared_ptr<nvidia::isaac_ros::nitros::ManagedNitrosPublisher<
63+
nvidia::isaac_ros::nitros::NitrosTensorList>> nitros_pub_;
64+
65+
// Name of tensor in NitrosTensorList
66+
std::string tensor_name_{};
67+
std::string input_image_encoding_{};
68+
std::string output_image_encoding_{};
69+
const uint16_t output_image_width_{};
70+
const uint16_t output_image_height_{};
71+
const uint16_t input_image_width_{};
72+
const uint16_t input_image_height_{};
73+
std::vector<double> image_mean_{};
74+
std::vector<double> image_stddev_{};
75+
76+
const uint16_t batch_size_ = 1;
77+
uint16_t input_image_channels_ = 0;
78+
uint16_t output_image_channels_ = 0;
79+
80+
nvcv::TensorDataStridedCuda::Buffer input_image_buffer_;
81+
nvcv::Tensor input_image_tensor_;
82+
83+
nvcv::TensorDataStridedCuda::Buffer output_image_buffer_;
84+
nvcv::Tensor output_image_tensor_;
85+
86+
cvcuda::Resize resize_op_;
87+
cvcuda::CvtColor cvtColor_op_;
88+
cvcuda::Reformat reformat_op_;
89+
cvcuda::Normalize norm_op_;
90+
cvcuda::ConvertTo convert_op_;
91+
92+
nvcv::Tensor std_dev_tensor_;
93+
nvcv::Tensor mean_tensor_;
94+
nvcv::Tensor resized_tensor_;
95+
nvcv::Tensor color_converted_tensor_;
96+
nvcv::Tensor float_tensor_;
97+
nvcv::Tensor norm_tensor_;
98+
99+
NVCVColorConversionCode color_conversion_code_;
100+
};
101+
102+
} // namespace custom_nitros_dnn_image_encoder
103+
104+
#endif // CUSTOM_NITROS_DNN_IMAGE_ENCODER__IMAGE_ENCODER_NODE_HPP_
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
# Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# SPDX-License-Identifier: Apache-2.0
17+
import launch
18+
from launch.actions import DeclareLaunchArgument
19+
from launch.substitutions import LaunchConfiguration
20+
from launch_ros.actions import ComposableNodeContainer
21+
from launch_ros.descriptions import ComposableNode
22+
23+
24+
def generate_launch_description():
25+
"""Generate launch description for DOPE encoder->TensorRT->DOPE decoder."""
26+
launch_args = [
27+
DeclareLaunchArgument(
28+
'output_image_width',
29+
default_value='640',
30+
description='The expected output image width from custom encoder'),
31+
DeclareLaunchArgument(
32+
'output_image_height',
33+
default_value='480',
34+
description='The expected output image height from custom encoder'),
35+
DeclareLaunchArgument(
36+
'input_image_width',
37+
default_value='1920',
38+
description='The expected output image width from custom encoder'),
39+
DeclareLaunchArgument(
40+
'input_image_height',
41+
default_value='1080',
42+
description='The expected output image height from custom encoder'),
43+
DeclareLaunchArgument(
44+
'image_mean',
45+
default_value='[0.5, 0.5, 0.5]',
46+
description='The mean for image normalization'),
47+
DeclareLaunchArgument(
48+
'image_stddev',
49+
default_value='[0.5, 0.5, 0.5]',
50+
description='The standard deviation for image normalization'),
51+
DeclareLaunchArgument(
52+
'model_file_path',
53+
description='The absolute file path to the ONNX file'),
54+
DeclareLaunchArgument(
55+
'engine_file_path',
56+
default_value='/tmp/trt_engine.plan',
57+
description='The absolute file path to the TensorRT engine file'),
58+
DeclareLaunchArgument(
59+
'input_tensor_names',
60+
default_value='["input_tensor"]',
61+
description='A list of tensor names to bound to the specified input binding names'),
62+
DeclareLaunchArgument(
63+
'input_binding_names',
64+
default_value='["input"]',
65+
description='A list of input tensor binding names (specified by model)'),
66+
DeclareLaunchArgument(
67+
'input_tensor_formats',
68+
default_value='["nitros_tensor_list_nchw_rgb_f32"]',
69+
description='The nitros format of the input tensors'),
70+
DeclareLaunchArgument(
71+
'output_tensor_names',
72+
default_value='["output"]',
73+
description='A list of tensor names to bound to the specified output binding names'),
74+
DeclareLaunchArgument(
75+
'output_binding_names',
76+
default_value='["output"]',
77+
description='A list of output tensor binding names (specified by model)'),
78+
DeclareLaunchArgument(
79+
'output_tensor_formats',
80+
default_value='["nitros_tensor_list_nhwc_rgb_f32"]',
81+
description='The nitros format of the output tensors'),
82+
DeclareLaunchArgument(
83+
'tensorrt_verbose',
84+
default_value='False',
85+
description='Whether TensorRT should verbosely log or not'),
86+
DeclareLaunchArgument(
87+
'object_name',
88+
default_value='Ketchup',
89+
description='The object class that the DOPE network is detecting'),
90+
DeclareLaunchArgument(
91+
'force_engine_update',
92+
default_value='False',
93+
description='Whether TensorRT should update the TensorRT engine file or not'),
94+
]
95+
96+
# Custom Image Encoder parameters
97+
input_image_width = LaunchConfiguration('input_image_width')
98+
input_image_height = LaunchConfiguration('input_image_height')
99+
network_image_width = LaunchConfiguration('output_image_width')
100+
network_image_height = LaunchConfiguration('output_image_height')
101+
encoder_image_mean = LaunchConfiguration('image_mean')
102+
encoder_image_stddev = LaunchConfiguration('image_stddev')
103+
104+
# Tensor RT parameters
105+
model_file_path = LaunchConfiguration('model_file_path')
106+
engine_file_path = LaunchConfiguration('engine_file_path')
107+
input_tensor_names = LaunchConfiguration('input_tensor_names')
108+
input_binding_names = LaunchConfiguration('input_binding_names')
109+
input_tensor_formats = LaunchConfiguration('input_tensor_formats')
110+
output_tensor_names = LaunchConfiguration('output_tensor_names')
111+
output_binding_names = LaunchConfiguration('output_binding_names')
112+
output_tensor_formats = LaunchConfiguration('output_tensor_formats')
113+
tensorrt_verbose = LaunchConfiguration('tensorrt_verbose')
114+
force_engine_update = LaunchConfiguration('force_engine_update')
115+
116+
# DOPE Decoder parameters
117+
object_name = LaunchConfiguration('object_name')
118+
119+
encoder_node = ComposableNode(
120+
name='encoder_node',
121+
package='custom_nitros_dnn_image_encoder',
122+
plugin='custom_nitros_dnn_image_encoder::ImageEncoderNode',
123+
parameters=[{
124+
'output_image_width': network_image_width,
125+
'output_image_height': network_image_height,
126+
'image_mean': encoder_image_mean,
127+
'image_stddev': encoder_image_stddev,
128+
'input_image_height': input_image_height,
129+
'input_image_width': input_image_width
130+
}],
131+
remappings=[('/encoded_tensor', '/tensor_pub')]
132+
)
133+
134+
dope_inference_node = ComposableNode(
135+
name='dope_inference',
136+
package='isaac_ros_tensor_rt',
137+
plugin='nvidia::isaac_ros::dnn_inference::TensorRTNode',
138+
parameters=[{
139+
'model_file_path': model_file_path,
140+
'engine_file_path': engine_file_path,
141+
'input_tensor_names': input_tensor_names,
142+
'input_binding_names': input_binding_names,
143+
'input_tensor_formats': input_tensor_formats,
144+
'output_tensor_names': output_tensor_names,
145+
'output_binding_names': output_binding_names,
146+
'output_tensor_formats': output_tensor_formats,
147+
'verbose': tensorrt_verbose,
148+
'force_engine_update': force_engine_update
149+
}])
150+
151+
dope_decoder_node = ComposableNode(
152+
name='dope_decoder',
153+
package='isaac_ros_dope',
154+
plugin='nvidia::isaac_ros::dope::DopeDecoderNode',
155+
parameters=[{
156+
'object_name': object_name,
157+
}],
158+
remappings=[('belief_map_array', 'tensor_sub'),
159+
('dope/pose_array', 'poses')])
160+
161+
container = ComposableNodeContainer(
162+
name='dope_container',
163+
namespace='',
164+
package='rclcpp_components',
165+
executable='component_container_mt',
166+
composable_node_descriptions=[encoder_node, dope_inference_node, dope_decoder_node],
167+
output='screen',
168+
)
169+
170+
final_launch_description = launch_args + [container]
171+
return launch.LaunchDescription(final_launch_description)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0"?>
2+
3+
<!--
4+
SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
SPDX-License-Identifier: Apache-2.0
19+
-->
20+
21+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
22+
<package format="3">
23+
<name>custom_nitros_dnn_image_encoder</name>
24+
<version>1.0.0</version>
25+
<description>Custom NITROS Image Encoding</description>
26+
27+
<maintainer email="[email protected]">Hemal Shah</maintainer>
28+
<license>Apache-2.0</license>
29+
<url type="website">https://developer.nvidia.com/isaac-ros-gems/</url>
30+
<author>Shubham Tyagi</author>
31+
32+
<buildtool_depend>ament_cmake</buildtool_depend>
33+
34+
<depend>rclcpp</depend>
35+
<depend>rclcpp_components</depend>
36+
<depend>std_msgs</depend>
37+
<depend>sensor_msgs</depend>
38+
<depend>isaac_ros_managed_nitros</depend>
39+
<depend>isaac_ros_tensor_list_interfaces</depend>
40+
41+
<build_depend>isaac_ros_common</build_depend>
42+
43+
<test_depend>ament_lint_auto</test_depend>
44+
<test_depend>ament_lint_common</test_depend>
45+
<test_depend>isaac_ros_test</test_depend>
46+
47+
<export>
48+
<build_type>ament_cmake</build_type>
49+
</export>
50+
</package>

0 commit comments

Comments
 (0)