subscriber.cpp
Go to the documentation of this file.
1 // own class header first: https://stackoverflow.com/a/2762596/8224054
3 
4 #include <string>
5 
6 namespace ros1_ros_cpptemplate
7 {
8 
9 Subscriber::Subscriber(ros::NodeHandle& node_handle, const std::string& topic_name)
10 {
11  // Subscribing should be last after everything else of the class is ready
12  int queue_size = 10;
13  subscriber_ = node_handle.subscribe(topic_name, queue_size, &Subscriber::callback, this);
14 }
15 
17 {
18 }
19 
20 void Subscriber::callback(const std_msgs::Int32Ptr& number)
21 {
22  ROS_INFO_STREAM("Got number " << number->data << " on " << subscriber_.getTopic());
23 }
24 
25 } // namespace
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual void callback(const std_msgs::Int32Ptr &number)
Definition: subscriber.cpp:20
ros::Subscriber subscriber_
Actual subscriber.
Definition: subscriber.hpp:49
std::string getTopic() const
#define ROS_INFO_STREAM(args)


ros1_ros_cpptemplate
Author(s): Alexander Reimann
autogenerated on Sat Sep 2 2017 02:38:06