In this section, we will see the C++ interpretation of the diff_tf.py node, which subscribes the encoder data and computes the odometry, and publishes the odometry and tf of the robot. We can see the C++ interpretation of this node, called diff_tf.cpp, which can be found in the src folder of a package named chefbot_navig_cpp.
Discussed next are the important code snippets of this code and their explanations. The following code snippet is the constructor of the class Odometry_calc. This class contains the definition of computing odometry. The following code declares the subscriber for the left and right wheel encoders along with the publisher for odom value:
Odometry_calc::Odometry_calc(){ //Initialize ...