Skip to content

Instantly share code, notes, and snippets.

@jdumont0201
Created May 4, 2018 11:19
Show Gist options
  • Save jdumont0201/e2ab5e198482ab72ea68bc2e4808a889 to your computer and use it in GitHub Desktop.
Save jdumont0201/e2ab5e198482ab72ea68bc2e4808a889 to your computer and use it in GitHub Desktop.
Minimal ROS Subscriber
#include <ros/ros.h>
#include <std_msgs/Int32>
void counterCallback(const std_msgs::Int32::ConstPtr& msg)
{
ROS_INFO("%d", msg->data);
}
int main(int argc, char** argv) {
ros::init(argc, argv, "topic_subscriber");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("counter", 1000, counterCallback);
ros::spin();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment