Launch file not found after proper edits made to setup.py

Hello, I’m struggling with getting the launch file to work properly in the intro course.

I followed the following forum posts, and neither worked for me.

I made sure all proper edits to files were made, Here are my setup.py, two_rover_heartbeat.launch.py, and heartbeat.py. When I was unable to debug them myself, I copy/pasted them from the course examples and it still would not see my launch file after

cd ~/ros2_ws
source install/setup.bash
colcon build
source install/setup.bash
ros2 launch mars_rover_systems [TAB][TAB]

any help would be appreciated.

heartbeat.py -----------------------------------------------

#!/usr/bin/env python

import rclpy
from rclpy.node import Node
import time

class HeartbeatNode(Node):
    def __init__(self,rover_name,timer_period = 0.2):
        self.rover_name = rover_name
        super().__init__(self.rover_name)
        self.create_timer(timer_period,self.timer_callback)
    
    def timer_callback(self):
        timestamp = self.get_clock().now()
        self.get_logger().info(str(self.rover_name) + str(" is alive. ") + "T:" + str(timestamp))




def main(args = None):
    rclpy.init(args=args)

    #create node
    node = HeartbeatNode('mars_rover_1',timer_period=0.5)
    
    rclpy.spin(node)

    
    rclpy.shutdown()


def main2(args = None):
    rclpy.init(args=args)

    #create node
    node = HeartbeatNode('mars_rover_2',timer_period=0.5)
    
    rclpy.spin(node)

    rclpy.shutdown()


if __name__ == '__main__':
    main()

two_rover_heartbeat.launch.py---------------------------------------------------------------

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='mars_rover_systems',
            executable='heartbeat_executable',
            output='screen'),
        Node(
            package='mars_rover_systems',
            executable='heartbeat_executable_2',
            output='screen')
    ])

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:main2'
        ],
    },
)

Hello @aliske ,

The codes seem to be good, so I’d say there’s probably some error in your package structure. Check the following:

  • Make sure the launch file is actually inside the launch folder (sometimes it can be placed outside the folder by mistake)
  • Make sure the launch folder is located correctly inside the package

Best,

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