ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I would do the following.
bool is_receive;
void callback_topic_A(msgtype &msg)
{
is_receive = true;
}
// ...
ros::Rate loop(frequency);
is_receive = false;
while(ros::ok()){
if (new message on topic A is received){
//do some computations and publish messages
is_receive = false;
}
loop.sleep();
ros::spinOnce();
}
If there is a better way, I would love to know.
2 | No.2 Revision |
I would do the following.
bool is_receive;
void callback_topic_A(msgtype &msg)
{
is_receive = true;
}
// ...
ros::Rate loop(frequency);
is_receive = false;
while(ros::ok()){
if (new message on topic A is received){
(is_receive){
//do some computations and publish messages
is_receive = false;
}
loop.sleep();
ros::spinOnce();
}
If there is a better way, I would love to know.