Using Multi-ranger deck for altitude control

Firmware/software/electronics/mechanics
Post Reply
chopin
Beginner
Posts: 4
Joined: Thu Sep 26, 2019 5:39 am

Using Multi-ranger deck for altitude control

Post by chopin » Thu Sep 26, 2019 6:02 am

Hey,
As a part of an experiment, I needed to swap the Multi-ranger and Flow (v2) decks. That means, the Flow deck is on top of the quad, and the Multi-ranger now points to the ground.
The hardware flip worked, and I am left with flipping one thing in the firmware: I need the altitude estimator to use the sensor of the Multi-ranger because as mentioned, now the Multi-ranger points to the floor.
However, after starting to delve in the code, starting from this file, I see that there is a `state` parameter. I tried to find where the distance from the ground is inserted into `state`, but couldn't find it. If I'll know where it is, I will be able to make it take the data from the Multi-ranger instead of the Flow deck (because normally, the Flow deck points to the ground).
Any other methods of achieving this goal will be welcome.

Thanks a lot!



arnaud
Bitcraze
Posts: 2070
Joined: Tue Feb 06, 2007 12:36 pm

Re: Using Multi-ranger deck for altitude control

Post by arnaud » Thu Sep 26, 2019 8:29 am

You need to push the range in the kalman filter as TOF measurement. So you need to disable pushing the range in the zranger driver: https://github.com/bitcraze/crazyflie-f ... #L139-L150 and copy similar code in the multiranger driver: https://github.com/bitcraze/crazyflie-f ... ger.c#L111.

All ranges are pushed in a central module, range.c, and ideally that should be the place where measurement are pushed to the Kalman filter, this way you would not have to copy-paste the Kalman push code. I am not so sure how that would look like exactly but I am creating a ticket to track the idea. In the mean time, copy-pasting the code like I described should work for you to achieve height control with reverse sensors.

chopin
Beginner
Posts: 4
Joined: Thu Sep 26, 2019 5:39 am

Re: Using Multi-ranger deck for altitude control

Post by chopin » Fri Sep 27, 2019 9:36 am

Hi, thanks for your reply! Sorry for my late response.
So I managed to do the copy-paste you suggested. I couldn't test my code on a real Crazyflie, but it seems the code has compiled without errors. I will be able to test the code on a physical Crazyflie only on Wednesday, I will update here.
Thanks again!

chopin
Beginner
Posts: 4
Joined: Thu Sep 26, 2019 5:39 am

Re: Using Multi-ranger deck for altitude control

Post by chopin » Mon Oct 07, 2019 5:43 am

Hi, sorry for my late reply.
So the copy-paste you suggested worked, and the height estimator does use the Multi-ranger deck now and not the Flow deck.
However, we encountered another problem: the quadcopter is commanded to take off and land. It takes off kinda smoothly, but then it starts to drift in one direction (negative X-axis). We think that might be related to the fact that now, for velocity calculations, the Flow deck uses the height measurement from the Multi-ranger (because that's where the height estimator takes its data from). The problem is that the numbers diverge and become very large, very quickly (probably).
So, how can we make the Flow deck use its Z-ranger, and not the Multi-ranger's Z-ranger, for X- and Y-axes velocities calculations?
Thanks!

chopin
Beginner
Posts: 4
Joined: Thu Sep 26, 2019 5:39 am

Re: Using Multi-ranger deck for altitude control

Post by chopin » Mon Oct 07, 2019 7:58 am

and the height estimator does use the Multi-ranger deck now and not the Flow deck.
Actually, after a second look, we see that the Flow does influence the height estimator. If we graph `stateEstimate.z`, it changes with influences from the Flow deck's Z-ranger:
Here is the graph of `StateEstimate.z` when the quad is stable on the table, Flow deck is completely covered: https://imgur.com/a/x2aG85i
Quad stable on the table (Multi-ranger looking down), Flow deck is completely uncovered: https://imgur.com/a/XVe6x0J
Quad stable on the table, an object passes above the Flow deck a few times: https://imgur.com/a/ZEEMQzV
The spike you see in the graph happens when the Flow deck was briefly covered.
While the spikes aren't large, they do seem weird because I did comment-out lines 136-147 in `zranger2.c` as you have suggested.
So how can we fix this problem (and the one above)?
Thanks a lot!

Post Reply