subscriber.cpp
Go to the documentation of this file.
00001 // Test subscriber
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 #include <stdio.h>
00011 
00012 void handleMsg(const std_msgs::Int8MultiArray& msg)
00013 {
00014   static uint8_t previous = 0;
00015   uint8_t current = msg.data[0];
00016   uint8_t diff = current - previous;
00017   if (diff != 1)
00018   {
00019     ROS_WARN("Missing %u message(s)", diff - 1);
00020   }
00021   ROS_INFO("Got message %u", current);
00022   previous = msg.data[0];
00023 }
00024 
00025 int main(int argc, char** argv)
00026 {
00027   ros::init(argc, argv, "subscriber");
00028   ros::NodeHandle n;
00029   ros::Subscriber sub = n.subscribe("data", 1, &handleMsg, ros::TransportHints().udp());
00030   ros::spin();
00031   return 0;
00032 }


test_roscpp
Author(s): Morgan Quigley, Josh Faust, Brian Gerkey, Troy Straszheim
autogenerated on Mon Oct 6 2014 11:47:21