talker.cpp
Go to the documentation of this file.
00001 // talker.cpp : Defines the entry point for the console application.
00002 //
00003 
00004 #include "stdafx.h"
00005 #include <string>
00006 #include <iostream>
00007 #include <sstream>
00008 #include <ros/ros.h>
00009 #include <std_msgs/String.h>
00010 
00011 //int _tmain(int argc, _TCHAR* argv[])
00012 int _tmain(int argc, char** argv)
00013 {
00014    std::cout << "Hello Dude" << std::endl;
00025   std::string name("talker");
00026  
00027   ros::init(argc, argv, name);
00028 
00034   ros::NodeHandle n;
00035 
00053   ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
00054   ros::Rate loop_rate(10);
00055 
00060   int count = 0;
00061   while (ros::ok())
00062   {
00066     std_msgs::String msg;
00067 
00068     std::stringstream ss;
00069     ss << "hello world " << count;
00070     msg.data = ss.str();
00071 
00072     ROS_INFO("%s", msg.data.c_str());
00073 
00080     chatter_pub.publish(msg);
00081 
00082     ros::spinOnce();
00083 
00084     loop_rate.sleep();
00085     ++count;
00086   }
00087 
00088 
00089         std::cout << "Enter 'q' to quit" << std::endl;
00090         char c;
00091         std::cin >> c;
00092         return 0;
00093 }
00094 
00095 


msvc_sdk_tutorials
Author(s): Daniel Stonier
autogenerated on Fri Jan 3 2014 12:16:36