Running experiments on motors mid flight

I’m working on a research problem, and it involves a series of experiments on motors.

I’m trying to do these:

Kill one motor mid-flight
Set pwn outputs to motors mid flight
Kill all motors at the same time any point in flight

I tried lua scripting for these. It’s causing a lot of problems. Any suggestions on how to automate this/ do these kinds of experiments?

I’m using SITL+ Ardupilot, as well as Holybro X500+Ardupilot (Quadcopter, x frame)
RC is disabled. Controlling the drone only using a laptop, over telemetry.
Pixhawk 6C

There are FW inbuilt options to perform these kind of actions. But you do need to recompile and upload the FW to your FC.
Things like disable a GPS via a RC switch.

Kill all motors at the same time any point in flight ← this is a standard RCX_OPTION called “emergency stop”

PS: you should really get a RC, it will make your live a lot easier.

There are scripts for killing motors in flight in the scripting library. They can do 1 and 3 and modification to do 2 should be trivial.