The control rates

Hello, I’m trying to do a little change to the mc_pos_control_main.cpp . And now I have a question about the control rate. There is a “dt” doing time updating in the code. Is there a fixed control rate? Thank you!

It runs when there’s a new local position update from the estimator.

Is this “pret” decide the control rates?


          /* wait for up to 20ms for data */
	int pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 20);

	/* timed out - periodic check for _task_should_exit */
	if (pret == 0) {
		// Go through the loop anyway to copy manual input at 50 Hz.
	}

	/* this is undesirable but not much we can do */
	if (pret < 0) {
		warn("poll error %d, %d", pret, errno);
		continue;
	}

For I want to change the code to control the vehicle in another way, and a sample rate is needed. As what you said, there doesn’t exist a fixed rate?

The way this is structured it runs in step with position updates published by the estimator. You should calculate a dt if needed.