Best way to listen to a topic

Hi guys

I am making some new applications to control my px4 vehicle, and I am wondering what is the best way to listen to a topic. I can either orb_copy the topic every loop, or use the px4_poll then if(fds[0].revents & POLLIN) to copy once new data is available, but I am not sure which one is suitable for which.

The current application I am working on is to receive a custom mavlink message and perform a special manoeuvre, the two key topics are “vehicle_command” and “vehicle_attitude”. I use the px4_poll method on the command topic since I think it doesn’t matter if it is slow, and I force the orb_copy call on the attitude topic every loop once the manoeuvre is initiated since I think it has to be fast.

Is this the correct thinking, or am I missing the point of px4_poll?

Here is an example of what I mean, I use px4_poll while I haven’t sent the command:

Once the command is received and handled, I switch to copy the command and attitude topic every loop:

1 Like