text: import os
  
  from ament_index_python.packages import get_package_share_directory
  from launch import LaunchDescription, launch_description_sources
  from launch.actions import IncludeLaunchDescription
  from launch.actions import DeclareLaunchArgument
  from launch.substitutions import LaunchConfiguration
  import launch_ros.actions
  import launch_ros.descriptions
  
  
  def generate_launch_description():
      default_rviz = os.path.join(get_package_share_directory('depthai_examples'),
                                  'rviz', 'stereoInertial.rviz')
      urdf_launch_dir = os.path.join(get_package_share_directory('depthai_bridge'), 'launch')
      
  
      camera_model = LaunchConfiguration('camera_model',  default = 'OAK-D')
      tf_prefix    = LaunchConfiguration('tf_prefix',   default = 'oak')
      base_frame   = LaunchConfiguration('base_frame',    default = 'oak-d_frame')
      parent_frame = LaunchConfiguration('parent_frame',  default = 'oak-d-base-frame')
      
      cam_pos_x    = LaunchConfiguration('cam_pos_x',     default = '0.0')
      cam_pos_y    = LaunchConfiguration('cam_pos_y',     default = '0.0')
      cam_pos_z    = LaunchConfiguration('cam_pos_z',     default = '0.0')
      cam_roll     = LaunchConfiguration('cam_roll',      default = '0.0')
      cam_pitch    = LaunchConfiguration('cam_pitch',     default = '0.0')
      cam_yaw      = LaunchConfiguration('cam_yaw',       default = '0.0')
  
      imuMode      = LaunchConfiguration('imuMode', default = '1')
      mode         = LaunchConfiguration('mode', default = 'depth')
      lrcheck      = LaunchConfiguration('lrcheck', default = True)
      extended     = LaunchConfiguration('extended', default = False)
      subpixel     = LaunchConfiguration('subpixel', default = True)
  
      rectify        = LaunchConfiguration('rectify', default = True)
      depth_aligned  = LaunchConfiguration('depth_aligned', default = False)
      stereo_fps     = LaunchConfiguration('stereo_fps', default = 30)
      confidence     = LaunchConfiguration('confidence', default = 200)
      LRchecktresh   = LaunchConfiguration('LRchecktresh', default = 5)
      angularVelCovariance  = LaunchConfiguration('linearAccelCovariance', default = 0.0)
      linearAccelCovariance = LaunchConfiguration('linearAccelCovariance', default = 0.0)
  
      declare_camera_model_cmd = DeclareLaunchArgument(
          'camera_model',
          default_value=camera_model,
          description='The model of the camera. Using a wrong camera model can disable camera features. Valid models: `OAK-D, OAK-D-LITE`.')
  
      declare_tf_prefix_cmd = DeclareLaunchArgument(
          'tf_prefix',
          default_value=tf_prefix,
          description='The name of the camera. It can be different from the camera model and it will be used in naming TF.')
  
      declare_base_frame_cmd = DeclareLaunchArgument(
          'base_frame',
          default_value=base_frame,
          description='Name of the base link.')
  
      declare_parent_frame_cmd = DeclareLaunchArgument(
          'parent_frame',
          default_value=parent_frame,
          description='Name of the parent link from other a robot TF for example that can be connected to the base of the OAK.')
  
      declare_pos_x_cmd = DeclareLaunchArgument(
          'cam_pos_x',
          default_value=cam_pos_x,
          description='Position X of the camera with respect to the base frame.')
  
      declare_pos_y_cmd = DeclareLaunchArgument(
          'cam_pos_y',
          default_value=cam_pos_y,
          description='Position Y of the camera with respect to the base frame.')
  
      declare_pos_z_cmd = DeclareLaunchArgument(
          'cam_pos_z',
          default_value=cam_pos_z,
          description='Position Z of the camera with respect to the base frame.')
  
      declare_roll_cmd = DeclareLaunchArgument(
          'cam_roll',
          default_value=cam_roll,
          description='Roll orientation of the camera with respect to the base frame.')
  
      declare_pitch_cmd = DeclareLaunchArgument(
          'cam_pitch',
          default_value=cam_pitch,
          description='Pitch orientation of the camera with respect to the base frame.')
  
      declare_yaw_cmd = DeclareLaunchArgument(
          'cam_yaw',
          default_value=cam_yaw,
          description='Yaw orientation of the camera with respect to the base frame.')
  
      declare_mode_cmd = DeclareLaunchArgument(
          'mode',
          default_value=mode,
          description='set to depth or disparity. Setting to depth will publish depth or else will publish disparity.')
  
      declare_imu_mode_cmd = DeclareLaunchArgument(
          'imuMode',
          default_value=imuMode,
          description=' set to 0 -> COPY, 1 -> LINEAR_INTERPOLATE_GYRO, 2 -> LINEAR_INTERPOLATE_ACCEL')
  
      declare_lrcheck_cmd = DeclareLaunchArgument(
          'lrcheck',
          default_value=lrcheck,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
  
      declare_extended_cmd = DeclareLaunchArgument(
          'extended',
          default_value=extended,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
  
      declare_subpixel_cmd = DeclareLaunchArgument(
          'subpixel',
          default_value=subpixel,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
      
      declare_rectify_cmd = DeclareLaunchArgument(
          'rectify',
          default_value=rectify,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
      
      declare_depth_aligned_cmd = DeclareLaunchArgument(
          'depth_aligned',
          default_value=depth_aligned,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
      
      declare_stereo_fps_cmd = DeclareLaunchArgument(
          'stereo_fps',
          default_value=stereo_fps,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
      
      declare_LRchecktresh_cmd = DeclareLaunchArgument(
          'LRchecktresh',
          default_value=LRchecktresh,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
      
      declare_confidence_cmd = DeclareLaunchArgument(
          'confidence',
          default_value=confidence,
          description='The name of the camera. It can be different from the camera model and it will be used as node `namespace`.')
  
      declare_angularVelCovariance_cmd = DeclareLaunchArgument(
          'angularVelCovariance',
          default_value=angularVelCovariance,
          description='Set the angular velocity covariance of the IMU.')
  
      declare_linearAccelCovariance_cmd = DeclareLaunchArgument(
          'linearAccelCovariance',
          default_value=linearAccelCovariance,
          description='Set the Linear acceleration covariance of the IMU.')
     
      
      urdf_launch = IncludeLaunchDescription(
                              launch_description_sources.PythonLaunchDescriptionSource(
                                      os.path.join(urdf_launch_dir, 'urdf_launch.py')),
                              launch_arguments={'tf_prefix'   : tf_prefix,
                                                'camera_model': camera_model,
                                                'base_frame'  : base_frame,
                                                'parent_frame': parent_frame,
                                                'cam_pos_x'   : cam_pos_x,
                                                'cam_pos_y'   : cam_pos_y,
                                                'cam_pos_z'   : cam_pos_z,
                                                'cam_roll'    : cam_roll,
                                                'cam_pitch'   : cam_pitch,
                                                'cam_yaw'     : cam_yaw}.items())
  
  
      streo_node = launch_ros.actions.Node(
              package='depthai_examples', executable='stereo_inertial_node',
              output='screen',
              parameters=[{'tf_prefix':     tf_prefix},
                          {'mode':          mode},
                          {'imuMode':       imuMode},
                          {'lrcheck':       lrcheck},
                          {'extended':      extended},
                          {'subpixel':      subpixel},
                          {'rectify':       rectify},
                          {'depth_aligned': depth_aligned},
                          {'stereo_fps':    stereo_fps},
                          {'confidence':    confidence},
                          {'LRchecktresh':  LRchecktresh}])
  
      metric_converter_node = launch_ros.actions.ComposableNodeContainer(
              name='container',
              namespace='',
              package='rclcpp_components',
              executable='component_container',
              composable_node_descriptions=[
                  # Driver itself
                  launch_ros.descriptions.ComposableNode(
                      package='depth_image_proc',
                      plugin='depth_image_proc::ConvertMetricNode',
                      name='convert_metric_node',
                      remappings=[('image_raw', '/stereo/depth'),
                                  ('camera_info', '/stereo/camera_info'),
                                  ('image', '/stereo/converted_depth')]
                  ),
              ],
              output='screen',)
  
      #TODO(sachin): Move this into the same container
      point_cloud_node = launch_ros.actions.ComposableNodeContainer(
              name='container2',
              namespace='',
              package='rclcpp_components',
              executable='component_container',
              composable_node_descriptions=[
                  # Driver itself
                  launch_ros.descriptions.ComposableNode(
                      package='depth_image_proc',
                      plugin='depth_image_proc::PointCloudXyziNode',
                      name='point_cloud_xyzi',
  
                      remappings=[('depth/image_rect', '/stereo/converted_depth'),
                                  ('intensity/image_rect', '/right/image_rect'),
                                  ('intensity/camera_info', '/right/camera_info'),
                                  ('points', '/stereo/points')]
                  ),
              ],
              output='screen',)
  
      rviz_node = launch_ros.actions.Node(
              package='rviz2', executable='rviz2', output='screen',
              arguments=['--display-config', default_rviz])
  
      ld = LaunchDescription()
      ld.add_action(declare_tf_prefix_cmd)
      ld.add_action(declare_camera_model_cmd)
      
      ld.add_action(declare_base_frame_cmd)
      ld.add_action(declare_parent_frame_cmd)
      
      ld.add_action(declare_pos_x_cmd)
      ld.add_action(declare_pos_y_cmd)
      ld.add_action(declare_pos_z_cmd)
      ld.add_action(declare_roll_cmd)
      ld.add_action(declare_pitch_cmd)
      ld.add_action(declare_yaw_cmd)
      
      ld.add_action(declare_mode_cmd)
      ld.add_action(declare_imu_mode_cmd)
      ld.add_action(declare_lrcheck_cmd)
      ld.add_action(declare_extended_cmd)
      ld.add_action(declare_subpixel_cmd)
      ld.add_action(declare_rectify_cmd)
      ld.add_action(declare_depth_aligned_cmd)
      ld.add_action(declare_stereo_fps_cmd)
      ld.add_action(declare_LRchecktresh_cmd)
      ld.add_action(declare_confidence_cmd)
      ld.add_action(declare_angularVelCovariance_cmd)
      ld.add_action(declare_linearAccelCovariance_cmd)
  
      ld.add_action(streo_node)
      ld.add_action(urdf_launch)
  
      ld.add_action(metric_converter_node)
      ld.add_action(point_cloud_node)
      ld.add_action(rviz_node)
      return ld
  
  