test
src
publisher_rate.cpp
Go to the documentation of this file.
1
// Publish big data chunks
2
// Author: Max Schwarz <max.schwarz@uni-bonn.de>
3
4
#include <
ros/publisher.h
>
5
#include <
ros/init.h
>
6
#include <
ros/node_handle.h
>
7
8
#include <std_msgs/Int8MultiArray.h>
9
10
int
main
(
int
argc,
char
** argv)
11
{
12
ros::init
(argc, argv,
"publisher"
);
13
ros::NodeHandle
n;
14
15
const
size_t
NUM_BYTES
= 8;
16
std_msgs::Int8MultiArray data;
17
data.data.reserve(
NUM_BYTES
);
18
19
assert(argc > 1);
20
float
frequency = atof(argv[1]);
21
22
ros::Publisher
pub = n.
advertise
<std_msgs::Int8MultiArray>(
"data"
, 1);
23
ros::Rate
rate(frequency);
24
25
size_t
start
= 0;
26
while
(
ros::ok
())
27
{
28
data.data.clear();
29
for
(
size_t
i = 0; i <
NUM_BYTES
; ++i)
30
{
31
data.data.push_back(
start
+ i);
32
}
33
pub.
publish
(data);
34
rate.sleep();
35
start
++;
36
}
37
return
0;
38
}
node_handle.h
ros::Publisher
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
init.h
NUM_BYTES
dictionary NUM_BYTES
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
publisher.h
ros::ok
ROSCPP_DECL bool ok()
main
int main(int argc, char **argv)
Definition:
publisher_rate.cpp:10
start
ROSCPP_DECL void start()
ros::Rate
ros::NodeHandle
test_roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
, Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:57