Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Okay, I think I figured it out. I think it was the result of some combination of two factors, one ROS-related and one embarrassingly not. The non-ROS problem: I had a Vicon motion-capture system publishing to the vrpn_client_node/quadpeter/pose topic, and somehow the Vicon software kept getting paused. Even when I made sure the live-stream was on, though, it still didn't work properly -- until I added a ros::Rate object and a ros::Rate::sleep() function call to the while loop.

My best guess is that I was calling publish() faster than ROS could actually publish the messages, and so the publish requests kept getting overwritten or something like that. When I added code so that it published at a steady rate of 100 times per second, the code worked as expected.

Thank you all for your help. It was useful to know that my code was written correctly (except for publishing faster than ROS could handle), and I appreciate the tips for eliminating global variables.