Loop rate for modules


I am creating a module which runs a loop that should call a function at a specific rate (e.g. 1000 Hz). How can I accomplish this? The examples I’ve looked at don’t run at a specific rate, but rather uses delta-t in the computations. I don’t have this option, and would like a fixed-rate loop.

Does anyone have examples of this?

You could run the module as soon as a topic gets updated, but before limit the update rate of the topic using “orb_set_interval”

Thanks Carl - however, this controller should run regardless of whether a message is published on a topic.

After I asked the question on gitter, this answer came up: https://gitter.im/PX4/Firmware?at=5814b2c05a1cfa016e5d2526

The hrt_call_every-function seems to do the job.

1 Like