Completely confused on how to get distance sensor data

Hello,

Basically I am making a program with a drone that is supposed to detect and move to an object, then recognize said object.

First step is to detect the object. I figured I can achieve this with distance sensors. Since I also need to recognize said object eventually I figured the Typhoon_H480 model would be the most appropriate. Which is what I am currently using.

What I need to do is within my c++ code, get the distance sensor data. Approximate the position of the object from said data. And add that position to my waypoint list.

I posted a question on github: Trying to use distance sensor with Typhoon_H480 · Issue #1387 · mavlink/mavros · GitHub.

But I am still not sure where to go from here.

I am simply trying to get distance sensor data inside of my code. I know it is easily accessible outside by using “listener” on the px4 command console. Or by looking at QGroundControl. But I am trying to program autonomy.

I am going to post an image as to what I’ve already tried to do. It might seem very wrong or weird, but I’m new to px4. I’m just trying to figure out how to get this darn drone to move to the cylinder with c++ code!

Also I know going through the guide would help, and I have gone through the guide, but I’m short on time and I don’t have the luxury of going through the entire guide with the time I have been given.