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");
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 }
ROSCPP_DECL void start()
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
Definition: publisher.cpp:10
ROSCPP_DECL bool ok()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
dictionary NUM_BYTES


test_roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:46