ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Something like will do the job.
void callback()
{
static counter = 0;
counter++;
std::cout << counter << std::endl;
}
int main()
{
ros::init(argc, argv, "node_name");
ros::Subscriber sub = n.subscribe("your_sub_topic", 1, callback);
ros::spin();
}
2 | No.2 Revision |
Something like will do the job.
void callback()
callback(msg::type & msg)
{
static counter = 0;
counter++;
std::cout << counter << std::endl;
}
int main()
{
ros::init(argc, argv, "node_name");
ros::Subscriber sub = n.subscribe("your_sub_topic", 1, callback);
ros::spin();
}
3 | No.3 Revision |
Something like will do the job.
void callback(msg::type & msg)
{
static int counter = 0;
counter++;
std::cout << counter << std::endl;
}
int main()
{
ros::init(argc, argv, "node_name");
ros::Subscriber sub = n.subscribe("your_sub_topic", 1, callback);
ros::spin();
}