Configuring HC-SR04 for obstacle avoidance

New to Arducopter/Mavlink and have been trying to determine if I can configure a HC-SR04 sensor to be used for obstacle avoidance.

Using a rpi4 and cube orange. HC-SR04 is routed to the pi and pi to telem2 port on cube.

Found this:

Modified the parts of the code for my setup and attempted to execute but received the error below:


Any help is appreciated.