Lua Scripts to read and set pwm output orders?

Hello !

Here’s my problem, I have a sub vehicle running on ardusub latest. The frame is simplerov4 but I have two more servos (on servo 5 and 6) that acts like ailerons in a plane so when we move we wan’t to use them instead of motors 3 and 4.

The Idea would be to send the throttle order on different motors depending on the forward order.

In pseudo code it would look like :
if forward > 1700 :
servo3 pwm = servo4 pwm = throttle
servo5pwm = servo6pwm = 1500
else
servo3pwm = servo4pwm = 1500
servo5pwm = servo6pwm = throttle

I want to do this as soon as the vehicle boots. That’s why I think the only option is a lua script.

I did something that works in manual mode using python scripts because I just had to read the rc that corresponded to forward and change the servox_function accordingly. However since I want to do this automaticaly and in other modes than manual I think that the only options I have is to use lua and this is where the issue comes. As a begginer I am not able to acces the forward, throttle and yaw order in lua ! I am able to read the rc input so I am able to do the manual mode but not the others. I’ve been looking for help in the ardupilot doc and forums but till now I don’t have solutions.

I’ve got an other question. On stil I feel like the only frame available is the bluerov2/vectored. I’ve tried many frames by adding -f but didn’t find the simple rov 4. Is there a way to simulate it ?

Finally I have a question about the “throttle” and “ground steering” orders that seem like they are not activated :
image
. Is this specific in the bluerov 2 or am I doing something wrong again ?

Does anyone have a solution for reading these orders and change a parameter in lua or by an other way it would be so cool !