How to properly use nav2_costmap_2d node

asked 2022-03-03 07:22:57 -0500

ahopsu gravatar image

Hi!

I have a problem, that I don't fully understand how to use (properly) the Lifecycle nodes (especially the costmap node).

I'm unable to, for example, change the name of the node. No matter what, the costmap node I launch has always the name(space) costmap. I get the costmap node automatically start up / activate with the lifecycle manager, when I use the following launch and parameter files:

launch.py:

import launch
import launch_ros

def generate_launch_description():

    parameter_file = './costmap_params.yaml'

    return launch.LaunchDescription([

        launch_ros.actions.LifecycleNode(
            package = 'nav2_costmap_2d',
            executable = 'nav2_costmap_2d',
#            name = 'my_costmap', # This does not seem to have any effect?
#            namespace = 'test_namespace',
            name = 'costmap',
            namespace = 'costmap',
            parameters = [parameter_file],
        ),

        launch_ros.actions.LifecycleNode(
            package = 'nav2_lifecycle_manager',
            executable = 'lifecycle_manager',
            name = 'my_lifecycle_manager',
#            namespace = 'test_namespace',
            namespace = 'costmap',
            parameters = [
                {'autostart' : True},
#                {'node_names' : ['my_costmap']},
                {'node_names' : ['costmap']},
              #  {'bond_timeout' : 0.0},
            ],
        )

    ])

costmap_params.yaml:

#test_namespace:
#  my_costmap:
costmap:
  costmap:
    ros__parameters:
      update_frequency: 5.0
      publish_frequency: 5.0
      global_frame: map
      robot_base_frame: base_link
      use_sim_time: False
      rolling_window: true
      width: 3
      height: 3
      resolution: 0.05

But when I change the node name(space), for example to those, what I have commented out, the lifecycle manager is unable to bring the costmap node up. The reason to this seems to be, that the costmap node is still having the default name(space) costmap, which can be seen in the figure below:

image description

Interesting thing is, that the lifecycle node is able to change it's name(space).

edit retag flag offensive close merge delete

Comments

Also, another question is, that when I launch the costmap node, it will be shutdown after 4 seconds, as it was not able to be bonded? I don't really understand also about this concept / know how to use it, so that's why I'm disabling the bonding by setting the parameter to 0.0

ahopsu gravatar image ahopsu  ( 2022-03-03 07:28:10 -0500 )edit