ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Move AP_Baro parameters and call-handling to AP_Vehicle

Open peterbarker opened this issue 1 year ago • 2 comments

Tested the param upgrade code for all the normal 6 vehicles using something like this:

./Tools/autotest/test_param_upgrade.py --vehicle=arducopter --param "BARO_GND_TEMP=13" --param "BARO1_WCF_ENABLE=17" --param "BARO2_WCF_BCK=19.34"

Also tried upgrading from 4.5 using new patches to that script.

The calibrate should really go next to the init call (actually, within it!), but if the calibration doesn't succeed and we throw a config error then the vehicle segfaults (this was shown up by the autotest ConfigErrorLoop test). So I've left it past the point where we initialise the vehicle hard enough to not segfault.

More detail on that segfault:

  • error-loop allows the user to use mavlink to fix their parameter problems, so it calls update_send (and update_receive)
  • we've initialised the streams from parameters and files and whatnot, so we're trying to send normal message streams
  • we try to send nav controller output, but that eventually calls methods on the "wpnav" object (via mode_auto)
  • we have not yet actually allocated the wpnav object as that's done in init_ardupilot in Copter
  • recreation on top of this PR is trivial; move the calibrate call to be just underneath the init call. Possible solutions
  • don't initialise message streams until later
  • protect against nullptr in the calls (note there are a lot of things allocated in Copter's init_ardupilot, 'though!)
  • de-initialise message streams in the error loop
  • create some form of early-init setup function (I don't think this is going to work!)
  • move baro calibration into a separate thread or be part of normal update (fixes only this specific case)

peterbarker avatar Apr 22 '24 07:04 peterbarker

Board               AP_Periph  blimp  bootloader  copter  heli  iofirmware  plane  rover  sub
Durandal                       216    *           208     208               232    240    232
Hitec-Airspeed      *
KakuteH7-bdshot                192    *           176     176               200    200    192
MatekF405                      96     *           88      80                104    120    96
Pixhawk1-1M-bdshot             80                 72      72                104    112    88
f103-QiotekPeriph   *
f303-Universal      *
iomcu                                                           *
revo-mini                      88     *           80      80                96     112    88
skyviper-v2450                                    112

peterbarker avatar Apr 22 '24 08:04 peterbarker

@peterbarker I think there is a less intrusive approach which we can discuss

tridge avatar Apr 23 '24 00:04 tridge