Created
July 17, 2018 18:01
-
-
Save Tutorgaming/97763617e66247b32b608b93591a2aa6 to your computer and use it in GitHub Desktop.
chatter_subscriber_tutorial - Publisher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ros/ros.h" | |
#include "std_msgs/String.h" | |
#include <sstream> | |
int main(int argc, char **argv) | |
{ | |
ros::init(argc, argv, "talker"); | |
ros::NodeHandle n; | |
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000); | |
ros::Rate loop_rate(10); | |
int count = 0; | |
while (ros::ok()) | |
{ | |
std_msgs::String msg; | |
std::stringstream ss; | |
ss << "hello world " << count; | |
msg.data = ss.str(); | |
ROS_INFO("%s", msg.data.c_str()); | |
chatter_pub.publish(msg); | |
ros::spinOnce(); | |
loop_rate.sleep(); | |
++count; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment