Skip to content

Commit

Permalink
tune gyro gating and minimum gyro trust parameters and add menu to se…
Browse files Browse the repository at this point in the history
…t optimum defaults for AHRS Parameters
  • Loading branch information
iltis42 committed Sep 11, 2023
1 parent 670392d commit 100cf59
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
26 changes: 7 additions & 19 deletions main/SetupMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,25 +1647,7 @@ void SetupMenu::system_menu_create_hardware_ahrs_parameter( MenuEntry *top ){
SetupMenuValFloat * gyrog = new SetupMenuValFloat( PROGMEM"Gyro Gating", "°", 0, 10, 0.1, 0, false, &gyro_gating );
gyrog->setHelp( PROGMEM"Minimum accepted gyro rate in degree per second");
top->addEntry( gyrog );
/*
SetupMenuValFloat * virtglp = new SetupMenuValFloat( PROGMEM"Virtual G Lowpass", "", 0, 1, 0.005, 0, false, &ahrs_virt_g_lowpass );
virtglp->setPrecision( 3 );
virtglp->setHelp( PROGMEM"Lowpass factor for virtual gravity from airspeed and omega or centripedal force compensation");
top->addEntry( virtglp );
SetupMenuValFloat * gflp = new SetupMenuValFloat( PROGMEM"G-Force Lowpass", "", 0, 1, 0.005, 0, false, &ahrs_gforce_lp );
gflp->setHelp( PROGMEM"Lowpass factor to filter g force for loadfactor dependent bank calculation");
gflp->setPrecision( 3 );
top->addEntry( gflp );
SetupMenuValFloat * vgtrust = new SetupMenuValFloat( PROGMEM"Virt G trust bank", "", 0, 100, 0.1, 0, false, &ahrs_virtg_bank_trust );
vgtrust->setHelp( PROGMEM"Factor for trust in virtual gravity depending on angle of bank");
top->addEntry( vgtrust );
SetupMenuValFloat * gloadbd = new SetupMenuValFloat( PROGMEM"G Load bank Dynamic", "", 1, 2, 0.01, 0, false, &ahrs_gbank_dynamic );
gloadbd->setHelp( PROGMEM"G load dynamic grow factor for angle of bank to be considered");
top->addEntry( gloadbd );
*/

SetupMenuValFloat * gyrocal = new SetupMenuValFloat( PROGMEM"Gyro Calibration", "", -0.5, 1.5, 0.01, 0, false, &ahrs_gyro_cal );
gyrocal->setHelp( PROGMEM"Gyro calibration factor to increase accuracy of gyro in %/100");
top->addEntry( gyrocal );
Expand Down Expand Up @@ -1700,6 +1682,12 @@ void SetupMenu::system_menu_create_hardware_ahrs( MenuEntry *top ){
top->addEntry( ahrspa );
ahrspa->addCreator( system_menu_create_hardware_ahrs_parameter );

SetupMenuSelect * ahrsdef = new SetupMenuSelect( "AHRS Defaults", RST_NONE, 0, true, &ahrs_defaults );
top->addEntry( ahrsdef );
ahrsdef->setHelp( PROGMEM "Set optimum default values for all AHRS Parameters as determined to the best practice");
ahrsdef->addEntry( "Start");
ahrsdef->addEntry( "Cancel");

SetupMenuSelect * rpyl = new SetupMenuSelect( PROGMEM"AHRS RPYL", RST_NONE , 0, true, &ahrs_rpyl_dataset );
top->addEntry( rpyl );
rpyl->setHelp( PROGMEM "Send LEVIL AHRS like $RPYL sentence for artifical horizon");
Expand Down
17 changes: 11 additions & 6 deletions main/SetupNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ void chg_mpu_target(){
mpu_target_temp = mpu_temperature.get();
};

void set_ahrs_defaults(){
ahrs_gyro_factor.setDefault();
ahrs_min_gyro_factor.setDefault();
ahrs_dynamic_factor.setDefault();
gyro_gating.setDefault();
ahrs_gyro_cal.setDefault();
}

SetupNG<float> MC( "MacCready", 0.5, true, SYNC_BIDIR, PERSISTENT, change_mc, UNIT_VARIO );
SetupNG<float> QNH( "QNH", 1013.25, true, SYNC_BIDIR, PERSISTENT, 0, UNIT_QNH );
Expand Down Expand Up @@ -271,13 +278,11 @@ SetupNG<int> attitude_indicator("AHRS", 1 );
SetupNG<int> ahrs_rpyl_dataset("RPYL", 0 );
SetupNG<int> ahrs_autozero("AHRSAZ", 0 );
SetupNG<float> ahrs_gyro_factor("AHRSMGYF", 100 );
SetupNG<float> ahrs_min_gyro_factor("AHRSLGYF", 20 );
SetupNG<float> ahrs_dynamic_factor("AHRSGDYN", 5 );
SetupNG<float> ahrs_min_gyro_factor("AHRSLGYF", 40 );
SetupNG<float> ahrs_gforce_lp("AHRSGFLP", 0.2 );
SetupNG<float> ahrs_virt_g_lowpass("AHRSVGL", 0.2 );
SetupNG<float> ahrs_virtg_bank_trust("AHRSGBT", 20 );
SetupNG<float> gyro_gating("GYRO_GAT", 1.0 );
SetupNG<float> ahrs_gyro_cal("AHRSGCAL", 1.07 );
SetupNG<float> ahrs_gbank_dynamic("AHRSGBD", 1.2 );
SetupNG<int> ahrs_defaults( "AHRSDEF", 1, RST_NONE, SYNC_NONE, VOLATILE, set_ahrs_defaults );
SetupNG<int> display_style("DISPLAY_STYLE", 1 );
SetupNG<int> s2f_switch_type("S2FHWSW", S2F_HW_SWITCH );
SetupNG<int> hardwareRevision("HWREV", HW_UNKNOWN );
Expand Down Expand Up @@ -390,7 +395,7 @@ SetupNG<t_wireless_id> custom_wireless_id("WLID", t_wireless_id("") );
SetupNG<int> drawing_prio("DRAWP", DP_NEEDLE );

mpud::raw_axes_t zero_bias;
SetupNG<float> gyro_gating("GYRO_GAT", 2.5 );

SetupNG<mpud::raw_axes_t> gyro_bias("GYRO_BIAS", zero_bias );
SetupNG<mpud::raw_axes_t> accl_bias("ACCL_BIAS", zero_bias );
SetupNG<float> mpu_temperature("MPUTEMP", 45.0, true, SYNC_FROM_MASTER, PERSISTENT, chg_mpu_target ); // default for AHRS chip temperature (XCV 2023)
Expand Down
15 changes: 8 additions & 7 deletions main/SetupNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ class SetupNG: public SetupCommon
return flags._dirty;
}

virtual void setDefault(){
set( _default );
}

virtual void setValueStr( const char * val ){
if( flags._volatile != VOLATILE ){
if( typeid( T ) == typeid( float ) ){
Expand Down Expand Up @@ -360,6 +364,7 @@ class SetupNG: public SetupCommon
return true;
}


virtual bool erase() {
if( flags._volatile != PERSISTENT ){
return true;
Expand Down Expand Up @@ -540,13 +545,11 @@ extern SetupNG<int> attitude_indicator;
extern SetupNG<int> ahrs_rpyl_dataset;
extern SetupNG<int> ahrs_autozero;
extern SetupNG<float> ahrs_gyro_factor;
extern SetupNG<float> ahrs_dynamic_factor;
extern SetupNG<float> ahrs_min_gyro_factor;
extern SetupNG<float> ahrs_gforce_lp;
extern SetupNG<float> ahrs_virt_g_lowpass;
extern SetupNG<float> ahrs_virtg_bank_trust;
extern SetupNG<float> ahrs_dynamic_factor;
extern SetupNG<float> gyro_gating;
extern SetupNG<int> ahrs_defaults;
extern SetupNG<float> ahrs_gyro_cal;
extern SetupNG<float> ahrs_gbank_dynamic;
extern SetupNG<int> display_style;
extern SetupNG<int> display_variant;
extern SetupNG<int> s2f_switch_type;
Expand Down Expand Up @@ -663,8 +666,6 @@ extern SetupNG<t_bitfield_compass> calibration_bits;
extern SetupNG<int> gear_warning;
extern SetupNG<t_wireless_id> custom_wireless_id;
extern SetupNG<int> drawing_prio;
extern SetupNG<float> gyro_gating;

extern uint8_t g_col_background;
extern uint8_t g_col_highlight;

Expand Down

0 comments on commit 100cf59

Please sign in to comment.