Skip to content

Do not require LDS_MODEL to be set in robot.launch.py - #1152

Open
mmporong wants to merge 1 commit into
ROBOTIS-GIT:mainfrom
mmporong:fix/lds-model-optional
Open

Do not require LDS_MODEL to be set in robot.launch.py#1152
mmporong wants to merge 1 commit into
ROBOTIS-GIT:mainfrom
mmporong:fix/lds-model-optional

Conversation

@mmporong

Copy link
Copy Markdown

Issue: Fixes #1151. The e-Manual bringup steps (export TURTLEBOT3_MODEL=burger
then ros2 launch turtlebot3_bringup robot.launch.py) never set LDS_MODEL, so
following the documentation raises KeyError: 'LDS_MODEL' together with the
misleading InvalidFrontendLaunchFileError: The launch file may have a syntax error.

Fix: one line.

-    LDS_MODEL = os.environ['LDS_MODEL']
+    LDS_MODEL = os.environ.get('LDS_MODEL')

This relies on behaviour the file already has. The final else branch selects
hls_lfcd_lds_driver, the same driver as the 'LDS-01' branch, so an unrecognised
value is already treated as LDS-01. Only an unset variable raised before reaching that
fallback. It also matches the ROS_DISTRO lookup two lines above, which already uses
os.environ.get().

Verification: ros-humble-turtlebot3-bringup 2.3.6, TURTLEBOT3_MODEL=burger.

case before after
LDS_MODEL unset KeyError: 'LDS_MODEL', nothing starts robot_state_publisher, hlds_laser_publisher, turtlebot3_ros all start
LDS_MODEL=LDS-01 hls_lfcd_lds_driver unchanged
LDS_MODEL=LDS-02 ld08_driver unchanged
LDS_MODEL=LDS-03 coin_d4_driver unchanged

If you would rather keep the variable mandatory, the alternative is to raise a
RuntimeError naming the accepted values instead of letting the KeyError surface. I
went with .get() because it makes the documented startup sequence work without a
documentation change, but I am happy to switch.

The Bringup page of the e-Manual documents the startup sequence as

    export TURTLEBOT3_MODEL=burger
    ros2 launch turtlebot3_bringup robot.launch.py

and never mentions LDS_MODEL. Following it exactly fails before any node
starts:

    KeyError: 'LDS_MODEL'
    InvalidFrontendLaunchFileError: The launch file may have a syntax error,
    or its format is unknown

The second line is misleading, since the launch file is fine and only an
environment variable is missing.

robot.launch.py already defines what to do with an unrecognised LDS_MODEL:
the final else branch selects hls_lfcd_lds_driver, the same driver as the
'LDS-01' branch. An unset variable is the only case that raises instead of
reaching that fallback. Reading it with os.environ.get() lets None fall into
the existing else branch, which is also consistent with the ROS_DISTRO lookup
two lines above.

Explicit values are unaffected: 'LDS-02' still selects ld08_driver and
'LDS-03' still selects coin_d4_driver.

Signed-off-by: mmporong <mmporong@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

robot.launch.py fails with KeyError when LDS_MODEL is unset, but the e-Manual bringup steps never set it

1 participant