#################################### ##FILL ME IN #################################### ## links to any required tutorials ## note.0= [[roscpp_tutorials/Tutorials/WritingPublisherSubscriber|Writing a Simple Publisher and Subscriber]] ## note.1= [[roscpp_tutorials/Tutorials/WritingAService|Writing a Simple Service]] ## descriptive title for the tutorial ## title = Using Class Methods as Callbacks ## multi-line description to be displayed in search ## description = Most of the tutorials use functions in their examples, rather than class methods. This is because using functions is simpler, not because class methods are unsupported. This tutorial will show you how to use class methods for subscription and service callbacks. ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link= ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory #################################### <> <> /!\ if no code snippet is shown where it's supposed to be or anything strange in the code shown, please open the link. Code snippet macro might not be working well with github, which is being investigated. == Subscriptions == Suppose you have a simple class, `Listener`: <> Where the `NodeHandle::subscribe()` call using a function would have looked like this: <> ###<> Using a class method looks like this: <> If the subscriber is '''inside''' the class Listener, you can replace the last argument with the keyword '''this''', which means that the subscriber will refer to the class it is part of. == Service Servers == Suppose you have a simple class, `AddTwo`: <> Where the old `NodeHandle::advertiseService()` call would look like: <> The class version looks like this: <> For the full set of `subscribe()`, `advertiseService()`, etc. overloads, see the [[http://www.ros.org/doc/api/roscpp/html/classros_1_1NodeHandle.html|NodeHandle class documentation]] ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE