0
$\begingroup$

I am studying Ros2 for a college project, I've build this robot using some tutorials to help me. I am now researching how to make a dynamic navigation node. My problem is, everytime I run my robot, I also have to run rviz, localization and navigation. So I was modifying my launch file and encountered an error. enter image description here

Here is the code of my launch file:

import os

from ament_index_python.packages import get_package_share_directory


from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node



def generate_launch_description():


    package_name='my_bot'
    
    config_dir = os.path.join(get_package_share_directory(package_name),'config')
    map_file = os.path.join(config_dir,'casaMapa_save.yaml')
    rviz_config_dir = os.path.join(config_dir,'navigation.rviz')

    rsp = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory(package_name),'launch','rsp.launch.py'
                )]), launch_arguments={'use_sim_time': 'true'}.items()
    )

    # Include the Gazebo launch file, provided by the gazebo_ros package
    gazebo = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]),
             )

    # Run the spawner node from the gazebo_ros package. The entity name doesn't really matter if you only have a single robot.
    spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                        arguments=['-topic', 'robot_description',
                                   '-entity', 'my_bot'],
                        output='screen')

    localization = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory(package_name),'launch','localization_launch.py'
                )]), launch_arguments=[{'use_sim_time': 'true'}.items(), {'map' : map_file}]
    )
    
    navigation = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory(package_name),'launch','navigation_launch.py'
                )]), launch_arguments=[{'use_sim_time': 'true'}.items(), {'map_subscribe_transient_local' : 'true'}]
    )

    rviz = Node(package='rviz2',
                executable='rviz2',
                name='rviz2_node',
                arguments=['-d', rviz_config_dir],
                output='screen'
                )


    return LaunchDescription([
        rsp,
        gazebo,
        spawn_entity,
        rviz,
        localization,
        navigation,
    ])

Any help would be appreciated!

$\endgroup$
1
  • $\begingroup$ Please paste any console output as code formatted text, and not as screenshots. Images are not text searchable, amongst other things... $\endgroup$ Commented May 28 at 19:43

1 Answer 1

0
$\begingroup$

I think your error may be with the launch_argments in the rsp section. In the other sections launch_arguments has 2 tuples, while rsp only has one. This would explain the "not enough variables to unpack, expected 2 but got 1" error

$\endgroup$
1
  • $\begingroup$ No, it didn't solve it. Actually, when i just comment localization and navigation in return LaunchDescription it still partially works, but when i tried putting a tuple as an input for rsp i got the same error as before $\endgroup$ Commented Jun 6 at 18:48

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.