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

Revision history [back]

click to hide/show revision 1
initial version

Read the Publisher Subsriber Tutorial carefully:

When all copies of the Subscriber object go out of scope, this callback will automatically be unsubscribed from this topic.

And this is exactly what happens to you. The subscriber goes out of scope and unsubscribes.

Oh I just have seen even your variable splitcmd_sub goes out of scope after each case.

Have a look at C++ scoping.