rolandash Hi, I think I know the reason. I can switch to position mode successfully and arm it (after this I use offboard mode), which means the sensor is able to lock position. I checked the local_position.pose.pose, which feedbacks the orientation and local positon. Sometimes The local position in Z direction is drifting and inaccurate. It can give me 1m high even it is on the ground. Since my goal position is at 0.7m, it is reasonable that the quad will not take off. But the distance sensor is giving me good estimation for Z position. I guess that the EKF2 failed to use the distance sensor sometimes.
And a new question, do you know how could I change the frequency of distance sensor? The default frequency in the MavLink Inspector is 10Hz. I tried to directly use the distance sensor feedback to implement my own feedback loop to control the position. But the feedback is too slow.