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

Your code is a bit fuzzy and won't compile, but in principle yes, you can do all of that.

A callback is just a method that you can call manually if you need to. You can also create subscriptions whenever you want.

There is only one flaw in your code: The subscribers/publishers are declared locally, so once the function is done, they will be destroyed.