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


Are you aware that there is alibrary that does avoidance ?

Hi yes but it works only in altihold mode but not in auto mode.

There are possibilities to work auto with the advanced avoidance library.
I suggest you look at work from @rishabsingh3003 on that matter.
I think it would be better if you open a thread at as it is not directly related to cubepilot.

Hi, in Copter 4.1 you can do this via Lua scripting. As far as I have understood, you want to switch from Auto -> Loiter when an obstacle is detected?
I have done a similar script in the past and I think I might be able to find it… let me know if you need it.