Receive "Altitude" with pymavlink from autopilot

Hello
I want to get the final altitude calculated by the autopilot via pymavlink.
By final altitude, I mean the summation of all altitudes calculated from all sensors, such as GPS, altitude sensors such as LiDAR Lite V3, and barometers in meters.
I was found “VFR_HUD” and “AHRS2” altitude but both of them in ASL and I don’t know which one is the control output that mentioned in this link.

Here is my code :

from pymavlink import mavutil
import argparse
import time
import serial

myport = 'COM6'
# myport = '/dev/ttyTHS0'
mybaudrate = 115200

# Start a connection listening on a UDP port
# the_connection = mavutil.mavlink_connection('udpin:localhost:14550')

# Start a connection listening on a USB port
the_connection = mavutil.mavlink_connection(myport,mybaudrate)

# Wait for the first heartbeat 
#   This sets the system and component ID of remote system for the link
the_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component))

# Once connected, use 'the_connection' to get and send messages
# the_connection.mav.request_data_stream_send(the_connection.target_system, the_connection.target_component, mavutil.mavlink.MAV_DATA_STREAM_ALL,
#     10,  # Hz
#     1,   # enable
#     )
the_connection.mav.request_data_stream_send(the_connection.target_system, the_connection.target_component, mavutil.mavlink.MAV_DATA_STREAM_POSITION,
    10,  # Hz
    1,   # enable
    )

while 1:
#    msg = the_connection.recv_match(blocking=True)
    print('before')
    #msg = the_connection.recv_match(type='ATTITUDE', blocking=True)
    #msg = the_connection.recv_match(blocking=True)
    #print(msg)
    
    msg = the_connection.recv_match(type='AHRS2', blocking=True)
    # print(msg)
    altitude = msg.altitude
    print(altitude)
    
    msg = the_connection.recv_match(type='VFR_HUD', blocking=True)
    altitude = msg.alt
    print(altitude)

    msg = the_connection.recv_match(type='TERRAIN_REPORT', blocking=True)
    altitude = msg.current_height
    print(altitude)

    # msg = the_connection.recv_match(type='CTUN', blocking=True)
    # altitude = msg.Alt
    # print(altitude)
    
    
    print('after')

@amilcarlucas @stephendade

Those are for .bin log files, for mavlink you need to request the message with SET_REQUEST_INTERVAL

First of all thank you for fast reply. The above code isn’t enough for request data?
For my purpose I should use SET_REQUEST_INTERVAL?
And with SET_REQUEST_INTERVAL, which packet contains mentioned altitude?