Error with pkg turtlebot2_demo ( ModuleNotFoundError: No module named 'launch.exit_handler')

asked 2023-06-13 11:26:16 -0500

Sergiiio__ gravatar image

updated 2023-06-13 12:18:26 -0500

Good,

I'm a bit new to ROS2, and I wanted to port my turtlebot 2 to ROS 2, so I looked at the following repository: https://github.com/ros2/turtlebot2_demo.

This repository says that you can use the demos that were originally available for turtlebot 2 in ROS 1 but working in ROS 2.

I have installed ROS 1 (melodic) and ROS 2 bouncy as indicated in the repository. However some demos do work, at least the teleop joystick and the follower but if I run the nodes separately, as shown in the README.

But what I'm really interested in is to see if I can scan a room and navigate with ROS 2, for this some cartographer packages are presented with which it can be done, however, when I run the launch command of ros 2 to launch all the nodes that do the mapping with the following command:

launch `ros2 pkg prefix turtlebot2_cartographer`/share/turtlebot2_cartographer/launch/turtlebot_carto_2d.py

I get the following error:

turtlebot@turtlebot@turtlebot:~/ros2$ launch ``ros2 pkg prefix turtlebot2_cartographer`/share/turtlebot2_cartographer/launch/turtlebot_carto_2d.py
Traceback (most recent call last):
  File "/opt/ros/bouncy/bin/launch", line 11, in <module>
    load_entry_point('launch==0.5.1', 'console_scripts', 'launch')()
  File "/opt/ros/bouncy/lib/python3.6/site-packages/launch/legacy/main.py", line 50, in main
    load_launch_file(launch_file, launch_descriptor, args.args)
  File "/opt/ros/bouncy/lib/python3.6/site-packages/launch/legacy/loader.py", line 20, in load_launch_file
    launch_module = loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 684, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/turtlebot/ros2/install/turtlebot2_cartographer/share/turtlebot2_cartographer/launch/turtlebot_carto_2d.py", line 18, in <module>
    from launch.exit_handler import restart_exit_handler
ModuleNotFoundError: No module named 'launch.exit_handler'

I haven't been able to find any information about why this error can occur, and I can't find any other way to use my turtlebot 2 in ROS 2, at least to do a little testing.

My ROS env variables are these:

turtlebot@turtlebot:~/ros2$ env | grep ROS
ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS1_DISTRO=melodic
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=bouncy

This is the python code where the launch.exit_handler import is done:

# Copyright 2017 Open Source Robotics Foundation, Inc.
#
# 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 ...
(more)
edit retag flag offensive close merge delete