ros-navigation / navigation2

ROS 2 Navigation Framework and System
https://nav2.org/
Other
2.45k stars 1.24k forks source link

Default parameter not correctly set? #4316

Closed moooeeeep closed 3 months ago

moooeeeep commented 3 months ago

Bug report

Required Info:

Steps to reproduce issue

Install deps

sudo apt-get install ros-humble-turtlebot3-gazebo ros-humble-rtabmap-ros ros-humble-navigation2

Prepare env

source /opt/ros/humble/setup.bash
export ROS_LOCALHOST_ONLY=1
export TURTLEBOT3_MODEL=waffle

Run this launch file:

<launch>

  <include
      file="$(find-pkg-share turtlebot3_gazebo)/launch/turtlebot3_world.launch.py"
      />

  <include
      file="$(find-pkg-share rtabmap_demos)/launch/turtlebot3_scan.launch.py"
      />

  <include
      file="$(find-pkg-share nav2_bringup)/launch/navigation_launch.py"
      >
    <arg name="use_sim_time" value="true" />
  </include>

</launch>

Expected behavior

Gazebo Turtlebot3 Simulation, RTAB-Map SLAM and nav2 Navigation Stack is started.

Actual behavior

Gazebo and RTAB-Map GUI open, but full stack crashes.

Text output:

[INFO] [launch]: All log files can be found below /home/dfki.uni-bremen.de/fmueller/.ros/log/2024-05-08-14-17-09-108819-HDP-MASTER-U-12655
[INFO] [launch]: Default logging verbosity is set to INFO
urdf_file_name : turtlebot3_waffle.urdf
urdf_file_name : turtlebot3_waffle.urdf
urdf_file_name : turtlebot3_waffle.urdf
[ERROR] [launch]: Caught exception in launch (see debug for traceback): [Errno 2] No such file or directory: ''

Additional information

The same launch file works without changes as expected on foxy.

If we adjust the launch file slightly to specify the params_file argument, it launches as expected with humble (not tested with foxy though):

<launch>

  <include
      file="$(find-pkg-share turtlebot3_gazebo)/launch/turtlebot3_world.launch.py"
      />

  <include
      file="$(find-pkg-share rtabmap_demos)/launch/turtlebot3_scan.launch.py"
      />

  <include
      file="$(find-pkg-share nav2_bringup)/launch/navigation_launch.py"
      >
    <arg name="use_sim_time" value="true" />
    <arg name="params_file" value="$(find-pkg-share nav2_bringup)/params/nav2_params.yaml" />
  </include>

</launch>

I have made a post about this here: https://robotics.stackexchange.com/questions/109897

SteveMacenski commented 3 months ago

I'll be honest, Foxy is so ancient and so many thousands of things have changed since then, I won't even speculate as to why a break from Foxy to Humble occurred. Foxy is legit so out of date that we stopped supporting it years before it went EOL since the project moved past ABI/API stable updates so rapidly. Things have slowed down now so its not nearly as bad, but just important context.

But, I did test

ros2 launch nav2_bringup navigation_launch.py

and that seems to work fine for me with humble binaries. Can you test as well and let me know what you see? Perhaps this is an XML launch bug, but too early for me to point to that as the likely culrpit

moooeeeep commented 3 months ago

On its own, I can run the launch file just fine. Embedding it into another (non-trivial) launch file, seems to break something sometimes.

Same behavior as described above (crash with [Errno 2] No such file or directory: '') occurs when called from the equivalent Python parent launch file:

from launch_ros.substitutions import FindPackageShare

from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import PathJoinSubstitution, TextSubstitution

def generate_launch_description():
    turtlebot3_world = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('turtlebot3_gazebo'),
                'launch/turtlebot3_world.launch.py'
            ])
        ]),
    )
    mapping = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('rtabmap_demos'),
                'launch/turtlebot3_scan.launch.py'
            ])
        ]),
    )
    navigation = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            PathJoinSubstitution([
                FindPackageShare('nav2_bringup'),
                'launch/navigation_launch.py'
            ])
        ]),
        launch_arguments={
            'use_sim_time': 'True',
        }.items()
    )

    return LaunchDescription([
        turtlebot3_world,
        mapping,
        navigation,
    ])

When I explicitly pass the params_file argument to navigation_launch.py, it works:

'params_file': PathJoinSubstitution([
    FindPackageShare('nav2_bringup'),
    'params/nav2_params.yaml'
]),
SteveMacenski commented 3 months ago

I won't argue that this is a problem, but also wouldn't you need to pass in a configuration file no matter what? The defaults for every navigation server is not likely to work well for anyone's particular situation. Happy to have you dig into the problem and try to get it resolved, but also seems like a somewhat non-issue practically speaking

moooeeeep commented 3 months ago

I agree that most serious users will probably override these parameters, but e.g., for getting started or quick tests the default config works just fine.

I just found this other post that seems to indicate this is indeed a more general issue, maybe a regression with ros2 launch. I'll try to reproduce this with a more minimal setup and consider to file an issue there instead.

Thanks for your input!

moooeeeep commented 3 months ago

FWIW: Appparantly this is a "feature". Included launch files are not scoped by default. To isolate them from external modifications to default arguments, we need to wrap them into group actions.