In althold mode, the weight ratio of rangefinder data and imu data

I use the ultrasonic module to set the height, if the terrain below changes, what is the change degree of the UAV, and what is the weight ratio of the ultrasonic data and imu data in the flight control code (does the UAV automatically increase the weight of the imu data when the terrain changes greatly?)

Not exactly… in this specific scenario, the rangefinder data goes into a glitch protection logic that avoid the UAV making aggressive corrections in altitude, so these values with a bigger difference relative to the latest measure are not placed into the height controller.