Skip to content

Instantly share code, notes, and snippets.

@sipah00
Last active August 16, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sipah00/f06ed1ec7bea99b284952d8c12a817c4 to your computer and use it in GitHub Desktop.
Save sipah00/f06ed1ec7bea99b284952d8c12a817c4 to your computer and use it in GitHub Desktop.
#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