Initiating RTL with custom battery failsafe conditions


We have designed a custom battery management system for our UAV. As of now, the battery voltage and SOC are the only parameters which can initiate RTL and E-Land, which are achieved by changing the BATT_FS_LOW and BATT_FS_CRT parameters on Ardupilot.

Our BMS transmits all the battery data to the FMU via droneCAN integrating the libcanard library, using the batteryInfo.h and BatteryInfoAux.h DSDL files.

I would like to perform RTL or E-Land for emergency situations such as high cell temperature, overcurrent, etc. I have tried implementing a lua script to do this, butI’ve been struggling with it for a while. I have a few major doubts:

  1. How to read the battery data from the BMS via lua scripting? the I2C lines are not connected to the FMU and the only lua script i could find readsd standard CAN messages.

  2. I’ve also noticed in earlier iterations of the kua script, the battery node is no longer detectable if the script is running

Any help would be greatly appreciated!