Offboard mode with optical flow

Hi, I am planning to do indoor 3D path planning project with pixhawk with jetson kit and optical flow for position control. My optical flow is [MicoAir] MTF-01.

My question is how optical flow and pixhawk calculate altitude. As far as I know, tof sensor calculates distance between underneath object and drone. So, I think drone goes up when the drone fly over object. For example, if I command pose.pose.position.z = 1, the drone can’t maintain 1m above ground if there is any object under the drone while flying.

Am I right? or does pixhawk can calculate absolute distance from the initial point?
I am considering using VIO instead of optical flow.


Flow is just velocity (delta position estimates) of the sensor. You need something to get it to scale, so some sort of distance measurement. Usually, that’s a laser range finder, sometimes sonar depending on the surfaces you fly on.

Thank you @JulianOes !
I also use down facing lidar as a range finder.
What happens if the drone fly above a hill? Does the drone go up because the slope reduces the distance between the drone and the hill?

Have a read through this: Terrain Following/Holding | PX4 User Guide (v1.14)

Thank you for the response! I will check the post:)