Page 1 of 1

Ground Mapping for bumpless flights using the Flow Deck

Posted: Tue Feb 19, 2019 12:27 pm
by ricardo.halfeld
Good morning,

I've been testing this great little guy with LPS + Flow deck in our lab and I just thought I'd survey the community about the implementation of a new piece of functionality.

The annoying thing about flying the CF with the Z-ranger is picking up obstacles on the ground and having that sensory data affect the Kalman Filter's Z estimate. I have tried reducing the effect of the Z-ranger by increasing the sensor's standard deviation data in the firmware, but couldn't find satisfactory values to improve flight in such conditions without seriously affecting its ability to maintain altitude.

It just makes me wonder about implementing some sort of adaptive ground level mapping. If the Z-ranger picks up changes in elevation, it also changes the expected ground level for that horizontal position. All of that with slow dynamics, of course, so it would take a a few flights over the obstacle to ignore it correctly. Has anyone tried anything like that yet?

Have a good one!

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Tue Feb 19, 2019 2:07 pm
by tobias
A functionality like that would be very nice. Maybe it is possible to do in combination with the accelerometer. If there is a step change in the z-distance but no corresponding z-acceleration then it is a change in the ground distance.

Sometimes keeping the height to the ground is wanted though, like when flying up a stairway :D

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Tue Feb 19, 2019 7:37 pm
by ricardo.halfeld
tobias wrote: Tue Feb 19, 2019 2:07 pm Sometimes keeping the height to the ground is wanted though, like when flying up a stairway :D
True, but when you're really hauling there's no guarantee you'll clear the ground! With a map you could include some sort of anticipation in the control allowing for relative ground tracking as well.

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Thu Feb 21, 2019 9:00 am
by tobias
A map would be awesome :D

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Sat Mar 09, 2019 12:39 am
by ricardo.halfeld
Correct me if I'm wrong. It seems to me that the least painful way of introducing this feature is to setup a parameter (let's call it groundLevel) in the firmware code and add it to the distance the zranger is pushing into the Kalman filter. Its standard value can be 0.0. If you don't change that parameter, it's business as usual.

Now, using the Python library, we'd read the estimated horizontal position using the logging framework and then run it through some sort of mapping we somehow acquired, resulting in a vertical coordinate for the ground level in that location. We proceed to change our groundLevel parameter with that value. If all goes according to plan, the CF should fly level despite the irregular ground.

Sounds right to you? Got a better idea?

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Mon Mar 11, 2019 2:21 am
by ricardo.halfeld
I tried doing it. Here's what I did:
  1. Declared a static float named grLevel = 0.0 at the top of zranger.c
  2. Added grLevel to where zrange->distance is set
  3. Used the parameter macro to set it as the parameter named "level" under the group "ground" at the bottom of the file
After flashing the CF with this new firmware, I'm able to see it in the Windows client. I'm also able to change it with the Python library.

I ran a test in which the CF takes off, hovers, then this parameter is set to some small non-zero value, like 0.2m. I expected to see it drop that same amount. It did not. Any ideas about what may have gone wrong?

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Mon Mar 11, 2019 12:55 pm
by tobias
Did you also change the code where the distance is pushed to the Kalman filter? That could be why nothing is happening?

Code: Select all

    
    if (getStateEstimator() == kalmanEstimator &&
        range_last < RANGE_OUTLIER_LIMIT) {
      // Form measurement
      tofMeasurement_t tofData;
      tofData.timestamp = xTaskGetTickCount();
      tofData.distance = (float)range_last * 0.001f; // Scale from [mm] to [m]
      tofData.stdDev = expStdA * (1.0f  + expf( expCoeff * ( tofData.distance - expPointA)));
      estimatorKalmanEnqueueTOF(&tofData);
    }

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Mon Mar 11, 2019 4:42 pm
by ricardo.halfeld
Indeed I had not. There's a line that's exactly the same in zRangerReadRange and I confused the two. After changing the one you pointed out it started working.

Where is this zRangerReadRange method used? Should I keep the change in it?

Thanks for the tip!

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Thu Mar 14, 2019 12:23 pm
by tobias
I think the zRangerReadRange is used when the complimentary filter runs, in e.g. height hold mode so I think it is better to leave that as it was.

Re: Ground Mapping for bumpless flights using the Flow Deck

Posted: Thu Mar 14, 2019 12:39 pm
by ricardo.halfeld
I haven't messed with that part yet. Anyway, thanks for the help! I will start testing this implementation soon.