ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Well, your x and y "before" values are -nan. Adding anything to nan will still yield nan. If I had to guess, you are going through one loop iteration before your callbacks actually receive any data.

Also, consider this bit of code:

while(n.ok())
    {
        ros::spinOnce();               // check for incoming messages
        fr_enc = n.subscribe("front_encoders", 1, feCallBack);
        rr_enc = n.subscribe("rear_encoders", 1, reCallBack);

You are repeatedly subscribing to the topics for every loop iteration. Move lines 56 and 57 out of the while loop:

fr_enc = n.subscribe("front_encoders", 1, feCallBack);
rr_enc = n.subscribe("rear_encoders", 1, reCallBack);

while(n.ok())
    {
        ros::spinOnce();               // check for incoming messages