Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "ros/ros.h"
00009 #include "std_msgs/String.h"
00010 #include <sstream>
00011
00012 int main(int argc, char **argv)
00013 {
00014
00015 ros::init(argc, argv, "talker_node");
00016
00017
00018 ros::NodeHandle n;
00019
00020 ros::Publisher chatter_publisher = n.advertise<std_msgs::String>("chatter", 1000);
00021
00022 ros::Rate loop_rate(0.5);
00023
00024 int count = 0;
00025 while (ros::ok())
00026 {
00027
00028
00029 std_msgs::String msg;
00030
00031
00032 std::stringstream ss;
00033 ss << "Hello World " << count;
00034
00035 msg.data = ss.str();
00036
00037
00038 ROS_INFO("[Talker] I published %s\n", msg.data.c_str());
00039
00040
00041 chatter_publisher.publish(msg);
00042
00043 ros::spinOnce();
00044
00045 loop_rate.sleep();
00046 count++;
00047 }
00048 return 0;
00049 }
00050
00051