As you have seen in other examples with Gazebo, our robot moves in the simulated world just like a robot in the real world. We use a driver for our robot, diffdrive_plugin.
This driver publishes the odometry generated in the simulated world, so we do not need to write anything for Gazebo.
Execute the robot sample in Gazebo to see the odometry working. Type the following commands in the shell:
$ roslaunch chapter5_tutorials gazebo_xacro.launch model:="'rospack find robot1_description'/urdf/robot1_base_04.xacro" $ rosrun teleop_twist_keyboard teleop_twist_keyboard.py
Then, with the teleop node, move the robot for a few seconds to generate new data on the odometry topic.
On the screen of the Gazebo simulator, ...