Hi,
I am new to lua scripting and using pixhawk 6x and trying to write a custom mixer. I am using an example script. I have put example lua script inside an update function. But it is not running, and I get pre-arm failure “PreArm: Motors: Check frame class and type”. The script is as follows:
function update()
MotorsMatrix:add_motor_raw(0, -1, 0, 1, 2)
MotorsMatrix:add_motor_raw(1, 1, 0, 1, 4)
MotorsMatrix:add_motor_raw(2, 0, 1, -1, 1)
MotorsMatrix:add_motor_raw(3, 0, -1, -1, 3)
assert(MotorsMatrix:init(4), "Failed to init MotorsMatrix")
motors:set_frame_string("scripting plus example")
end
return update, 1000
I have enabled the SCR_ENABLE parameter and have set the FRAME_CLASS to Scripting matrix. But I am not getting any pwm data out from the servo pins. If I use Quad FRAME_CLASS I am getting the pwm pulses in dso. Is there a way to check if script is loaded and running?
Thanks for the reply, Lupus! But I took this example script from ardupilot examples located under AP_Scripting library. Please let me know if you have any better solution for this.
Thanks, I could make it run by removing the fast task in copter for custom controller. I do not know why it is not running with the custom controller code. Do you know any reasons for this? Is the controller code taking much more time and memory that scripts are not running?