file path not recognized as file ros2 launch

asked 2022-07-07 05:47:27 -0500

kyubot gravatar image

updated 2022-07-07 09:57:00 -0500

Hello, I am running ros2-foxy on ubuntu 20.04

I am writing a launch file to combine two node at once.

Node executable rgbd requires 2 files as arguments as below. $ ros2 run ros2_orbslam rgbd ~/SLAM/ORB_SLAM2/Vocabulary/ORBvoc.txt ~/ws/src/ros2-ORB_SLAM2/src/rgbd/TUM1.yaml

To pass these argument as parameters for launch.py, I created below script.

import os
import launch
import launch_ros.actions
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from ament_index_python.packages import get_package_share_directory
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.actions import TimerAction      #For delayed launch of node

def generate_launch_description():
    ros2_orbslam_dir = get_package_share_directory('ros2_orbslam')
    voc_file = os.path.join('~','SLAM/ORB_SLAM2/Vocabulary', 'ORBvoc.txt')
    param_file = os.path.join('~','ws/src/ros2-ORB_SLAM2/src/rgbd','TUM1.yaml')
    pkg_realsense2_camera = get_package_share_directory('realsense2_camera')
    launch_realsense2 = IncludeLaunchDescription(
            PythonLaunchDescriptionSource(
                os.path.join(pkg_realsense2_camera, 'launch', 'rs_launch.py')
        ),
    )
ld = launch.LaunchDescription([
    DeclareLaunchArgument(
        'voc',
        default_value = voc_file,
        description = 'Full path to the VOC file to load'
    ),
    DeclareLaunchArgument(
        'params_file',
        default_value = param_file,
        description = 'Full path to the VOC file to load'
    ),
    TimerAction(period = 1.0,
        actions=[
            Node(
                package="ros2_orbslam", executable="rgbd",
                output='screen',
                parameters = [
                    {"voc":voc_file},
                    {"params_file":param_file},
                ],
            ),
        ]),
    #launch_realsense2,
])
print(f"VOC FILE: {voc_file}")
print(f"PARAM_FILE: {param_file}")

return ld

The path looks ok and there exist the files however it fails to launch the node with errors. Here is the result.

$ ros2 launch ros2_orbslam rgbd.launch.py 
[INFO] [launch]: All log files can be found below /home/khyou/.ros/log/2022-07-07-19-32-23-441629-ubuntu-30580
[INFO] [launch]: Default logging verbosity is set to INFO
VOC FILE: ~/SLAM/ORB_SLAM2/Vocabulary/ORBvoc.txt
PARAM_FILE: ~/ws/src/ros2-ORB_SLAM2/src/rgbd/TUM1.yaml
[INFO] [rgbd-1]: process started with pid [30582]
[rgbd-1] 
[rgbd-1] ORB-SLAM2 Copyright (C) 2014-2016 Raul Mur-Artal, University of Zaragoza.
[rgbd-1] This program comes with ABSOLUTELY NO WARRANTY;
[rgbd-1] This is free software, and you are welcome to redistribute it
[rgbd-1] under certain conditions. See LICENSE.txt.
[rgbd-1] 
[rgbd-1] Input sensor was set to: RGB-D
[rgbd-1] Failed to open settings file at: --params-file
[ERROR] [rgbd-1]: process has died [pid 30582, exit code 255, cmd '/home/khyou/ws/install/ros2_orbslam/lib/ros2_orbslam/rgbd --ros-args --params-file /tmp/launch_params_b80906wf --params-file /tmp/launch_params_bef33l_r'].
edit retag flag offensive close merge delete