0
$\begingroup$

This question is almost similar to the other one which has the same issue of _launch.py was not found in the share package. What differs is i created the package using ament_cmake. So i created a urdf file for the robot and launch file attached below

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import ExecuteProcess
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
    package_name = 'round_bot'

    pkg_share = get_package_share_directory(package_name)

    urdf_file_path = os.path.join(pkg_share, 'description', 'round_bot.urdf')

    with open(urdf_file_path, 'r') as urdf_file:
        robot_description = urdf_file.read()

    rviz_node = Node(
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        output='screen'
    )

    robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher',
        output='both',
        parameters=[{'robot_description': robot_description}],
    )

    joint_state_publisher_gui = Node(
        package='joint_state_publisher_gui',
        executable='joint_state_publisher_gui',
        name='joint_state_publisher_gui'
    )

    gazebo = ExecuteProcess(
        cmd=['gazebo', '--verbose'], 
        output='screen'
    )

    return LaunchDescription([
        rviz_node,
        robot_state_publisher,
        joint_state_publisher_gui,
        gazebo
    ])

i went through the ros2 wiki documentation, but i don't know why this issue heads up. Do i have to modify something in the CMakeLists.txt or package.xml file.

$\endgroup$

1 Answer 1

0
$\begingroup$

You'd have to install the launch directory into your install space - in your CMakeLists.txt file, you can add the following section :

install(
    DIRECTORY launch
    DESTINATION share/${PROJECT_NAME}
)

This would now copy over the entire launch directory over to the install space.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for your response. It worked out. $\endgroup$
    – Vasanth
    Commented Mar 22 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.