publisher.cpp
Go to the documentation of this file.
00001 // Publish big data chunks
00002 // Author: Max Schwarz <max.schwarz@uni-bonn.de>
00003 
00004 #include <ros/publisher.h>
00005 #include <ros/init.h>
00006 #include <ros/node_handle.h>
00007 
00008 #include <std_msgs/Int8MultiArray.h>
00009 
00010 int main(int argc, char** argv)
00011 {
00012   ros::init(argc, argv, "publisher");
00013   ros::NodeHandle n;
00014 
00015   const size_t NUM_BYTES = 4000;
00016   std_msgs::Int8MultiArray data;
00017   data.data.reserve(NUM_BYTES);
00018 
00019   ros::Publisher pub = n.advertise<std_msgs::Int8MultiArray>("data", 1);
00020   ros::Rate rate(10.0);
00021 
00022   size_t start = 0;
00023   while(ros::ok())
00024   {
00025     data.data.clear();
00026     for(size_t i = 0; i < NUM_BYTES; ++i)
00027     {
00028       data.data.push_back(start + i);
00029     }
00030     pub.publish(data);
00031     rate.sleep();
00032     start++;
00033   }
00034   return 0;
00035 }


test_roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Thu Jun 6 2019 21:10:42