Main Page
Namespaces
Classes
Files
File List
File Members
src
subscriber.cpp
Go to the documentation of this file.
1
// own class header first: https://stackoverflow.com/a/2762596/8224054
2
#include "
ros1_ros_cpptemplate/subscriber.hpp
"
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
16
Subscriber::~Subscriber
()
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
ros::NodeHandle
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros1_ros_cpptemplate::Subscriber::~Subscriber
virtual ~Subscriber()
Definition:
subscriber.cpp:16
ros1_ros_cpptemplate::Subscriber::Subscriber
Subscriber()
Definition:
subscriber.hpp:44
ros1_ros_cpptemplate::Subscriber::callback
virtual void callback(const std_msgs::Int32Ptr &number)
Definition:
subscriber.cpp:20
ros1_ros_cpptemplate::Subscriber::subscriber_
ros::Subscriber subscriber_
Actual subscriber.
Definition:
subscriber.hpp:49
ros::Subscriber::getTopic
std::string getTopic() const
subscriber.hpp
ROS_INFO_STREAM
#define ROS_INFO_STREAM(args)
ros1_ros_cpptemplate
Definition:
publisher.hpp:12
ros1_ros_cpptemplate
Author(s): Alexander Reimann
autogenerated on Sat Sep 2 2017 02:38:06