while loop lock subcribing
Hi everybody,I'm part of an international project team working on robot using ROS. We are stuck with a problem about multithreading. The code below never exit the loop because of the _current_angle is not changed:
while(ros::ok() && _current_angle <= -1)
{
ROS_INFO("[Navigation::Navigation] angle: %g", _current_angle);
_motor_power_pub.publish(_motor_power_msg);
ros::spinOnce();
loop_rate.sleep();
}
You may be agree that it should not change by itself but the _current_angle is modified in a function called back by the subscriber.
The problem, I think, is that during the while loop the function called back from the subscriber is not executed. How should we manage it then ?
PS : the _current_angle is a class' attribute and the part of the code below is in the constructor of this class.