High Precision Terrain following

I am interested in developing high precision low altitude terrain following system for Pixhawk. With the research I have done, My idea is to use two lidar sensors to calculate the height. One is to calculate directly downward altitude and another one to calculate the distance to the ground at about an angle of 30degrees. Is there any past attempts related to this. Thanks

1 Like

Yes, there are. Unfortunately I cannot disclose so much right now and I cannot give any source code, but for some info you can PM me.

1 Like

You can always use mavros to integrate 2 distance sensors at any given angle like any other sensor with a companion computer, then you can command using mavros in offboard mode for your need

Issue with this approach is we cant have other modes like mission or position hold since the copter should be in off board control mode. Anyway thanks for the suggestion.

you can use the mission mode like in avoidance stack. but not position hold , if you want true integration what you can do is to call at the commander.cpp, tread carefully

1 Like

@Aruna Switching between offboard mode and mission mode autonomously may not be safe.

The trajectory interface provided by mavros lets you deal with the problems you have. You can have a ros node that is transparent until interference is needed.

1 Like

@Aruna i agree on this too, use a ros node for switching

1 Like

I will look into the suggestions thanks @Yuthika_Sagarage, @Jaeyoung-Lim. I am looking for a generalized implementation strategy, appreciate your help Thank you

In a crude way you just need to change EKF2_HGT_MODE to 3 (see description)
However, the local NED origin will move up and down with ground level which may be disagreeable.

A better way would be to modify the position controller to use dist_bottom in its computing

1 Like

Hi, i am also interested in such kind of info.How can i contact you?

Aruna, any news on topic? Have u found some solution?

@Ed_shiran Since I need a generalized implementation, I’m going to implement this at the EKF level. Currently I’m studying about the implementation of the position estimator in PX4. Lets see how it proceeds.

You can write me via PM.

The general idea of my implementation is:
-Use multiple lidar/sonar and merge the info to get an estimation of the altitude. I did this on external hardware with custom algorithm.
-Send the computed altitude via mavlink to the autopilot (serial or UDP mavlink) as distance_sensor message.
-Modify the mavlink instance on the Firmware because it has bugs on handling incoming distance_sensor data.
-Modify the Firmware to use the altitude as absolute (see my PR which wasn’t accepted: https://github.com/PX4/Firmware/pull/11130).
-Modify the EKF to use more aggressively that info for the terrain altitude estimation (good luck).

You can also simulate everything on SITL with Gazebo. It works well.

Has this solution been tested yet ? Do you know in which file to modify the code so that the regulation in “altitude mode” is done with the ground-vehicle distance and not the current altitude? Thank you :slight_smile: