Obstacle Avoidance using HCSR04

How do we integrate obstacle avoidance using HCSR04 sensor into quadcopter pixhawk drone through raspberry pi

we will be using Mamdani Fuzzy Logic Controller for obstacle avoidance

Hope RPi has good enough timing resolution and write and implement MAVLink rangefinder.

You can also connect it directly to the ardupilot which you could have known with one simple google search.