Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

loki077
Copy link
Contributor

@loki077 loki077 commented Feb 4, 2024

This is an early PR for getting feedback on implementation.
This has been tested on SITL and Cube IronBird testing pending.

  • Renamed CX_LED_driver.lua file to cx_sanity_script to cover the scope of the script future functionality.

The key features implemented in this script include:

  • Base Firmware Version: Compare of Firmware version to CxPilot base version to check LUA dependencies are present.
  • Pre-Arm Checks: Before the vehicle is armed, the script performs a series of checks including auth access, parameter initialization and aircraft type check(Volanti or Ottano).
  • ESC/EFI Status Check and Fault Detection: Checks the delta between ESC/EFI telemetry of each ESC/EFI and reports if any one is not responding during PreArm and flight.
  • Aircraft Type Detection: The script checks certain parameters to determine the type of aircraft (Volanti or Ottano) and reports if the aircraft type is unknown.
  • During-Arm Checks: Once the vehicle is armed, the script continues to monitor the ESC and EFI telemetry and reports any failures.
  • VTOL Failure Check: The script checks for lost motor thrust and reports any failure.
  • NAV Wing End LED Operation Control: The script checks the arming status of the vehicle and sets the LED accordingly.

SW-61


local LED_servo = SRV_Channels:find_channel(MOTOR_LED_FUNCTION)

local auth_id = arming:get_aux_auth_id()
Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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).

Copy link
Contributor Author

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()

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
Copy link
Collaborator

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.

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
Copy link
Collaborator

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.

@loki077 loki077 force-pushed the feature/SW-61-esc-engine-safety-check branch from 5b0e581 to 9449085 Compare February 6, 2024 02:20


local function update()
local arming = require("arming")
Copy link
Collaborator

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.

if not arming:is_armed() then
pre_arm_check()
else
if pre_arm_init == false then
Copy link
Collaborator

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.

@ghost ghost closed this May 9, 2024
@robertlong13 robertlong13 deleted the feature/SW-61-esc-engine-safety-check branch June 17, 2024 07:06
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants