Setting the initial pose using config in NAV2

While working through the articubots tutorials I have been setting my initial pose for nav2 manually using rviz2. It works but it can be a little tedious when testing changes that require frequent restarts.

Luckily, there’s a small section of config in nav2_params.yaml that you can use to set your initial pose:

amcl:
  ros__parameters:
    ...
    set_initial_pose: true
    initial_pose:
      x: -3.644
      y: -5.596
      yaw: -2.793

This means that it will default to this location when starting up.

Once you’ve configured it, you should see something like the following in your localization startup:

...
[map_server-1] [INFO] [1679645323.134873176] [map_server]: Configuring
[map_server-1] [INFO] [map_io]: Loading yaml file: /home/parallels/Desktop/dev_ws/install/my_bot/share/my_bot/maps/21_03_2023.yaml
[map_server-1] [DEBUG] [map_io]: resolution: 0.05
[map_server-1] [DEBUG] [map_io]: origin[0]: -7.34
[map_server-1] [DEBUG] [map_io]: origin[1]: -9.37
[map_server-1] [DEBUG] [map_io]: origin[2]: 0
[map_server-1] [DEBUG] [map_io]: free_thresh: 0.25
[map_server-1] [DEBUG] [map_io]: occupied_thresh: 0.65
[map_server-1] [DEBUG] [map_io]: mode: trinary
[map_server-1] [DEBUG] [map_io]: negate: 0
...

There’s a bit more info on this setup here, as well as a few notes on how to set it programatically instead.