From 4ba7ff097064722f29368bb14553189c19e3ccb1 Mon Sep 17 00:00:00 2001 From: Rooholla-KhorramBakht Date: Fri, 3 May 2024 11:06:29 +0800 Subject: [PATCH] isaac ros workspace added --- .gitignore | 3 +- Dockerfile.dock | 8 +- Dockerfile.robot | 6 +- deploy/isaac_ws/.isaac_ros_common-config | 2 + deploy/isaac_ws/docker/Dockerfile.go2py | 6 ++ deploy/isaac_ws/h264_encoder.py | 112 +++++++++++++++++++++++ deploy/isaac_ws/rs_launch.py | 30 ++++++ deploy/isaac_ws/start_isaac_ros.sh | 2 + 8 files changed, 161 insertions(+), 8 deletions(-) create mode 100644 deploy/isaac_ws/.isaac_ros_common-config create mode 100644 deploy/isaac_ws/docker/Dockerfile.go2py create mode 100644 deploy/isaac_ws/h264_encoder.py create mode 100644 deploy/isaac_ws/rs_launch.py create mode 100755 deploy/isaac_ws/start_isaac_ros.sh diff --git a/.gitignore b/.gitignore index 01c5c49..572017d 100644 --- a/.gitignore +++ b/.gitignore @@ -172,4 +172,5 @@ deploy/nav2_ws/install deploy/nav2_ws/log _isaac_sim -.vscode \ No newline at end of file +.vscode +deploy/sgiaun-umut \ No newline at end of file diff --git a/Dockerfile.dock b/Dockerfile.dock index b001f88..74b8f2a 100644 --- a/Dockerfile.dock +++ b/Dockerfile.dock @@ -30,10 +30,10 @@ cd .. && colcon build --packages-select cyclonedds && source /opt/ros/humble/set COPY deploy/dock_ws/src /dock_ws/src RUN cd /dock_ws && source /opt/ros/humble/setup.bash && colcon build --symlink-install -# Compile the C++ hypervisor bridge -COPY deploy/dds_bridge /dds_bridge -WORKDIR /dds_bridge -RUN ./install.sh && mkdir build && cd build && cmake .. && make +# # Compile the C++ hypervisor bridge +# COPY deploy/dds_bridge /dds_bridge +# WORKDIR /dds_bridge +# RUN ./install.sh && mkdir build && cd build && cmake .. && make # Copy the script to start the nodes COPY deploy/scripts /root/scripts diff --git a/Dockerfile.robot b/Dockerfile.robot index 04f5fcf..2a11edd 100644 --- a/Dockerfile.robot +++ b/Dockerfile.robot @@ -30,9 +30,9 @@ COPY deploy/robot_ws/src /robot_ws/src RUN cd /robot_ws && source /opt/ros/humble/setup.bash && colcon build --symlink-install # Compile the C++ hypervisor bridge -COPY deploy/dds_bridge /dds_bridge -WORKDIR /dds_bridge -RUN ./install.sh && mkdir build && cd build && cmake .. && make +#COPY deploy/dds_bridge /dds_bridge +#WORKDIR /dds_bridge +#RUN ./install.sh && mkdir build && cd build && cmake .. && make # Copy the script to start the nodes COPY deploy/scripts /root/scripts diff --git a/deploy/isaac_ws/.isaac_ros_common-config b/deploy/isaac_ws/.isaac_ros_common-config new file mode 100644 index 0000000..17f4c14 --- /dev/null +++ b/deploy/isaac_ws/.isaac_ros_common-config @@ -0,0 +1,2 @@ +CONFIG_IMAGE_KEY="ros2_humble.realsense.go2py" +CONFIG_DOCKER_SEARCH_DIRS=(../../../docker) diff --git a/deploy/isaac_ws/docker/Dockerfile.go2py b/deploy/isaac_ws/docker/Dockerfile.go2py new file mode 100644 index 0000000..99f5dea --- /dev/null +++ b/deploy/isaac_ws/docker/Dockerfile.go2py @@ -0,0 +1,6 @@ +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +RUN apt update && sudo apt-get install -y ros-humble-isaac-ros-visual-slam \ + ros-humble-isaac-ros-h264-decoder \ + ros-humble-isaac-ros-h264-encoder \ No newline at end of file diff --git a/deploy/isaac_ws/h264_encoder.py b/deploy/isaac_ws/h264_encoder.py new file mode 100644 index 0000000..6e19170 --- /dev/null +++ b/deploy/isaac_ws/h264_encoder.py @@ -0,0 +1,112 @@ +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +import os + +from ament_index_python.packages import get_package_share_directory + +import launch +from launch.actions import ExecuteProcess +from launch_ros.actions import ComposableNodeContainer +from launch_ros.descriptions import ComposableNode + + +def generate_launch_description(): + # RealSense + realsense_config_file_path = os.path.join( + get_package_share_directory('isaac_ros_h264_encoder'), + 'config', 'realsense.yaml' + ) + + realsense_node = ComposableNode( + package='realsense2_camera', + plugin='realsense2_camera::RealSenseNodeFactory', + parameters=[realsense_config_file_path], + remappings=[ + ('infra1/image_rect_raw', 'left/image_rect_raw_mono'), + ('infra2/image_rect_raw', 'right/image_rect_raw_mono'), + ('infra1/camera_info', 'left/camerainfo'), + ('infra2/camera_info', 'right/camerainfo') + ] + ) + + left_format_converter_node = ComposableNode( + package='isaac_ros_image_proc', + plugin='nvidia::isaac_ros::image_proc::ImageFormatConverterNode', + name='image_format_node_left', + parameters=[{ + 'encoding_desired': 'rgb8', + }], + remappings=[ + ('image_raw', 'left/image_rect_raw_mono'), + ('image', 'left/image_rect_raw')] + ) + + right_format_converter_node = ComposableNode( + package='isaac_ros_image_proc', + plugin='nvidia::isaac_ros::image_proc::ImageFormatConverterNode', + name='image_format_node_right', + parameters=[{ + 'encoding_desired': 'rgb8', + }], + remappings=[ + ('image_raw', 'right/image_rect_raw_mono'), + ('image', 'right/image_rect_raw')] + ) + + left_encoder_node = ComposableNode( + package='isaac_ros_h264_encoder', + plugin='nvidia::isaac_ros::h264_encoder::EncoderNode', + name='left_encoder_node', + parameters=[{ + 'input_width': 640, + 'input_height': 480, + }], + remappings=[ + ('image_raw', 'left/image_rect_raw'), + ('image_compressed', 'left/image_compressed')] + ) + + right_encoder_node = ComposableNode( + package='isaac_ros_h264_encoder', + plugin='nvidia::isaac_ros::h264_encoder::EncoderNode', + name='right_encoder_node', + parameters=[{ + 'input_width': 640, + 'input_height': 480, + }], + remappings=[ + ('image_raw', 'right/image_rect_raw'), + ('image_compressed', 'right/image_compressed')] + ) + + container = ComposableNodeContainer( + name='encoder_container', + namespace='encoder', + package='rclcpp_components', + executable='component_container_mt', + composable_node_descriptions=[realsense_node, left_format_converter_node, + right_format_converter_node, + left_encoder_node, right_encoder_node], + output='screen' + ) + + rosbag_record = ExecuteProcess( + cmd=['ros2', 'bag', 'record', '/left/camerainfo', '/right/camerainfo', + '/left/image_compressed', '/right/image_compressed'], + output='screen') + + return (launch.LaunchDescription([rosbag_record, container])) diff --git a/deploy/isaac_ws/rs_launch.py b/deploy/isaac_ws/rs_launch.py new file mode 100644 index 0000000..424f2aa --- /dev/null +++ b/deploy/isaac_ws/rs_launch.py @@ -0,0 +1,30 @@ +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import ThisLaunchFileDir +from launch_ros.actions import Node + + +def generate_launch_description(): + return LaunchDescription([ + Node( + name='go2_cam', + namespace='go2/cam', + package='realsense2_camera', + executable='realsense2_camera_node', + parameters=[{ + 'enable_infra1': True, + 'enable_infra2': True, + 'enable_color': False, + 'enable_depth': False, + 'depth_module.emitter_enabled': 0, + 'depth_module.profile': '640x480x60', + 'enable_gyro': True, + 'enable_accel': True, + 'gyro_fps': 400, + 'accel_fps': 200, + 'unite_imu_method': 2, + # 'tf_publish_rate': 0.0 + }] + ) + ]) \ No newline at end of file diff --git a/deploy/isaac_ws/start_isaac_ros.sh b/deploy/isaac_ws/start_isaac_ros.sh new file mode 100755 index 0000000..ba9d647 --- /dev/null +++ b/deploy/isaac_ws/start_isaac_ros.sh @@ -0,0 +1,2 @@ +cp .isaac_ros_common-config src/isaac_ros_common/scripts/ +./src/isaac_ros_common/scripts/run_dev.sh $(pwd)