ros::Subscriber odom_sub = n.subscribe("p3dx/odom", 1000, velsubcallback);

outside the while loop. the subscriber only needs to be created once! And be sure to call ros::spinOnce() in your loop. This is the point code code where your callback are actually called!