talker.cpp
Go to the documentation of this file.
00001 
00011 /*****************************************************************************
00012 ** Includes
00013 *****************************************************************************/
00014 
00015 #include "ros/ros.h"
00016 #include "std_msgs/String.h"
00017 
00018 #include <sstream>
00019 
00023 int main(int argc, char **argv)
00024 {
00035   ros::init(argc, argv, "talker");
00036 
00042   ros::NodeHandle n;
00043 
00061 // %Tag(PUBLISHER)%
00062   ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
00063 // %EndTag(PUBLISHER)%
00064 
00065 // %Tag(LOOP_RATE)%
00066   ros::Rate loop_rate(10);
00067 // %EndTag(LOOP_RATE)%
00068 
00073 // %Tag(ROS_OK)%
00074   int count = 0;
00075   while (ros::ok())
00076   {
00077 // %EndTag(ROS_OK)%
00081 // %Tag(FILL_MESSAGE)%
00082     std_msgs::String msg;
00083 
00084     std::stringstream ss;
00085     ss << "hello world " << count;
00086     msg.data = ss.str();
00087 // %EndTag(FILL_MESSAGE)%
00088 
00089 // %Tag(ROSCONSOLE)%
00090     ROS_INFO("%s", msg.data.c_str());
00091 // %EndTag(ROSCONSOLE)%
00092 
00099 // %Tag(PUBLISH)%
00100     chatter_pub.publish(msg);
00101 // %EndTag(PUBLISH)%
00102 
00103 // %Tag(SPINONCE)%
00104     ros::spinOnce();
00105 // %EndTag(SPINONCE)%
00106 
00107 // %Tag(RATE_SLEEP)%
00108     loop_rate.sleep();
00109 // %EndTag(RATE_SLEEP)%
00110     ++count;
00111   }
00112 
00113 
00114   return 0;
00115 }
00116 // %EndTag(FULLTEXT)%


rocon_unreliable_experiments
Author(s): Daniel Stonier
autogenerated on Mon Oct 6 2014 06:46:44