Filtering rangefinder data using a ROS2 node

Hi everyone,

I am currently testing a drone with a rangefinder installed on board (Teraranger 60m EVO). I want to filter out data that is out of range (> 60m). I could do this by modifying the PX4 autopilot firmware (as I believe is done in this case), but I would prefer to do it by filtering the data in software.

I know that I can get the incoming data from the rangefinder at the topic fmu/distance_sensor/out. I can then filter this data and send it back to the autopilot with the ROS2 topic fmu/distance_sensor/in. Would this be possible?

My other question is, will this create a duplicate reading of the distance sensor at the autopilot?

Thank you in advance for your help.

Hi @riccardo-enr

That’s correct. All modules subscribing to the distance_sensor topic will eventually receive the unfiltered and the filtered version of the messages.
A possible solution could be to change the name of the unfiltered topic, something like distance_sensor_unfiltered, send it over ROS and have your ROS node sending back distance_sensor.