Is there a way to use servo output function via both RCIN and Mavlink?

[Summarized Question]
I have three servo outputs connected to my flight controller (FC) and I have set them to follow RCIN in the Mission Planner “Servo Output” tab. However, when I send the Mavlink message “MAV_CMD_DO_SET_SERVO”, the servos follow the Mavlink message at first, but then automatically return to the original RCIN position. I want the servo output to follow the Mavlink message in guided or auto mode while still maintaining the RC function in other than guided or auto mode. yaw, roll, pitch, throttle works similar(it follows transmitter value in loiter and follow mavlink messages in the auto mode) Is there a way to achieve this?

[Detailed Question]
Hello,

I am working on a unique drone delivery device that is different from existing devices. I am using Ardupilot, Mission Planner, and a my custom delivery GCS to test it. The device is controlled by three PWM channels from the FC. When in stabilize mode, altitude hold mode, or loiter mode, it operates well when controlled manually using the transmitter switch.

However, when I control the device using Mission Planner or my custom GCS, the servo command resets to the transmitter position after few seconds because the device also receives signals from the transmitter. I want the servo output to be controlled by the GCS or Mavlink message when in guided or auto mode.

Is there a way to set this up while still retaining the RC function? I am open to complex solutions. If I cannot find a solution in the forum, I plan to modify the Mavlink message to change the servo output setup after the guided mode operation is completed.

I know that I can control the servo output using mavlink mesages if I disable the “RCIN to servo output” setting, but I would like to maintain both the RC and mavlink functions. I believe this is a common issue when invent autonomous system with device and would be a useful addition for the future of Ardupilot.

[Additional Photo]
this is my servo configuration.

MAVLink RC overrides time out after a few seconds by design, so you must continuously send them prior to timing out if you want the commands to persist.

Thank you. I discovered before that repeatedly pressing the button makes the device work well.

However, the mavlink connection is not always stable and I’m worried that disconnections and the absence of mavlink messages may cause the device to behave in unintended way and lead to dangerous situation. when mavlink connections is lost, I want the device to follow the last command that was sent through the mavlink message, not the RCIN. That’s why I’m here, seeking for genius idea for setting up this.

and I believe that modifying the Ardupilot system with this function would be valuable. so I’m here to just propose a new system architecture. In the future, you may be able to modify the system if you desire.

If there are no innovative solutions, I will modify my GCS to allow for changing the servo setup with a single button, allowing for the choice between following the mavlink message or RCIN.

If your links are unreliable, you don’t need a new firmware architecture, you need to solve that problem and properly set the failsafes.

You might be better served exploring guided mode rather than manual control via MavLink.

I am curious about how to set a failsafe system in guided mode that outputs a default servo output value rather than RCIN value when the connection is lost(with the function following RC signals if in other than guided mode),
this would also require a change in the system architecture, so your saying about failsafe is not relevant to the current discussion.
mavlink failsafe is related to RTL, not the servo output choice between RCIN and mavlink messages.

I have a failsafe system in place for when the PWM value is out of range or the device connection is not stable. However, it is not easy to detect if it has switched from the mavlink to the RCIN signal.

and I said already I have developed a failsafe plan:

“If no better solutions are found, I will modify my GCS to allow for changing the servo setup with a single button, giving the option to follow either the mavlink message or RCIN. This will ensure the device remains safe even if the mavlink messages become unstable.”

so your saying about seeking failsafe advice is irrelavent to my question.

The system architecture not allowing the use of both mavlink and RCIN is a separate issue with my device. Modifying the GCS or system in this way offers a simple solution for making the autonomous device work with Ardupilot.

Another way of putting my previous reply, since I don’t think I made myself clear enough:

ArduPilot’s autonomy relies heavily on positional control, not low level RC input. I think you should explore controlling the drone via position or velocity vector inputs to guided mode rather than attempting lower level servo commands via MavLink, which, as you’re discovering, is quite problematic.

I apologize if my previous explanation was unclear and for the length of my previous question. Let me clarify my situation.

My delivery device utilizes aux PWM output port, and I have assigned servo outputs 9, 10, and 11 to it.( as depicted in the screenshot I provided.) These outputs are not related to positional control and are part of the aux channel. it is not related to UAV stabilization and PID system. Hence, your suggestion of guided mode is irrelavant in this case. aux servo output don’t have to follow positional control even it is in guided mode or auto mode.

and, you said ardupilot autonomy is heavily rely on calculation rather than raw rc input, so, solution to my question is problematic. I think there is confusion with your understanding. it is good thing that if ardupilot autonomy not follow raw rc input in autonomy, as you said. the problem is, ardupilot does not follow auto calculation servo value, and follow raw rc input in autonomous mode.

I am still seeking a solution to my issue, and would suggest improving the ArduPilot system “if you desire(as I said above.)” because other autonomous device will need that sytem. The issue I am facing is not due to not setting a failsafe system or not using the guided mode, or due to being an inexperienced user(who don’t know about failsafe or guided mode) attempting a task beyond their abilities. I feel like your previous answers may have suggested that.

I aim to control my device both manually through a transmitter and automatically through MavLink messages with mode changes. which may also be needed for other autonomous devices.
I am already familiar with the guided mode and am currently using it as you had previously suggested for autonomous missions with the ground computer.

You may try to experiment with MP Python scripts.

Your answer is really helpful, thank you.

However, I have already solved my problem using another solution.
I have created two buttons in my custom GCS to set the ‘SERVO_FUNCTION’ parameters, allowing me to switch between controlling the servo via RC and MAVLink.

I could potentially go further,
I can make my GCS automatically set the ‘SERVO_FUNCTION’ parameter when the mode switches, but I haven’t implemented that yet.

I was originally curious if I could set this function without programming, but I have since given up on that idea.
if ardupilot support that funtion without programming, it would better implement some autonomous devices