Signaling APM ports from Raspberry Pi to avoid objects

Hi all,

I have a Raspberry pi that measures the distance between my vehicle and an object.
depending on the distance, i want to avoid that object. I am using an old APM. In which port should i signal? and are there any parameters that i need to set it up for that? can i mock the behavior of a remote control signal with my raspberry pi to avoid the object without changing the flight mode from auto to manual or guided?

APM controllers run very out of date software and are no longer supported, but should still work with guided mode if you want to send it commands from a companion computer.