Error in Launch File detection

Hello there,

I have been doing the “ROS2 Basics in 5 Days (Python)” course, and in the topic 2.7 creating a launch file, i am not able to launch the launch file for “Exercise 3”

I have followed all the steps so far, and when i come to the part where i have to launch the file using the command “ros2 launch”, it is showing that the file does not exist.

i have attached a screenshot of the whole console displaying the editor, file tree and terminal

Please help, if you need further clarification, please message :slight_smile:

thanks in advance,
Dhananjay S Panth

Screenshot:

Hi @Dhananjay_Panth, the error indicates that the two_rover_heartbeat.py file is not found in the share directory of the mars_rover_systems package. This typically happens due to a missing or incorrect configuration in the package’s setup.py. Can you share the setup.py? The problem must be there.

Hi @jpvaldivia7 this is the code present inside setup.py :

from setuptools import find_packages, setup
import os
from glob import glob

package_name = ‘mars_rover_systems’

setup(
name=package_name,
version=‘0.0.0’,
packages=find_packages(exclude=[‘test’]),
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’: [
‘heartbeat_executable = mars_rover_systems.heartbeat:main’,
‘heartbeat_executable_2 = mars_rover_systems.heartbeat:main_2’
],
},
)

Would you like anything else?

P:S: The “setuptools” library always throws up an error, as seen in the above pic, it always shows "Import “setuptools” could not be resolved from sourcePylance(reportMissingModuleSource)
" When i did this course back in june, i had the same problem then, and now also. Same problem, In the same exercise. i dont know whether it is my fault, or something else…

I can see the issue here, the problem is with the line:

(os.path.join('share', package_name), glob('launch/*.launch.py'))

You named your file two_rover_heartbeat.py and in the setup.py you are saying that it is a .launch.py so all you have to do is rename your script to two_rover_heartbeat.launch.py which is the extension for launch files in ROS2.

Ah i see…

So i went ahead and renamed the “two_rover_heartbeat.py” into “two_rover_heartbeat.launch.py”, but now i am getting this:

What am i doing wrong :pensive:

I even did “source install/setup.bash” and “colcon build”

It seems the changes were not applied successfully. Here’s how you can verify and fix this:
Navigate to the install/share/mars_rover_systems/launch folder to ensure that the file with the updated name is present. You can do this with:

ls ~/ros2_ws/install/share/mars_rover_systems/launch/

Here you should see your two_rover_heartbeat.launch.py, if the file is not listed, it means the changes in your setup.py were not applied during the build process and you have to compile and source again.

Sir it appears that there is no launch file, i.e, “two_rover_heartbeat.launch.py”, nor my launch folder inside the " share" folder…

This is my Folder tree, let me know if you need the titles of any other folders too…

How has this happened, and how do i fix this, i did compiling and sourcing again, but nothing happened…

This is how my console looks now: (could’nt upload together)

I found the error, in your folder tree you have the launch file inside the /mars_rover_systems/mars_rover_systems/launch and it should be /mars_rover_systems/launch, the launch folder must be at the same level as resource, test and mars_rover_systems folders as the notebook says. Make this correction and now I am sure that it will work.

Here is how your folder tree should look like (just the mars_rover_systems package).

Got it working @jpvaldivia7 Thanks a lot for your help :innocent:

1 Like

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