Unable to launch my launch file

Hello Masters,

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’

Hi @wai.mak ,

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.

Regards,
Girish

Hi @girishkumar.kannan ,

It picked up the launch file now thanks but now im facing other more errors,

Saying the topics_quiz package does not exist…

But colcon build is successful on my topics_quiz package…

I am lost again… please advise

Hi @wai.mak ,

Could you please post the complete error output as a code-block?
That will help me understand what the exact problem is, and help you out.

Regards,
Girish

thanks @girishkumar.kannan ,

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’].

Hi @wai.mak ,

I believe this is a dependency issue due to setuptools.
Try to do pip install setuptools==56.2.0 before compiling.

So your steps will be:

cd
pip install setuptools==56.2.0
cd ~/ros2_ws
rm -rf ./build ./install ./log
colcon build
...

I believe you have some issues in your setup.py file. You need to check that.

But before working on the setup.py file, do the setuptools install and try to launch.
If that fails, it means that your setup.py file has issues.

I believe that should fix your issue.

Regards,
Girish

Hi @girishkumar.kannan ,

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

package_name = ‘topics_quiz’

setup(
name=package_name,
version=‘0.0.0’,
packages=[package_name],
data_files=[
(‘share/ament_index/resource_index/packages’,
[‘resource/’ + package_name]),
(‘share/’ + package_name, [‘package.xml’]),
(os.path.join(‘share’, package_name), glob(‘launch/*.launch.py’))
],
install_requires=[‘setuptools’],
zip_safe=True,
maintainer=‘user’,
maintainer_email=‘user@todo.todo’,
description=‘TODO: Package description’,
license=‘TODO: License declaration’,
tests_require=[‘pytest’],
entry_points={
‘console_scripts’: [
‘topics_quiz_node = topics_quiz.topics_quiz_node:main’
],
},
)

Blockquote

Hi @wai.mak ,

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 hope this should fix your issue.

Regards,
Girish

Hi @girishkumar.kannan ,

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:

Blockquote user:~/ros2_ws$ ros2 launch topics_quiz topics_quiz_launch_file.launch.py
Package ‘topics_quiz’ not found: “package ‘topics_quiz’ not found, searching: [‘/home/simulations/ros2_sims_ws/install/turtlebot3’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_teleop’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_simulations’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_navigation2’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_example’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_msgs’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_gazebo’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_bringup’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_description’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_cartographer’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_as’, ‘/home/simulations/ros2_sims_ws/install/t3_action_msg’, ‘/home/simulations/ros2_sims_ws/install/services_pkg’, ‘/home/simulations/ros2_sims_ws/install/dynamixel_sdk’, ‘/opt/ros/humble’]”

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:

image

Inside the terminal:

image

Hi @wai.mak ,

From this image, I understand that the compilation did not go well.
It says that there was an error output during the compilation of topics_quiz.

EDIT:
You have to check that and fix it.
I think you forgot to re-install setuptools==56.2.0.
Then compile and run, it should work.

Regards,
Girish

Hi @girishkumar.kannan,

so does that mean every time I start unit 3 I have to reinstall setuptools??

I had reinstalled the setuptools again, this time compiling the package has no errors but still unable to locate package:

Hi @wai.mak ,

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.

cd ~/ros2_ws
rm -rf ./build ./install ./log
colcon build && source install/setup.bash
ros2 launch topics_quiz topics_quiz_launch_file.launch.py

This should fix your issues.

Regards,
Girish

Hi @girishkumar.kannan ,

but how could this be? it was working in last night session,

today and tonight’s session, it broke…, sounds very inconsistent,

I tried all your steps mentioned above and still same error message “package topics_quiz” not found…

Blockquote Installing collected packages: setuptools
Successfully installed setuptools-56.2.0user:~/ros2_ws$ cd ~/ros2_ws
user:~/ros2_ws$ rm -rf ./build ./install ./log
user:~/ros2_ws$ colcon build && source install/setup.bash
[1.135s] WARNING:colcon.colcon_core.package_identification:Failed to parse ROS package manifest in ‘src/topics_quiz’: Error(s) in package ‘src/
topics_quiz/package.xml’:
Error(s):

  • The generic dependency on ‘rclpy’ is redundant with: build_depend, exec_depend
  • The generic dependency on ‘std_msgs’ is redundant with: build_depend, exec_depend
  • The generic dependency on ‘nav_msgs’ is redundant with: build_depend, exec_depend- The generic dependency on ‘geometry_msgs’ is redundant with: build_depend, exec_depend- The generic dependency on ‘numpy’ is redundant with: build_depend, exec_depend- The generic dependency on ‘nav_msgs’ is redundant with: build_depend, build_export_depend, exec_dependStarting >>> topics_quizFinished <<< topics_quiz [2.28s]Summary: 1 package finished [3.52s]user:~/ros2_ws$ ros2 launch topics_quiz topics_quiz_launch_file.launch.pyPackage ‘topics_quiz’ not found: “package ‘topics_quiz’ not found, searching: [‘/home/simulations/ros2_sims_ws/install/turtlebot3’, ‘/home/simu
    lations/ros2_sims_ws/install/turtlebot3_teleop’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_simulations’, ‘/home/simulations/ros2_sims_
    ws/install/turtlebot3_navigation2’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_example’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_msgs’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_gazebo’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_bringup’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_description’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_cartographer’, ‘/home/simulations/ros2_sims_ws/install/turtlebot3_as’, ‘/home/simulations/ros2_sims_ws/install/t3_action_msg’, ‘/home/simulations/ros2_sims_ws/install/services_pkg’, ‘/home/simulations/ros2_sims_ws/install/dynamixel_sdk’, ‘/opt/ros/humble’]”

Below is my package.xml:

Hi @wai.mak ,

Your package.xml seems to have unnecessary wrong lines. Did you copy paste from ROS1?
package.xml in ROS2 operates differently compared to ROS1.

You have just the <depend> tag only. <build_depend> and <exec_depend> are NEVER USED in ROS2. Did you go through the course properly?

Remove those lines and compile again. It might work properly.

Regards,
Girish

Hi @girishkumar.kannan ,

Ok that worked thanks BUT every time in a new session I have to pip install setuptools…will this be fix???

Blockquote user:~/ros2_ws$ 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 4.8 MB/s eta 0:00:00
Installing collected packages: setuptoolsSuccessfully installed setuptools-56.2.0user:~/ros2_ws$ cd ~/ros2_wsuser:~/ros2_ws$ rm -rf ./build ./install ./loguser:~/ros2_ws$ colcon build && source install/setup.bash[1.221s] 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 existStarting >>> topics_quiz
Finished <<< topics_quiz [2.55s]

Summary: 1 package finished [3.27s]
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-08-02-01-42-58-769850-4_xterm-1551
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [topics_quiz_node-1]: process started with pid [1552]
[topics_quiz_node-1] [INFO] [1690940583.565493459] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-2.0089407980448977, y=-3.499986409387027, z=0.0089480998166839)”
[topics_quiz_node-1] [INFO] [1690940584.030440906] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-1.9569442227770544, y=-3.500148977106791, z=0.008948101399044932)”
[topics_quiz_node-1] [INFO] [1690940584.529985249] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-1.7516086960641084, y=-3.5007922838369727, z=0.008948099806140895)”
[topics_quiz_node-1] [INFO] [1690940585.030145479] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-1.5646274551964987, y=-3.501379334812391, z=0.008948099800073928)”
[topics_quiz_node-1] [INFO] [1690940585.530109363] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-1.3436496298536034, y=-3.502074636562888, z=0.008948099792894352)”
[topics_quiz_node-1] [INFO] [1690940586.029965090] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-1.1396701033671892, y=-3.5027179094153644, z=0.008948099786257834)”
[topics_quiz_node-1] [INFO] [1690940586.530428275] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-0.9526888746414667, y=-3.5033088038444524, z=0.008948099780166632)”
[topics_quiz_node-1] [INFO] [1690940587.030052061] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-0.7317110636778625, y=-3.5040086474111183, z=0.00894809977295838)”
[topics_quiz_node-1] [INFO] [1690940587.530116416] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-0.5277315504932637, y=-3.504656112276058, z=0.008948099766295356)”
[topics_quiz_node-1] [INFO] [1690940588.030104567] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-0.34075033398499555, y=-3.5052508490151952, z=0.008948099760179814)”
[topics_quiz_node-1] [INFO] [1690940588.530070382] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=-0.13677082934188983, y=-3.5059009914490966, z=0.008948099753499816)”
[topics_quiz_node-1] [INFO] [1690940589.030185760] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=0.05021037932128914, y=-3.506498182387079, z=0.008948099747368675)”
[topics_quiz_node-1] [INFO] [1690940589.530082155] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=0.2541898753893405, y=-3.5071510018658523, z=0.008948099740671643)”
[topics_quiz_node-1] [INFO] [1690940590.030013749] [topics_quiz_node]: I receive: “geometry_msgs.msg.Point(x=0.4411710761766858, y=-3.5077506465189536, z=0.008948099734524895)”

Hi @wai.mak ,

Awesome!

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.

I hope you understood this.

Regards,
Girish

@girishkumar.kannan ,

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,

Hi @girishkumar.kannan ,

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,

Please help!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.