
.. warning::
   ROS 2 Foxy Fitzroy reached end-of-life in June 2023. We recommend upgrading to ROS 2 Humble for continued support.

Navigation
----------

The B2W supports autonomous navigation using Nav2.

.. image:: media/gifs/b2_vac_demo.webp
    :alt: B2 Navigation Demo
    :width: 100%
    :class: mbsrounded

|

SLAM Mapping
^^^^^^^^^^^^

Create a map using SLAM:

.. code-block:: bash

   ros2 launch b2_navigation slam.launch.py

Save the map when complete:

.. code-block:: bash

   ros2 run nav2_map_server map_saver_cli -f ~/maps/my_map

Localization
^^^^^^^^^^^^

Localize on a saved map:

.. code-block:: bash

   ros2 launch b2_navigation localization.launch.py \
     map:=~/maps/my_map.yaml

Nav2 Navigation
^^^^^^^^^^^^^^^

Launch full navigation stack:

.. code-block:: bash

   ros2 launch b2_navigation navigation.launch.py \
     map:=~/maps/my_map.yaml

Sending Goals
^^^^^^^^^^^^^

**Via RViz2:**

Use the "2D Goal Pose" tool to send navigation goals.

**Via Command Line:**

.. code-block:: bash

   ros2 action send_goal /navigate_to_pose \
     nav2_msgs/action/NavigateToPose \
     "{pose: {header: {frame_id: 'map'}, pose: {position: {x: 1.0, y: 2.0, z: 0.0}, orientation: {w: 1.0}}}}"

Odometry Sources
^^^^^^^^^^^^^^^^

The B2W provides multiple odometry sources:

- ``/b2_unit_001/odom`` - Leg odometry
- ``/b2_unit_001/odom_imu`` - IMU-fused odometry
- ``/odometry/filtered`` - EKF filtered odometry (if configured)
