Crazyflie frequency(run time, frequency)

Post Reply
Posts: 4
Joined: Tue Feb 18, 2020 8:48 am

Crazyflie frequency(run time, frequency)

Post by SH_Lee » Mon Jul 20, 2020 12:07 pm

I am curious about the cycle of Crazyflie.

I am currently studying RTOS inside the firmware, and I would like to know the execution cycle and time of each thread when I connect flow_deck, multi-ranger, and loco-position deck.

/* The stabilizer loop runs at 1kHz (stock) or 500Hz (kalman). It is the
* responsibility of the different functions to run slower by skipping call
* (ie. returning without modifying the output structure).

I found the above contents in the stabilizer.c file.
If I use the three decks I mentioned, can I know the runtime of the stabilizer and the execution time of the other decks?

Posts: 456
Joined: Fri Jul 06, 2018 11:13 am

Re: Crazyflie frequency(run time, frequency)

Post by kimberly » Tue Jul 21, 2020 12:28 pm


You can manually put in a timer if you want. There is this headerfile called usec_time.h in the firmware repo. You start it with

Code: Select all

at the very beginning of the driver (at startup of your crazyflie), than in the loop of your deck driver or where you want you can save the timestamps:

Code: Select all

uint64_t start_time,end_time;

	start_time = usecTimestamp();
	 ***code you want to test out**
	end_time = usecTimestamp();

	DEBUG_PRINT('code took %d usec to run, pend_time-start_time);
Or something like that (do double check is this runs though)

If you would like to know the complete run time (if it goes through all the other modules), you can calculate the start_time at the end of the while loop and the end_time at the beginning and than measure it, or you measure in the while loop of stabilizer.c

Post Reply