Skip to content

Instantly share code, notes, and snippets.

@Tutorgaming
Created July 17, 2018 18:01
Show Gist options
  • Save Tutorgaming/e10c4899eef4b067f6c2a7d502023f4c to your computer and use it in GitHub Desktop.
Save Tutorgaming/e10c4899eef4b067f6c2a7d502023f4c to your computer and use it in GitHub Desktop.
chatter_subscriber_tutorial - Subscriber
#include "ros/ros.h"
#include "std_msgs/String.h"
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
ros::spin();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment