test
src
publisher.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
= 4000;
16
std_msgs::Int8MultiArray data;
17
data.data.reserve(
NUM_BYTES
);
18
19
ros::Publisher
pub = n.
advertise
<std_msgs::Int8MultiArray>(
"data"
, 1);
20
ros::Rate
rate(10.0);
21
22
size_t
start
= 0;
23
while
(
ros::ok
())
24
{
25
data.data.clear();
26
for
(
size_t
i = 0; i <
NUM_BYTES
; ++i)
27
{
28
data.data.push_back(
start
+ i);
29
}
30
pub.
publish
(data);
31
rate.sleep();
32
start
++;
33
}
34
return
0;
35
}
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.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