Switching altitude measurement from downward ranger to upward

Firmware/software/electronics/mechanics
Post Reply
ricardo.halfeld
Beginner
Posts: 24
Joined: Tue May 22, 2018 1:40 pm

Switching altitude measurement from downward ranger to upward

Post 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?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Switching altitude measurement from downward ranger to upward

Post 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.
ricardo.halfeld
Beginner
Posts: 24
Joined: Tue May 22, 2018 1:40 pm

Re: Switching altitude measurement from downward ranger to upward

Post 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!
coreysnipes
Beginner
Posts: 16
Joined: Mon Jan 21, 2019 3:09 am
Location: Cleveland, OH, USA
Contact:

Re: Switching altitude measurement from downward ranger to upward

Post by coreysnipes »

Very clever!
ricardo.halfeld
Beginner
Posts: 24
Joined: Tue May 22, 2018 1:40 pm

Re: Switching altitude measurement from downward ranger to upward

Post 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
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Switching altitude measurement from downward ranger to upward

Post 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).
ricardo.halfeld
Beginner
Posts: 24
Joined: Tue May 22, 2018 1:40 pm

Re: Switching altitude measurement from downward ranger to upward

Post 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?
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Switching altitude measurement from downward ranger to upward

Post 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?
Post Reply