Hey !
I am discovering the python scripts using for now the mission planner “script” pannel but then the “servo10_function”.
I am on ardusub sitl but i think the orders are sent the same way for every vehicle type so I am open to suggestions on other types of vehicle.
I have the orders of my radiocommand incomming by PPM. Then the “forward”, “throttle”, “yaw” and “lateral” commands are read by the autopilot and sent on motors 1-5 through servo1-5 functions.
Also if this would be easier in lua I am open to any suggestions
Now I’d like to get the PWM commands before they are sent to the motors, modify them a bit and send them.
For now I am able to read the different commands using this script :
print (‘Start Script’)
Set all RC channels to mid-point (1500)
for chan in range(1, 9):
Script.SendRC(chan, 1500, True)
print(‘wrote neutral RC’)
Arm motors
cs.messages.Clear()
armed = MAV.doARM(True)
if armed :
print (‘Motors Armed!’)
else :
print('unable to arm ')
exit()
cmd=[1500]*5
output = [1500]*5
Loop to read and modify PWM commands going into motors
while True:
# Read PWM commands going into motors 1-5
cmd[0] = cs.ch1in
cmd[1] = cs.ch2in
cmd[2] = cs.ch3in
cmd[3] = cs.ch4in
cmd[4] = cs.ch5in
print('PWM read : ' +str(cmd))
# Modify the PWM commands as desired (here, set all to mid-point)
output = [1500] * 5
# Send modified PWM commands to motors 1-5
for j in range (5):
Script.SendRC(j + 1, output[j], True)
Script.Sleep(100) # wait a bit before checking again
However this seems to not work. I am thinking of using the cs.chxout but didn’t work till now eather.
Did anyone already do something like this ?
Thanks