Need guidance on running Python script to control servo on Pixhawk Main Out 5 and 7

I want to run a Python script on my Jetson Nano to control a pan-tilt servo connected to Pixhawk’s Main Out 5 and 7. My Pixhawk 2.4.8 is running on rover firmware, and I mostly use it in manual mode. However, I am having issues changing the flight mode due to an unhealthy AHRS.
i have successfully connected Pixhawk to jetson nano via mavlink .
If you need any additional information, please let me know.