[SOLVED] Edit Crazyflie firmware

Post here to get support
Post Reply
SH_Lee
Beginner
Posts: 4
Joined: Tue Feb 18, 2020 8:48 am

[SOLVED] Edit Crazyflie firmware

Post 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?
Attachments
KakaoTalk_20200722_154055294_01.jpg
KakaoTalk_20200722_154055294.jpg

kimberly
Bitcraze
Posts: 465
Joined: Fri Jul 06, 2018 11:13 am

Re: Edit Crazyflie firmware

Post by kimberly »

I am moving this post to the right group, namely the crazyflie support group.

kimberly
Bitcraze
Posts: 465
Joined: Fri Jul 06, 2018 11:13 am

Re: Edit Crazyflie firmware

Post 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.

SH_Lee
Beginner
Posts: 4
Joined: Tue Feb 18, 2020 8:48 am

Re: Edit Crazyflie firmware

Post 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.

kimberly
Bitcraze
Posts: 465
Joined: Fri Jul 06, 2018 11:13 am

Re: Edit Crazyflie firmware

Post 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.

SH_Lee
Beginner
Posts: 4
Joined: Tue Feb 18, 2020 8:48 am

Re: Edit Crazyflie firmware

Post 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.

kimberly
Bitcraze
Posts: 465
Joined: Fri Jul 06, 2018 11:13 am

Re: Edit Crazyflie firmware

Post by kimberly »

Good luck! Start a new forum thread is you come across a specific problem :)

Post Reply