Go to the documentation of this file.00001
00011
00012
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
00062 ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
00063
00064
00065
00066 ros::Rate loop_rate(10);
00067
00068
00073
00074 int count = 0;
00075 while (ros::ok())
00076 {
00077
00081
00082 std_msgs::String msg;
00083
00084 std::stringstream ss;
00085 ss << "hello world " << count;
00086 msg.data = ss.str();
00087
00088
00089
00090 ROS_INFO("%s", msg.data.c_str());
00091
00092
00099
00100 chatter_pub.publish(msg);
00101
00102
00103
00104 ros::spinOnce();
00105
00106
00107
00108 loop_rate.sleep();
00109
00110 ++count;
00111 }
00112
00113
00114 return 0;
00115 }
00116