mavros icon indicating copy to clipboard operation
mavros copied to clipboard

Is there a way to get newest mission / waypoints from FCU ?

Open HGGshiwo opened this issue 7 months ago • 3 comments

Hi: I want to get the latest waypoints, but the update of the waypoints topic seems random to me, and it is possible to get the waypoints before the pull through mission/pull + waypoints callback function. Is there a way to actively get the waypoints that are guaranteed to be the latest?

case1:

call pull service here
// global variable waypoints here may be old;

case2:

called = False
call pull service here
// waypoints callback was called and set called to True in another thread
while not called:
    pass
// global variable waypoints may still be old, becuase I run ros::spin and above code in two thread

HGGshiwo avatar May 22 '25 12:05 HGGshiwo

Subscribe to waypoints, then call pull and wait till it done. wp_received must match the list.

vooon avatar May 22 '25 14:05 vooon

Subscribe to waypoints, then call pull and wait till it done. wp_received must match the list.

Thanks for your reply. I saved the waypoints obtained in the waypoints callback function in a global variable. Now I am not sure whether the latest waypoints can be obtained when the next line of code accesses the variable after the pull is completed (my FCU may have a set of old waypoints before the update). According to the results of my test, there is a certain probability that the variable is the previous waypoints.

HGGshiwo avatar May 22 '25 15:05 HGGshiwo

Synchronisation in your code is a bit out of scope. Just a suggestion to use cond vars / events to wait for waypoint subscriber callback to process the message. Once you start pull - you should get the current state.

vooon avatar May 22 '25 19:05 vooon