Page 1 of 1

[SOLVED] Edit Crazyflie firmware

Posted: Wed Jul 22, 2020 10:48 am
by SH_Lee
We are making a new drone using Bolt.

We use the code of the existing crazyflie firmware for most sensor inputs, but we try to use the code we want for filter codes and coefficients.
We want to replace our code with the existing code, but we don't know exactly where to fix it.
Creating a new task has already been successful, but I don't know which part to correct to replace the existing code.
I wonder exactly what code the sensor's data value is entered into the queue.

Q : Based on FLOW Deck, I would like to add a code to use a filter other than just a Kalman filter.
If I want to use the existing ROTS priority but use the filter differently, which part should I correct?


If you know what you need to add and what you need to remove to insert the new code, please answer.
Even if it's not accurate, it'll be very helpful

Now I think I should refer to and modify the static pool 'appendMeasure()' function of <estimator_kalman.c>
If I'm right, can you teach me a simple example code?

Re: Edit Crazyflie firmware

Posted: Thu Jul 23, 2020 8:08 am
by kimberly
I am moving this post to the right group, namely the crazyflie support group.

Re: Edit Crazyflie firmware

Posted: Thu Jul 23, 2020 8:17 am
by kimberly
So first of all, let me ask you a question: what is your purpose or goal for this:

Would you like to use the filtered values as an actual state estimate and fly based on these (completely replace the kalman filter)? Or do you just want to log these variables (no flying with them)? Or would you like to prefilter the flowdeck measurements before sending it to the kalman filter?

In any sense, this part of the code is the measurement model were the measurements are being fed into the kalman filter. Check out this part of the doc to understand how this is done.

Re: Edit Crazyflie firmware

Posted: Sat Jul 25, 2020 9:56 am
by SH_Lee
My apologies for the late reply.
First, I will use an optimized filter for my drone. I want to use the existing rtos in the process.
We want to use the sensor input for each deck as it is, but we want to create a new filter that we want, not just a Kalman filter.

In other words, we want to create a new file that can replace the existing Kalman filter, and we want to remove the settings that go into the existing Kalman filter file and modify and produce the code that can be linked to the new file.

All of this is for self-creating codes (filters, pids, etc.) other than rtos.
Currently, we are adding a new filter to the existing code, but we would like to create a file with a new name.(By creating a new code in a completely new file.)

For each deck, I asked you to know how to modify the code that goes into the filtering file so that it can enter the filtering file we created.
We don't want to ruin the existing rtos priority because we think the existing firmware is very stable.
I'm looking at the code in the section I mentioned earlier, but it's not easy to create and replace files with new names because there are too many files internally. Please let me know any process if there is any additional help. Even a little advice would be a great development for us.

Re: Edit Crazyflie firmware

Posted: Mon Jul 27, 2020 9:38 am
by kimberly
I can try to point you to the right files in the firmware if you want to include a completely nw
  • Stabilizer.c: Here is where the estimator is called, by asking for the estimator type here or in the loop here
  • estimator.c: Here is where the individual functions for the estimators are called, which you can see are separate between the kalman filter and the complementary filter, see here. You would need to make a new structure in here for your estimator
  • estimator_ESTIMATORNAME.c: Per estimator there is one file that contains the functions to initialize, to start, and to read out the measurements. There is one for the complementary filter and the kalmanfilter, which are the ones that are written into estimator.c into the structure. You would need to write a init function, test, and update function, and indicate which functions will handle the input of the measurements. Note that the kalmanfilter also uses kalman_core.c to include many parts of the code (but its split up to make it more manageble.
Remember that if you make a new file, you will need to include it too in the Makefile.

I'm afraid that this is probably as far as I can go with explaining how to add a new filter. You would need to study the code of how this is done before exactly but I hope this has put you into the right direction.

Re: Edit Crazyflie firmware

Posted: Wed Jul 29, 2020 4:52 am
by SH_Lee
It's very informative!

Based on your advice, we started writing code.
Thanks to your advice, I think we'll get good results.

Re: Edit Crazyflie firmware

Posted: Wed Jul 29, 2020 6:55 am
by kimberly
Good luck! Start a new forum thread is you come across a specific problem :)