Hi Davide,
Great question! You are correct that to control the motion of the
robot, we publish Twist messages on the /cmd_vel topic and listen on
the /odom topic. However, the base
controller node does
things in reverse.
For example, suppose you are trying to teleop the robot using a
joystick or some other manual control. In this case, the teleop
node needs to
publish motion commands on the /cmd_vel topic
but the base controller node (which talks more-or-less directly to
the motor control hardware) must
listen on this topic in order to respond to your commands.
At the same time, the base controller node typically reads encoder
data (and perhaps gyro data as well) from the underlying hardware
and publishes the data as a ROS Odometry message on the /odom
topic. Other nodes like move_base in the Navigation stack can then
subscribe to the /odom topic so they can track the movement of the
robot.
A good example of a ROS base controller node can be found in the
ros_arduino_bridge
package. In particular, take a look at the
base_controller.py
file which subscribes to the /cmd_vel topic and publishes on the
/odom topic.
--patrick