What is the purpose of distancesensor.h in file in moduel/uORB/topics?

I have been working to learn the coding of Pixhawk controller by changing so modules of PX4 firmware. Right now i have done the initial tutorial of Hello Sky to assigning values to attitude (q.att[0]).
From this gained the idea that in order to code the Pixhawk i need to change the module info and in order to get that info, i need to go to modules folder in firmware where a lot of different purpose modules are present from which we subscribe data and order/publish data in another module to follow.
now i want to measure the height of the pixhawk 4 from the ground via using the values of sensor data like MPU/IMU. I dont know which module is used to calculate that data. like height from the ground and in second part also want to work on distance from the target. I dont know whether inorder to find distance do we really need an external sensor to get data.( external sensor like sonar sensor)

1 Like

Hello. First of all, in PX4 DevGuide, you may find some relevant info, such as the uORB graph, showing all topics and which modules consumes and write down all data.

Regarding your first question, “distance_sensor” topic is used to transmit distance to the ground measured from any external distance sensor, such as lidar, ultrasound and radar. So check out any of these drivers.

Thanks, Alex it is a great help to understand a few new topics. Alex, I want to know do you know a way how to access/control the PWM output pins of Pixhawk via uploading code and access it through mavlink. Just like SimpleAPP example.
I want to manually control the motors and start it run it test for my on specific purpose. But it difficult for me to understand which module code to access to publish or subscribe data. Please put a light on this too. Thanks again for helping.

Sorry for the delay. If you still are looking for it, the answer is to create a module that gets MAVLink data (however, I cannot remember how to do it, exactly) and publish it into the actuators control topic (or output, depending if you want it to be done before or after the mixing process).

Further, you may want to disable all controllers so they will not overwrite your data.