-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Lua Scripts: Implement Aircraft Sanity Checks and LED Control in Lua #102
Conversation
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua
Outdated
Show resolved
Hide resolved
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua
Outdated
Show resolved
Hide resolved
|
||
local LED_servo = SRV_Channels:find_channel(MOTOR_LED_FUNCTION) | ||
|
||
local auth_id = arming:get_aux_auth_id() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to do something if this returns nil
. Should repeatedly fire off GCS high severity warnings. If we don't get an auth id, then we can't cause prearm failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to do an assert, because that will just kill the script with a single warning message and it would be easy to miss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind! AP_Arming fails the prearm checks if anything tries and fails to get an aux_auth (obviously; I don't know why I assumed they wouldn't).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am already doing that check in function pre_arm_check()
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua
Outdated
Show resolved
Hide resolved
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua
Outdated
Show resolved
Hide resolved
end | ||
|
||
function check_aircraft() | ||
if params.EFI_TYPE:get() == 0 and params.CAN_D1_UC_ESC_BM:get() == 19 and params.CAN_D2_UC_ESC_BM:get() == 12 then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to make a similar comment. The check Pradeep proposes isn't quite right, but basically, if no EFI type, then we are Volanti.
We have CAN bus routing plans in the near future. Let's decouple any ESC bitmask params from this check.
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua
Outdated
Show resolved
Hide resolved
for i = 1, #escs do | ||
local current_ts = tostring(esc_telem:get_last_telem_data_ms(escs[i])) | ||
current_ts = tonumber(current_ts) | ||
if (i < 5 or aircraft_type == VOLANTI) and (current_ts == 0 or current_ts == esc_prev_ts[i]) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how this is working now. Essentially, our script's loop rate determines our timeout threshold. We should do an actual time difference.
SW-61
5b0e581
to
9449085
Compare
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_built_in_test.lua
Show resolved
Hide resolved
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_built_in_test.lua
Show resolved
Hide resolved
|
||
|
||
local function update() | ||
local arming = require("arming") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with this. require
is a library loading thing, right? I thought we could do this without explicitly loading anything.
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_built_in_test.lua
Show resolved
Hide resolved
libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_built_in_test.lua
Show resolved
Hide resolved
if not arming:is_armed() then | ||
pre_arm_check() | ||
else | ||
if pre_arm_init == false then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have this check? This means that if we somehow get armed while this is false, we stop running our in-flight checks forever, and that happens silently.
This is an early PR for getting feedback on implementation.
This has been tested on SITL and Cube IronBird testing pending.
The key features implemented in this script include:
SW-61