Page 1 of 1

Switching altitude measurement from downward ranger to upward

Posted: Wed Apr 03, 2019 11:54 am
by ricardo.halfeld
Greetings,

in the continued attempt to fly the CF over non-flat grounds, I had a new idea. This occurred to me after acquiring a multiranger deck. In the vast majority of places we fly our CFs, the ceiling is much flatter and bump-free than our floors. My idea is to use the upward ranger on the multiranger deck to feed the EKF wherever the ground is non-flat or non-inertial.

My intent is to do so by changing a parameter. The firmware would be adapted to check for that parameter whenever trying to enqueue zranger or multiranger data into the Kalman filter. When toggling to upward, the first measurement would be used to define the absolute position of the ceiling, and the following measurements would be corrected with that value.

Any further thoughts?

Re: Switching altitude measurement from downward ranger to upward

Posted: Thu Apr 04, 2019 8:25 am
by arnaud
In principle I think that this should work fine. Practically though you might need two parameters: one to disable pushing the zranger to the EKF: https://github.com/bitcraze/crazyflie-f ... #L139-L147 and one to enable pushing the up-measurement into the EKF, all ranges from the multiranger end-up in range.c: https://github.com/bitcraze/crazyflie-f ... ange.c#L39.

This makes me think that pushing data to the EKF could be moved completely to range.c, and then a "up/down" parameter could be added there. The algorithm you describe for acquiring the offset to the ceiling, can be applied to get an initial ground sample as well.

Re: Switching altitude measurement from downward ranger to upward

Posted: Thu Apr 11, 2019 1:46 pm
by ricardo.halfeld
The code isn't decent. I essentially took every shortcut I could find. :p

That's why I won't post it.

But it seems to work just fine!

Re: Switching altitude measurement from downward ranger to upward

Posted: Fri Apr 12, 2019 4:02 pm
by coreysnipes
Very clever!

Re: Switching altitude measurement from downward ranger to upward

Posted: Mon Apr 15, 2019 2:00 pm
by ricardo.halfeld
arnaud wrote:
Thu Apr 04, 2019 8:25 am
This makes me think that pushing data to the EKF could be moved completely to range.c...
I'm trying my best to incorporate your suggestion into this branch, but there's so much to learn and so little time available to work on this...

FreeRTOS is very unfamiliar to me, but from what I gather I'll need to create an xTask (as in here and here) to push data into the estimator from range.c, right?
coreysnipes wrote:
Fri Apr 12, 2019 4:02 pm
Very clever!
Thanks! :D

Re: Switching altitude measurement from downward ranger to upward

Posted: Tue Apr 23, 2019 9:10 am
by arnaud
Hi,

I do not think you need a new task: the function rangeSet() in range.c is already called by a task when a new measurement is acquired. This function can in turn call the EKF estimatorEnqueueTOF() function when required (ie. when a down or up measurement is acquired depending of the current configuration).

Re: Switching altitude measurement from downward ranger to upward

Posted: Mon Jul 29, 2019 9:13 pm
by ricardo.halfeld
Recently I got back to this. One problem we still have is that flow measurements rely on distance to ground. I believe it takes absolute altitude in based on how it behaves, though it would work much better using zranger data, I believe. Haven't found where in the code the magic happens yet. Can you point it out?

Re: Switching altitude measurement from downward ranger to upward

Posted: Wed Aug 07, 2019 7:43 am
by kimberly
Hi ricardo,

Sorry for the late reply. @arnaud is on a holiday right now but he will be able to help you out once he is back next week. In the mean time, were you able to find your way in the kalman_core.c ?

I had a quick look at it and it seems that it's using the estimated height position and not the zranger direct measurement: kalmanCoreUpdateWithFlow() in Kalman_core.c (line 505)

Code: Select all

      z_g = this->S[KC_STATE_Z];
Would you agree?