Reading from LIDAR Connected to serial using Pymavlink or other ways

I have a Benewake lidar TF03 which is connected to my Telem 2 Orange Cube Here 3,

I read here Benewake TF02 / TF03 lidar/ TF-Luna — Copter documentation it explains how to connect and view the results using Mission Planner.

But question is I am using Mavproxy, MAVSDK and Pymavlink. Just wonder anyway to read the results of the lidar scan using script?

I like to program it to autonomously loiter whenever there is obstacle in front.

You may need to read the mavlink messages through pymavlink
https://mavlink.io/en/messages/common.html#DISTANCE_SENSOR
https://mavlink.io/en/messages/common.html#OBSTACLE_DISTANCE

Hello,

Are you aware that there is alibrary that does avoidance ?
https://ardupilot.org/dev/docs/code-overview-object-avoidance.html