I’m doing the Unit 3 topic_quiz and I tried to launch the launch file as below but got the error not found but the launch file is located at topics_quiz/launch directory,
I’m not sure why it goes to look in the …/share directory. please help!
user:~/ros2_ws$ ros2 launch topics_quiz topics_quiz_launch_file.launch.py
file ‘topics_quiz_launch_file.launch.py’ was not found in the share directory of package ‘topics_quiz’ which is at ‘/home/user/ros2_ws/install/topics_quiz/share/topics_quiz’
I think you have forgotten to add the launch directory and launch files in the setup.py file.
Adding this line will install the necessary launch files in the install folder.
Follow the ROS2 launch file creation tutorial step to understand this procedure.
Because that is how ROS2 is structured. The package gets built into ~/ros2_ws/install/share folder after compilation.
here are the errors when I tried to launch the package,
Blockquote user:~/ros2_ws$ colcon build --packages-select topics_quizStarting >>> topics_quiz— stderr: topics_quiz/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn(—Finished <<< topics_quiz [1.89s]
Summary: 1 package finished [2.56s]
1 package had stderr output: topics_quiz
user:~/ros2_ws$ source ~/ros2_ws/install/setup.bash
user:~/ros2_ws$ ros2 launch topics_quiz topics_quiz_launch_file.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-07-30-02-38-46-128199-2_xterm-1390
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [topics_quiz_node-1]: process started with pid [1391]
[topics_quiz_node-1] Traceback (most recent call last):
[topics_quiz_node-1] File “/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node”, line 33, in
[topics_quiz_node-1] sys.exit(load_entry_point(‘topics-quiz==0.0.0’, ‘console_scripts’, ‘topics_quiz_node’)())
[topics_quiz_node-1] File “/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node”, line 25, in importlib_load_entry_point
[topics_quiz_node-1] return next(matches).load()
[topics_quiz_node-1] File “/usr/lib/python3.10/importlib/metadata/init.py”, line 171, in load
[topics_quiz_node-1] module = import_module(match.group(‘module’))
[topics_quiz_node-1] File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
[topics_quiz_node-1] return _bootstrap._gcd_import(name[level:], package, level)
[topics_quiz_node-1] File “”, line 1050, in _gcd_import
[topics_quiz_node-1] File “”, line 1027, in _find_and_load
[topics_quiz_node-1] File “”, line 1004, in _find_and_load_unlocked
[topics_quiz_node-1] ModuleNotFoundError: No module named ‘topics_quiz.topics_quiz_node’
[ERROR] [topics_quiz_node-1]: process has died [pid 1391, exit code 1, cmd ‘/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node --ros-args’].
I tried your steps and still unable to launch…, please advise
Blockquote user:~$ pip install setuptools==56.2.0
Defaulting to user installation because normal site-packages is not writeable
Collecting setuptools==56.2.0
Downloading setuptools-56.2.0-py3-none-any.whl (785 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 785.3/785.3 KB 9.3 MB/s eta 0:00:00
Installing collected packages: setuptools
Successfully installed setuptools-56.2.0
user:~$ pip install setuptools==56.2.0
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: setuptools==56.2.0 in ./.local/lib/python3.10/site-packages (56.2.0)
user:~$ cd ~/ros2_ws
user:~/ros2_ws$ rm -rf ./build ./install ./log
user:~/ros2_ws$ colcon build
[1.186s] WARNING:colcon.colcon_ros.prefix_path.ament:The path ‘/home/user/ros2_ws/install/topics_quiz’ in the environment variable AMENT_PREFIX_PATH doesn’t exist
[1.186s] WARNING:colcon.colcon_ros.prefix_path.ament:The path ‘/home/user/ros2_ws/install/my_package’ in the environment variable AMENT_PREFIX_PATH doesn’t exist
Starting >>> topics_quiz
Finished <<< topics_quiz [2.88s]
Summary: 1 package finished [3.81s]
user:~/ros2_ws$ ros2 launch topics_quiz topics_quiz_launch_file.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2023-07-31-01-31-04-473589-2_xterm-1954
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [topics_quiz_node-1]: process started with pid [1955]
[topics_quiz_node-1] Traceback (most recent call last):
[topics_quiz_node-1] File “/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node”, line 33, in
[topics_quiz_node-1] sys.exit(load_entry_point(‘topics-quiz==0.0.0’, ‘console_scripts’, ‘topics_quiz_node’)())
[topics_quiz_node-1] File “/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node”, line 25, in importlib_load_entry_point
[topics_quiz_node-1] return next(matches).load()
[topics_quiz_node-1] File “/usr/lib/python3.10/importlib/metadata/init.py”, line 171, in load
[topics_quiz_node-1] module = import_module(match.group(‘module’))
[topics_quiz_node-1] File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
[topics_quiz_node-1] return _bootstrap._gcd_import(name[level:], package, level)
[topics_quiz_node-1] File “”, line 1050, in _gcd_import
[topics_quiz_node-1] File “”, line 1027, in _find_and_load
[topics_quiz_node-1] File “”, line 1004, in _find_and_load_unlocked
[topics_quiz_node-1] ModuleNotFoundError: No module named ‘topics_quiz.topics_quiz_node’
[ERROR] [topics_quiz_node-1]: process has died [pid 1955, exit code 1, cmd ‘/home/user/ros2_ws/install/topics_quiz/lib/topics_quiz/topics_quiz_node --ros-args’].
and regarding the setup.py, I just added the entry point and also the location of the launch file as guided:
Blockquote
from setuptools import setup
import os
from glob import glob
Deconstructing this line: 'topics_quiz_node = topics_quiz.topics_quiz_node:main'
You are specifying topics_quiz_node (left side) to be assigned as the main function from the python file named topics_quiz_node.py from the package topics_quiz.
So I am assuming that your python file name is topics_quiz_node.py inside the ros2_ws/src/topics_quiz/topics_quiz folder. If the python file name is different use the correct python file name.
Also, if a init.py file is missing in the ros2_ws/src/topics_quiz/topics_quiz folder, just create an empty python file and name it as init.py.
I followed your advise last night and launch actually works simply but now today when I logged on (nothing has changed), I tried to launch again, it gives me this:
nothing has changed since it was working last night, I even source install/setup.bash and colcon build --packages-select topics_quiz again, still same issue, below is the structure in case you think there is something now right there:
Not exactly, but when you get SetupToolsDeprecationError during compilation, then you need to install setuptools, but only for that session.
As far as being unable to locate the package, I think you are sourcing your workspace in an incorrect manner.
Try to remove the build and install files and compile from scratch again.
As far as I can tell, No. It will not be fixed.
Reason: setuptools comes as a package with the virtual machine (VM) as a bundled software. Every time you exit the VM and come back, the dependency will be reset. So you need to install setuptools everytime you start the VM fresh.
ROS depends on an earlier version of setuptools which is 56.2.0 which is not updated yet. So you need to install the old version of setuptools everytime you start the VM.
So, unless ROS updates its dependency, this cannot be fixed.
ok understood that it is ROS problem, not issue with the vm here.
Thanks for your help so far, much appreciated, I’m about to change my topics quiz node python scripts and will let you know if I run into more issues,
I had just submitted the Unit 3 quiz and got 3 marks only and had accidentally clicked on the check solution button and now I cannot resubmit, (I closed the solution straight away), so can you please reset the score for me so I can resubmit ? I know my robot didnt go through the opening of the wall, so I will resubmit on what I done best,