diff --git a/Tools/VARTest/Parameters.h b/Tools/VARTest/Parameters.h index 9f8786fde2..bc7f64dc2c 100644 --- a/Tools/VARTest/Parameters.h +++ b/Tools/VARTest/Parameters.h @@ -17,14 +17,14 @@ public: // The increment will prevent old parameters from being used incorrectly // by newer code. // - static const uint16_t k_format_version = 1; + static const uint16_t k_format_version = 13; // The parameter software_type is set up solely for ground station use // and identifies the software type (eg ArduPilotMega versus ArduCopterMega) // GCS will interpret values 0-9 as ArduPilotMega. Developers may use // values within that range to identify different branches. // - static const uint16_t k_software_type = 0; // 0 for APM trunk + static const uint16_t k_software_type = 9; // 0 for APM trunk enum { // Layout version number, always key zero. @@ -342,97 +342,14 @@ public: PID pidNavPitchAltitude; Parameters() : - format_version (k_format_version), - software_type (k_software_type), - - sysid_this_mav (MAV_SYSTEM_ID), - sysid_my_gcs (255), - serial3_baud (SERIAL3_BAUD/1000), - - kff_pitch_compensation (PITCH_COMP), - kff_rudder_mix (RUDDER_MIX), - kff_pitch_to_throttle (P_TO_T), - kff_throttle_to_pitch (T_TO_P), - - crosstrack_gain (XTRACK_GAIN_SCALED), - crosstrack_entry_angle (XTRACK_ENTRY_ANGLE_CENTIDEGREE), - - altitude_mix (ALTITUDE_MIX), - airspeed_ratio (AIRSPEED_RATIO), - airspeed_offset (0), - - /* XXX waypoint_mode missing here */ - command_total (0), - command_index (0), - waypoint_radius (WP_RADIUS_DEFAULT), - loiter_radius (LOITER_RADIUS_DEFAULT), - -#if GEOFENCE_ENABLED == ENABLED - fence_action (0), - fence_total (0), - fence_channel (0), - fence_minalt (0), - fence_maxalt (0), -#endif - - flybywire_airspeed_min (AIRSPEED_FBW_MIN), - flybywire_airspeed_max (AIRSPEED_FBW_MAX), - - throttle_min (THROTTLE_MIN), - throttle_max (THROTTLE_MAX), - throttle_slewrate (THROTTLE_SLEW_LIMIT), - throttle_fs_enabled (THROTTLE_FAILSAFE), - throttle_fs_value (THROTTLE_FS_VALUE), - throttle_cruise (THROTTLE_CRUISE), - - short_fs_action (SHORT_FAILSAFE_ACTION), - long_fs_action (LONG_FAILSAFE_ACTION), - gcs_heartbeat_fs_enabled(GCS_HEARTBEAT_FAILSAFE), - - flight_mode_channel (FLIGHT_MODE_CHANNEL), - flight_mode1 (FLIGHT_MODE_1), - flight_mode2 (FLIGHT_MODE_2), - flight_mode3 (FLIGHT_MODE_3), - flight_mode4 (FLIGHT_MODE_4), - flight_mode5 (FLIGHT_MODE_5), - flight_mode6 (FLIGHT_MODE_6), - - roll_limit (HEAD_MAX_CENTIDEGREE), - pitch_limit_max (PITCH_MAX_CENTIDEGREE), - pitch_limit_min (PITCH_MIN_CENTIDEGREE), - - auto_trim (AUTO_TRIM), - switch_enable (REVERSE_SWITCH), - mix_mode (ELEVON_MIXING), - reverse_elevons (ELEVON_REVERSE), - reverse_ch1_elevon (ELEVON_CH1_REVERSE), - reverse_ch2_elevon (ELEVON_CH2_REVERSE), - num_resets (0), - log_bitmask (DEFAULT_LOG_BITMASK), - log_last_filenumber (0), - reset_switch_chan (0), - airspeed_cruise (AIRSPEED_CRUISE_CM), - min_gndspeed (MIN_GNDSPEED_CM), - pitch_trim (0), - RTL_altitude (ALT_HOLD_HOME_CM), - FBWB_min_altitude (ALT_HOLD_FBW_CM), - ground_temperature (0), - ground_pressure (0), - compass_enabled (MAGNETOMETER), - flap_1_percent (FLAP_1_PERCENT), - flap_1_speed (FLAP_1_SPEED), - flap_2_percent (FLAP_2_PERCENT), - flap_2_speed (FLAP_2_SPEED), - - - battery_monitoring (DISABLED), - volt_div_ratio (VOLT_DIV_RATIO), - curr_amp_per_volt (CURR_AMP_PER_VOLT), - input_voltage (INPUT_VOLTAGE), - pack_capacity (HIGH_DISCHARGE), - inverted_flight_ch (0), - sonar_enabled (SONAR_ENABLED), - airspeed_enabled (AIRSPEED_SENSOR), + channel_roll (CH_1), + channel_pitch (CH_2), + channel_throttle (CH_3), + channel_rudder (CH_4), + rc_5 (CH_5), + rc_6 (CH_6), + rc_7 (CH_7), + rc_8 (CH_8), // PID controller initial P initial I initial D initial imax //----------------------------------------------------------------------------------- @@ -446,4 +363,6 @@ public: {} }; +extern const AP_Param::Info var_info[]; + #endif // PARAMETERS_H diff --git a/Tools/VARTest/Parameters.pde b/Tools/VARTest/Parameters.pde index 8875396e1e..9c60583740 100644 --- a/Tools/VARTest/Parameters.pde +++ b/Tools/VARTest/Parameters.pde @@ -9,99 +9,100 @@ version 2.1 of the License, or (at your option) any later version. */ -#define GSCALAR(v, name) { g.v.vtype, name, Parameters::k_param_ ## v, &g.v } -#define GGROUP(v, name, class) { AP_PARAM_GROUP, name, Parameters::k_param_ ## v, &g.v, class::var_info } -#define GOBJECT(v, name, class) { AP_PARAM_GROUP, name, Parameters::k_param_ ## v, &v, class::var_info } +#define GSCALAR(v, name, def) { g.v.vtype, name, Parameters::k_param_ ## v, &g.v, { def_value:def } } +#define GGROUP(v, name, class) { AP_PARAM_GROUP, name, Parameters::k_param_ ## v, &g.v, { group_info: class::var_info } } +#define GOBJECT(v, name, class) { AP_PARAM_GROUP, name, Parameters::k_param_ ## v, &v, { group_info: class::var_info } } -static const AP_Param::Info var_info[] PROGMEM = { - GSCALAR(format_version, "FORMAT_VERSION"), - GSCALAR(software_type, "SYSID_SW_TYPE"), - GSCALAR(sysid_this_mav, "SYSID_THISMAV"), - GSCALAR(sysid_my_gcs, "SYSID_MYGCS"), - GSCALAR(serial3_baud, "SERIAL3_BAUD"), - GSCALAR(kff_pitch_compensation, "KFF_PTCHCOMP"), - GSCALAR(kff_rudder_mix, "KFF_RDDRMIX"), - GSCALAR(kff_pitch_to_throttle, "KFF_PTCH2THR"), - GSCALAR(kff_throttle_to_pitch, "KFF_THR2PTCH"), +const AP_Param::Info var_info[] PROGMEM = { + GSCALAR(format_version, "FORMAT_VERSION", 0), + GSCALAR(software_type, "SYSID_SW_TYPE", Parameters::k_software_type), + GSCALAR(sysid_this_mav, "SYSID_THISMAV", MAV_SYSTEM_ID), + GSCALAR(sysid_my_gcs, "SYSID_MYGCS", 255), + GSCALAR(serial3_baud, "SERIAL3_BAUD", SERIAL3_BAUD/1000), + GSCALAR(kff_pitch_compensation, "KFF_PTCHCOMP", PITCH_COMP), + GSCALAR(kff_rudder_mix, "KFF_RDDRMIX", RUDDER_MIX), + GSCALAR(kff_pitch_to_throttle, "KFF_PTCH2THR", P_TO_T), + GSCALAR(kff_throttle_to_pitch, "KFF_THR2PTCH", T_TO_P), - GSCALAR(crosstrack_gain, "XTRK_GAIN_SC"), - GSCALAR(crosstrack_entry_angle, "XTRK_ANGLE_CD"), + GSCALAR(crosstrack_gain, "XTRK_GAIN_SC", XTRACK_GAIN_SCALED), + GSCALAR(crosstrack_entry_angle, "XTRK_ANGLE_CD", XTRACK_ENTRY_ANGLE_CENTIDEGREE), - GSCALAR(altitude_mix, "ALT_MIX"), - GSCALAR(airspeed_ratio, "ARSPD_RATIO"), - GSCALAR(airspeed_offset, "ARSPD_OFFSET"), + GSCALAR(altitude_mix, "ALT_MIX", ALTITUDE_MIX), + GSCALAR(airspeed_ratio, "ARSPD_RATIO", AIRSPEED_RATIO), + GSCALAR(airspeed_offset, "ARSPD_OFFSET", 0), - GSCALAR(command_total, "CMD_TOTAL"), - GSCALAR(command_index, "CMD_INDEX"), - GSCALAR(waypoint_radius, "WP_RADIUS"), - GSCALAR(loiter_radius, "WP_LOITER_RAD"), + GSCALAR(command_total, "CMD_TOTAL", 0), + GSCALAR(command_index, "CMD_INDEX", 0), + GSCALAR(waypoint_radius, "WP_RADIUS", WP_RADIUS_DEFAULT), + GSCALAR(loiter_radius, "WP_LOITER_RAD", LOITER_RADIUS_DEFAULT), #if GEOFENCE_ENABLED == ENABLED - GSCALAR(fence_action, "FENCE_ACTION"), - GSCALAR(fence_total, "FENCE_TOTAL"), - GSCALAR(fence_channel, "FENCE_CHANNEL"), - GSCALAR(fence_minalt, "FENCE_MINALT"), - GSCALAR(fence_maxalt, "FENCE_MAXALT"), + GSCALAR(fence_action, "FENCE_ACTION", 0), + GSCALAR(fence_total, "FENCE_TOTAL", 0), + GSCALAR(fence_channel, "FENCE_CHANNEL", 0), + GSCALAR(fence_minalt, "FENCE_MINALT", 0), + GSCALAR(fence_maxalt, "FENCE_MAXALT", 0), #endif - GSCALAR(flybywire_airspeed_min, "ARSPD_FBW_MIN"), - GSCALAR(flybywire_airspeed_max, "ARSPD_FBW_MAX"), + GSCALAR(flybywire_airspeed_min, "ARSPD_FBW_MIN", AIRSPEED_FBW_MIN), + GSCALAR(flybywire_airspeed_max, "ARSPD_FBW_MAX", AIRSPEED_FBW_MAX), - GSCALAR(throttle_min, "THR_MIN"), - GSCALAR(throttle_max, "THR_MAX"), - GSCALAR(throttle_slewrate, "THR_SLEWRATE"), - GSCALAR(throttle_fs_enabled, "THR_FAILSAFE"), - GSCALAR(throttle_fs_value, "THR_FS_VALUE"), - GSCALAR(throttle_cruise, "TRIM_THROTTLE"), + GSCALAR(throttle_min, "THR_MIN", THROTTLE_MIN), + GSCALAR(throttle_max, "THR_MAX", THROTTLE_MAX), + GSCALAR(throttle_slewrate, "THR_SLEWRATE", THROTTLE_SLEW_LIMIT), + GSCALAR(throttle_fs_enabled, "THR_FAILSAFE", THROTTLE_FAILSAFE), + GSCALAR(throttle_fs_value, "THR_FS_VALUE", THROTTLE_FS_VALUE), + GSCALAR(throttle_cruise, "TRIM_THROTTLE", THROTTLE_CRUISE), - GSCALAR(short_fs_action, "FS_SHORT_ACTN"), - GSCALAR(long_fs_action, "FS_LONG_ACTN"), - GSCALAR(gcs_heartbeat_fs_enabled, "FS_GCS_ENABL"), + GSCALAR(short_fs_action, "FS_SHORT_ACTN", SHORT_FAILSAFE_ACTION), + GSCALAR(long_fs_action, "FS_LONG_ACTN", LONG_FAILSAFE_ACTION), + GSCALAR(gcs_heartbeat_fs_enabled, "FS_GCS_ENABL", GCS_HEARTBEAT_FAILSAFE), - GSCALAR(flight_mode_channel, "FLTMODE_CH"), - GSCALAR(flight_mode1, "FLTMODE1"), - GSCALAR(flight_mode2, "FLTMODE2"), - GSCALAR(flight_mode3, "FLTMODE3"), - GSCALAR(flight_mode4, "FLTMODE4"), - GSCALAR(flight_mode5, "FLTMODE5"), - GSCALAR(flight_mode6, "FLTMODE6"), + GSCALAR(flight_mode_channel, "FLTMODE_CH", FLIGHT_MODE_CHANNEL), + GSCALAR(flight_mode1, "FLTMODE1", FLIGHT_MODE_1), + GSCALAR(flight_mode2, "FLTMODE2", FLIGHT_MODE_2), + GSCALAR(flight_mode3, "FLTMODE3", FLIGHT_MODE_3), + GSCALAR(flight_mode4, "FLTMODE4", FLIGHT_MODE_4), + GSCALAR(flight_mode5, "FLTMODE5", FLIGHT_MODE_5), + GSCALAR(flight_mode6, "FLTMODE6", FLIGHT_MODE_6), - GSCALAR(roll_limit, "LIM_ROLL_CD"), - GSCALAR(pitch_limit_max, "LIM_PITCH_MAX"), - GSCALAR(pitch_limit_min, "LIM_PITCH_MIN"), + GSCALAR(roll_limit, "LIM_ROLL_CD", HEAD_MAX_CENTIDEGREE), + GSCALAR(pitch_limit_max, "LIM_PITCH_MAX", PITCH_MAX_CENTIDEGREE), + GSCALAR(pitch_limit_min, "LIM_PITCH_MIN", PITCH_MIN_CENTIDEGREE), - GSCALAR(auto_trim, "TRIM_AUTO"), - GSCALAR(switch_enable, "SWITCH_ENABLE"), - GSCALAR(mix_mode, "ELEVON_MIXING"), - GSCALAR(reverse_elevons, "ELEVON_REVERSE"), - GSCALAR(reverse_ch1_elevon, "ELEVON_CH1_REV"), - GSCALAR(reverse_ch2_elevon, "ELEVON_CH2_REV"), - GSCALAR(num_resets, "SYS_NUM_RESETS"), - GSCALAR(log_bitmask, "LOG_BITMASK"), - GSCALAR(log_last_filenumber, "LOG_LASTFILE"), - GSCALAR(reset_switch_chan, "RST_SWITCH_CH"), - GSCALAR(airspeed_cruise, "TRIM_ARSPD_CM"), - GSCALAR(min_gndspeed, "MIN_GNDSPD_CM"), - GSCALAR(pitch_trim, "TRIM_PITCH_CD"), - GSCALAR(RTL_altitude, "ALT_HOLD_RTL"), - GSCALAR(FBWB_min_altitude, "ALT_HOLD_FBWCM"), - GSCALAR(ground_temperature, "GND_TEMP"), - GSCALAR(ground_pressure, "GND_ABS_PRESS"), - GSCALAR(compass_enabled, "MAG_ENABLE"), - GSCALAR(flap_1_percent, "FLAP_1_PERCNT"), - GSCALAR(flap_1_speed, "FLAP_1_SPEED"), - GSCALAR(flap_2_percent, "FLAP_2_PERCNT"), - GSCALAR(flap_2_speed, "FLAP_2_SPEED"), + GSCALAR(auto_trim, "TRIM_AUTO", AUTO_TRIM), + GSCALAR(switch_enable, "SWITCH_ENABLE", REVERSE_SWITCH), + GSCALAR(mix_mode, "ELEVON_MIXING", ELEVON_MIXING), + GSCALAR(reverse_elevons, "ELEVON_REVERSE", ELEVON_REVERSE), + GSCALAR(reverse_ch1_elevon, "ELEVON_CH1_REV", ELEVON_CH1_REVERSE), + GSCALAR(reverse_ch2_elevon, "ELEVON_CH2_REV", ELEVON_CH2_REVERSE), + GSCALAR(num_resets, "SYS_NUM_RESETS", 0), + GSCALAR(log_bitmask, "LOG_BITMASK", DEFAULT_LOG_BITMASK), + GSCALAR(log_last_filenumber, "LOG_LASTFILE", 0), + GSCALAR(reset_switch_chan, "RST_SWITCH_CH", 0), + GSCALAR(airspeed_cruise, "TRIM_ARSPD_CM", AIRSPEED_CRUISE_CM), + GSCALAR(min_gndspeed, "MIN_GNDSPD_CM", MIN_GNDSPEED_CM), + GSCALAR(pitch_trim, "TRIM_PITCH_CD", 0), + GSCALAR(RTL_altitude, "ALT_HOLD_RTL", ALT_HOLD_HOME_CM), + GSCALAR(FBWB_min_altitude, "ALT_HOLD_FBWCM", ALT_HOLD_FBW_CM), + GSCALAR(ground_temperature, "GND_TEMP", 0), + GSCALAR(ground_pressure, "GND_ABS_PRESS", 0), + GSCALAR(compass_enabled, "MAG_ENABLE", MAGNETOMETER), + GSCALAR(flap_1_percent, "FLAP_1_PERCNT", FLAP_1_PERCENT), + GSCALAR(flap_1_speed, "FLAP_1_SPEED", FLAP_1_SPEED), + GSCALAR(flap_2_percent, "FLAP_2_PERCNT", FLAP_2_PERCENT), + GSCALAR(flap_2_speed, "FLAP_2_SPEED", FLAP_2_SPEED), - GSCALAR(battery_monitoring, "BATT_MONITOR"), - GSCALAR(volt_div_ratio, "VOLT_DIVIDER"), - GSCALAR(curr_amp_per_volt, "AMP_PER_VOLT"), - GSCALAR(input_voltage, "INPUT_VOLTS"), - GSCALAR(pack_capacity, "BATT_CAPACITY"), - GSCALAR(inverted_flight_ch, "INVERTEDFLT_CH"), - GSCALAR(sonar_enabled, "SONAR_ENABLE"), - GSCALAR(airspeed_enabled, "ARSPD_ENABLE"), + GSCALAR(battery_monitoring, "BATT_MONITOR", DISABLED), + GSCALAR(volt_div_ratio, "VOLT_DIVIDER", VOLT_DIV_RATIO), + GSCALAR(curr_amp_per_volt, "AMP_PER_VOLT", CURR_AMP_PER_VOLT), + GSCALAR(input_voltage, "INPUT_VOLTS", INPUT_VOLTAGE), + GSCALAR(pack_capacity, "BATT_CAPACITY", HIGH_DISCHARGE), + GSCALAR(inverted_flight_ch, "INVERTEDFLT_CH", 0), + GSCALAR(sonar_enabled, "SONAR_ENABLE", SONAR_ENABLED), + GSCALAR(airspeed_enabled, "ARSPD_ENABLE", AIRSPEED_SENSOR), +#if 1 GGROUP(channel_roll, "RC1_", RC_Channel), GGROUP(channel_pitch, "RC2_", RC_Channel), @@ -125,23 +126,15 @@ static const AP_Param::Info var_info[] PROGMEM = { #if 0 // VARTest doesn't have these GOBJECT(gcs0, "SR0_", GCS_MAVLINK), - GOBJECT(gcs3, "SR3_", GCS_MAVLINK) + GOBJECT(gcs3, "SR3_", GCS_MAVLINK), #endif +#endif + AP_VAREND }; static void load_parameters(void) { - // setup the AP_Var subsystem for storage to EEPROM - if (!AP_Param::setup(var_info, sizeof(var_info)/sizeof(var_info[0]), WP_START_BYTE)) { - // this can only happen on startup, and its a definate coding - // error. Best not to continue so the programmer catches it - while (1) { - Serial.println_P(PSTR("ERROR: Failed to setup AP_Param")); - delay(1000); - } - } - if (!g.format_version.load() || g.format_version != Parameters::k_format_version) { diff --git a/Tools/VARTest/VARTest.pde b/Tools/VARTest/VARTest.pde index dac394a010..0476002e6f 100644 --- a/Tools/VARTest/VARTest.pde +++ b/Tools/VARTest/VARTest.pde @@ -25,11 +25,18 @@ #include // ArduPilot Mega IMU Library #include #include +#include #include #include #include #include +// this sets up the parameter table, and sets the default values. This +// must be the first AP_Param variable declared to ensure its +// constructor runs before the constructors of the other AP_Param +// variables +AP_Param param_loader(var_info, WP_START_BYTE); + static Parameters g; static AP_ADC_ADS7844 adc; @@ -51,6 +58,12 @@ static AP_Compass_HMC5843 compass; #endif AP_Baro_BMP085_HIL barometer; +SITL sitl; + +BetterStream *mavlink_comm_0_port; +BetterStream *mavlink_comm_1_port; +mavlink_system_t mavlink_system = {7,1,0,0}; + FastSerialPort0(Serial); FastSerialPort1(Serial1); // GPS port @@ -118,7 +131,7 @@ void setup() { for (AP_Param *ap = AP_Param::first(&token, &type); ap; ap=AP_Param::next(&token, &type)) { - test_variable(ap, type); + //test_variable(ap, type); } AP_Param::show_all();