How to adjust the sample rate of distance sensor (rangefinder)

I have not tried MAVSDK, but I think this link will be helpful:Difference MAVLink and MAVROS

She said:

MAVROS is the bridge between MAVLink and ROS. If you’re using ROS for whatever robotics you’re doing, then MAVROS is great.
If all you want is to write a simple C++ program to talk to a PX4 drone, then you should consider using the Dronecode SDK