The ROS 2 Navigation Stack relates upon:
a. nav_msgs/Odometry messages published on a ROS 2 topic.
b. coordinate transform from odom (parent frame) to base_link (child frame).
In other words (quote): "Keep in mind that Nav2 requires the nav_msgs/Odometry message and odom => base_link transforms to be published and this should be your goal when setting up your odometry system."
Note that the odom frame is connected to the rest of the system through the odom to base_link transform. This transform can either be published by a tf2 broadcaster or by frameworks such as robot_localization.
As an example (fron ROS2 official documentation), let's see how we can use wheel encoders to provide Nav2 with odometry. We need to publish the nav_msgs/Odometry message and odom to base_link transform. Calculation looks like (this is a simplified approach):
linear = (right_wheel_est_vel + left_wheel_est_vel) / 2 angular = (right_wheel_est_vel - left_wheel_est_vel) / wheel_separation;
Usually, we would like to use one of ROS2 plugins to do this job (like the ros2_control framework, that provides a diff_drive_controller under the ros2_controller package. The diff_drive_controller takes in the geometry_msgs/Twist messages published on cmd_vel topic, computes odometry information, and publishes nav_msgs/Odometry messages on odom topic. Other packages that deal with different kind of sensors are also available in ros2_control).
In other words, if we do everything right, then the differential drive plugin will provide odometry to Nav2 packages.
We are going to add the IMU (inertial) sensor and the differential drive plugins of Gazebo to our URDF. For an overview of the different plugins available in Gazebo, check here: Using Gazebo plugins with ROS.