Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your problem has nothing to do with ROS, but rather C++. From your code, your subscription is not failing, but the object you're instantiating within each "case" statement is going out of scope straight after you instantiate the object.

Try the following: Add ros::Subscriber splitcmd_sub; just below ros::Subscriber h_sub = ... and then change your "case" statements to only have splitcmd_sub = n.subscribe(...);.

That will solve your problem. :-)