Beispiel #1
0
LanPlayer::LanPlayer(const MString &Name, const int PlayerID)
{
	m_name = Name;
	SetPlayerID(PlayerID);
	ClearStats();
	m_screenpos = 1; //we know stuff
}
Beispiel #2
0
void ValuesTable::RecalculateStats() {
	ClearStats();

	size_t s,e;
	s = m_stats.Start(); 
	e = m_stats.End();

	for (size_t i = s; i <= e; ++i) 
		UpdateStats(i);
}
///////////////////////////////////////////////////////////////
//
// CClientModelCacheManagerImpl::DoPulse
//
///////////////////////////////////////////////////////////////
void CClientModelCacheManagerImpl::DoPulse(void)
{
    m_TickCountNow = CTickCount::Now();
    ClearStats();

    if (!g_pClientGame->GetLocalPlayer())
        return;

    m_fGameFps = g_pGame->GetFPS();

    // Assess which models will be needed in the next 2 seconds

    // Update frame time
    int iDeltaTimeMs = Clamp(10, (m_TickCountNow - m_LastTimeMs).ToInt(), 100);
    m_LastTimeMs = m_TickCountNow;

    // Get camera position
    CVector        vecOldCameraPos = m_vecCameraPos;
    CClientCamera* pCamera = g_pClientGame->GetManager()->GetCamera();
    if (pCamera->IsInFixedMode())
        pCamera->GetPosition(m_vecCameraPos);
    else
        g_pClientGame->GetLocalPlayer()->GetPosition(m_vecCameraPos);

    // Calculate camera velocity
    CVector vecDif = m_vecCameraPos - vecOldCameraPos;
    float   fCameraSpeed = vecDif.Length() / (iDeltaTimeMs * 0.001f);
    float   a = m_fSmoothCameraSpeed;
    m_fSmoothCameraSpeed = Lerp(m_fSmoothCameraSpeed, 0.25f, fCameraSpeed);

    // Spread updating over 4 frames
    m_iFrameCounter = (m_iFrameCounter + 1) % 4;

    if (m_iFrameCounter == 1)
        DoPulsePedModels();
    else if (m_iFrameCounter == 3)
        DoPulseVehicleModels();

    // Handle regeneration of possibly replaced clothes textures
    if (g_pGame->GetRenderWare()->HasClothesReplacementChanged())
    {
        g_pMultiplayer->FlushClothesCache();

        CClientPlayerManager* pPlayerManager = g_pClientGame->GetPlayerManager();
        for (std::vector<CClientPlayer*>::const_iterator iter = pPlayerManager->IterBegin(); iter != pPlayerManager->IterEnd(); ++iter)
            (*iter)->RebuildModel(false);

        CClientPedManager* pPedManager = g_pClientGame->GetPedManager();
        for (std::vector<CClientPed*>::const_iterator iter = pPedManager->IterBegin(); iter != pPedManager->IterEnd(); ++iter)
            (*iter)->RebuildModel(false);
    }
}
Beispiel #4
0
void ValuesTable::SetNumberOfValues(size_t number_of_values) {

	assert(m_draw->m_draws_controller->GetDoubleCursor() == false);
	m_values.clear();
	m_values.resize(number_of_values + 2 * m_draw->m_draws_controller->GetFilter());
	m_view.m_start = m_draw->m_draws_controller->GetFilter();
	m_view.m_end = number_of_values - 1 + m_draw->m_draws_controller->GetFilter();

	m_stats.m_start = m_draw->m_draws_controller->GetFilter();
	m_stats.m_end = number_of_values - 1 + m_draw->m_draws_controller->GetFilter();

	m_number_of_values = number_of_values;

	ClearStats();
}
Beispiel #5
0
void ValuesTable::SwitchFilter(int f, int t) {
	int df = t - f;

	m_view.m_start += df;
	m_view.m_end += df;

	m_stats.m_start += df;
	m_stats.m_end += df;

	for (size_t i = 0; i < m_values.size(); ++i) 
		m_values[i].n_count = 0;

	if (df > 0) 
		while (df--) {
			m_values.push_back(ValueInfo());
			m_values.push_front(ValueInfo());
		}
	else 
		while (df++) {
			m_values.pop_back();
			m_values.pop_front();
		}

	if (m_draw->GetDrawInfo() == NULL)
		return;

	ClearStats();

	bool stats_updated, view_updated;
	for (size_t i = 0; i < m_values.size(); ++i) {
		ValueInfo& v = m_values.at(i);
		if (v.state != ValueInfo::EMPTY && v.state != ValueInfo::PENDING)
			UpdateProbesValues(i, stats_updated, view_updated);
	}

}
void EngineStatePlayerStats::OnNewGame()
{
  // Blow away the previous stats for each player.
  ClearStats();
}
Beispiel #7
0
// Default settings
static void resetConf(void)
{
    uint8_t i;
    const int8_t default_align[3][3] = { /* GYRO */ { 0, 0, 0 }, /* ACC */ { 0, 0, 0 }, /* MAG */ { 0, 0, 0 } };
    memset(&cfg, 0, sizeof(config_t));

    cfg.version = EEPROM_CONF_VERSION;
    cfg.mixerConfiguration = MULTITYPE_QUADX;
    featureClearAll();
//    featureSet(FEATURE_VBAT);
    featureSet(FEATURE_PPM);
//    featureSet(FEATURE_FAILSAFE);
//    featureSet(FEATURE_LCD);
//    featureSet(FEATURE_GPS);
//    featureSet(FEATURE_PASS);                   // Just pass Throttlechannel
//    featureSet(FEATURE_SONAR);

    cfg.P8[ROLL]                  =  35;        // 40
    cfg.I8[ROLL]                  =  30;
    cfg.D8[ROLL]                  =  30;

    cfg.P8[PITCH]                 =  35;        // 40
    cfg.I8[PITCH]                 =  30;
    cfg.D8[PITCH]                 =  30;

    cfg.P8[YAW]                   =  60;        // 70
    cfg.I8[YAW]                   =  45;

    cfg.P8[PIDALT]                = 100;
    cfg.I8[PIDALT]                =  30;
    cfg.D8[PIDALT]                =  80;

    cfg.P8[PIDPOS]                =  10;        // FIND YOUR VALUE
    cfg.I8[PIDPOS]                =  40;        // USED

    cfg.P8[PIDPOSR]               =  70;        // FIND YOUR VALUE                    // Controls the speed part with my PH logic
    cfg.D8[PIDPOSR]               = 100;        // FIND YOUR VALUE                    // Controls the speed part with my PH logic

    cfg.P8[PIDNAVR]               =  15;        // 14 More ?
    cfg.I8[PIDNAVR]               =   0;        // NAV_I * 100;                       // Scaling/Purpose unchanged
    cfg.D8[PIDNAVR]               =   0;        // NAV_D * 1000;                      // Scaling/Purpose unchanged

//    cfg.P8[PIDPOS]                = 11;         // APM PH Stock values
//    cfg.I8[PIDPOS]                = 0;
//    cfg.D8[PIDPOS]                = 0;

//    cfg.P8[PIDPOSR]               = 20;         // POSHOLD_RATE_P * 10;
//    cfg.I8[PIDPOSR]               = 8;          // POSHOLD_RATE_I * 100;
//    cfg.D8[PIDPOSR]               = 45;         // POSHOLD_RATE_D * 1000;

//    cfg.P8[PIDNAVR]               = 14;         // NAV_P * 10;
//    cfg.I8[PIDNAVR]               = 20;         // NAV_I * 100;
//    cfg.D8[PIDNAVR]               = 80;         // NAV_D * 1000;

    cfg.P8[PIDLEVEL]              = 70;         // 70
    cfg.I8[PIDLEVEL]              = 10;
    cfg.D8[PIDLEVEL]              = 50;

    cfg.P8[PIDMAG]                = 80;         // cfg.P8[PIDVEL] = 0;// cfg.I8[PIDVEL] = 0;// cfg.D8[PIDVEL] = 0;

    cfg.rcRate8                   = 100;
    cfg.rcExpo8                   = 80;         // cfg.rollPitchRate = 0;// cfg.yawRate = 0;// cfg.dynThrPID = 0;
    cfg.thrMid8                   = 50;

    memcpy(&cfg.align, default_align, sizeof(cfg.align));

    cfg.mag_dec                   = 113;        // Crashpilot //cfg.acc_hdw = ACC_DEFAULT;// default/autodetect
    cfg.mag_time                  = 1;          // (1-6) Calibration time in minutes
    cfg.mag_gain                  = 0;          // 0(default) = 1.9 GAUSS ; 1 = 2.5 GAUSS (problematic copters, will reduce 20% resolution)
    cfg.acc_hdw                   = 2;          // Crashpilot MPU6050
    cfg.acc_lpfhz                 = 10.0f;      // [0.x-100Hz] LPF for angle/horizon 0.536f resembles somehow the orig mwii factor
    cfg.acc_altlpfhz              = 15;         // [1-100Hz]   LPF for althold
    cfg.acc_gpslpfhz              = 30;         // [1-100Hz]   LPF for GPS ins stuff
    cfg.looptime                  = 3000;
    cfg.mainpidctrl               = 0;          // 0 = OriginalMwiiPid pimped by me, 1 = New mwii controller (experimental, float pimped + pt1)
    cfg.maincuthz                 = 12;         // [1-100Hz] Cuf Off Frequency for D term of main Pid controller
    cfg.gpscuthz                  = 45;         // [1-100Hz] Cuf Off Frequency for D term of GPS Pid controller 

    cfg.gy_gcmpf                  = 700;        // (10-1000) 400 default. Now 1000. The higher, the more weight gets the gyro and the lower is the correction with Acc data.
    cfg.gy_mcmpf                  = 200;        // (10-2000) 200 default for 10Hz. Now higher. Gyro/Magnetometer Complement.
    cfg.gy_smrll                  = 0;
    cfg.gy_smptc                  = 0;
    cfg.gy_smyw                   = 0;          // In Tricopter mode a "1" will enable a moving average filter, anything higher will also enable a lowpassfilter
    cfg.gy_lpf                    = 42;         // Values for MPU 6050/3050: 256, 188, 98, 42, 20, 10, (HZ) For L3G4200D: 93, 78, 54, 32
    cfg.gy_stdev                  = 5;

    // Baro
    cfg.accz_vcf                  = 0.985f;     // Crashpilot: Value for complementary filter accz and barovelocity
    cfg.accz_acf                  = 0.960f;     // Crashpilot: Value for complementary filter accz and altitude
    cfg.bar_lag                   = 0.3f;       // Lag of Baro/Althold stuff in general, makes stop in hightchange snappier
    cfg.bar_dscl                  = 0.7f;       // Scale downmovement down (because copter drops faster than rising)
    cfg.bar_dbg                   = 0;          // Crashpilot: 1 = Debug Barovalues //cfg.baro_noise_lpf = 0.6f;// Crashpilot: Not used anymore//cfg.baro_cf = 0.985f;// Crashpilot: Not used anymore

    // Autoland
    cfg.al_barolr                 = 50;         // [10 - 200cm/s] Baro Landingrate
    cfg.al_snrlr                  = 50;         // [10 - 200cm/s] Sonar Landingrate - You can specify different landingfactor here on sonar contact, because sonar land maybe too fast when snr_cf is high
    cfg.al_debounce               = 5;          // (0-20%) 0 Disables. Defines a Throttlelimiter on Autoland. Percentage defines the maximum deviation of assumed hoverthrottle during Autoland
    cfg.al_tobaro                 = 2000;       // Timeout in ms (100 - 5000) before shutoff on autoland. "esc_nfly" must be undershot for that timeperiod
    cfg.al_tosnr                  = 1000;       // Timeout in ms (100 - 5000) If sonar aided land is wanted (snr_land = 1) you can choose a different timeout here

    // Autostart
    cfg.as_lnchr                  = 200;        // [50 - 250 no dimension DEFAULT:200] Autostart initial launchrate to get off the ground. When as_stdev is exceeded, as_clmbr takes over
    cfg.as_clmbr                  = 100;        // [50 - 250cm/s DEFAULT:100] Autostart climbrate in cm/s after liftoff! Autostart Rate in cm/s will be lowered when approaching targethight.
    cfg.as_trgt                   = 0;          // [0 - 255m  DEFAULT:0 (0 = Disable)] Autostart Targethight in m Note: use 2m or more
    cfg.as_stdev                  = 10;         // [5 - 20 no dimension DEFAULT:10] This is the std. deviation of the variometer when a liftoff is assumed. The higher the more unsensitive.

    cfg.vbatscale                 = 110;
    cfg.vbatmaxcellvoltage        = 43;
    cfg.vbatmincellvoltage        = 33;
    cfg.power_adc_channel         = 0;

    // Radio
    parseRcChannels("AETR1234");
    cfg.rc_db                     = 20;         // Crashpilot: A little deadband will not harm our crappy RC
    cfg.rc_dbyw                   = 20;         // Crashpilot: A little deadband will not harm our crappy RC
    cfg.rc_dbah                   = 50;         // Crashpilot: A little deadband will not harm our crappy RC
    cfg.rc_dbgps                  = 5;          // Additional Deadband for all GPS functions;
    cfg.devorssi                  = 0;          // Will take the last channel for RSSI value, so add one to rc_auxch, don't use that auxchannel unless you want it to trigger something
                                                // Note Spektrum or Graupner will override that setting to 0.
    cfg.rssicut                   = 0;          // [0-80%][0 Disables] Below that percentage rssi will show zero.
    // cfg.spektrum_hires = 0;
    cfg.rc_minchk                 = 1100;
    cfg.rc_mid                    = 1500;
    cfg.rc_maxchk                 = 1900;
    cfg.rc_lowlat                 = 1;          // [0 - 1] Default 1. 1 = lower latency, 0 = normal latency/more filtering.
    cfg.rc_rllrm                  = 0;          // disable arm/disarm on roll left/right
    cfg.rc_auxch                  = 4;          // [4 - 6] cGiesen: Default = 4, then like the standard! Crashpilot: Limited to 6 aux for safety
    cfg.rc_killt                  = 0;          // Time in ms when your arm switch becomes a Killswitch, 0 disables the Killswitch, can not be used together with FEATURE_INFLIGHT_ACC_CAL
    cfg.rc_flpsp                  = 0;          // [0-3] When enabled(1) and upside down in acro or horizon mode throttle is reduced (see readme)
    cfg.rc_motor                  = 0;          // [0-2] Behaviour when thr < rc_minchk: 0= minthrottle no regulation, 1= minthrottle&regulation, 2= Motorstop 

    // Motor/ESC/Servo
    cfg.esc_gain                  =    0;       // [0Disables - 32] Gain for esc to reduce delay 16 = Gain of 1 that would double the initial response(limited to +500) Only helps unflashed ESC.
//  cfg.esc_min                   = 1150;       // ORIG
    cfg.esc_min                   = 1100;
    cfg.esc_max                   = 1950;
    cfg.esc_moff                  = 1000;
    cfg.esc_nfly                  = 1300;       // This is the absolute throttle that kicks off the "has landed timer" if it is too low cfg.rc_minchk + 5% is taken. Also baselinethr for Autostart, also plausibility check for initial Failsafethrottle
//  cfg.esc_nfly                  = 0;          // This is the absolute throttle that kicks off the "has landed timer" if it is too low cfg.rc_minchk + 5% is taken.
    cfg.esc_pwm                   = 400;
    cfg.srv_pwm                   = 50;
    cfg.pass_mot                  = 0;          // Crashpilot: Only used with feature pass. If 0 = all Motors, otherwise specific Motor

    // servos
    cfg.tri_ydir                  = 1;
    cfg.tri_ymid                  = 1500;
    cfg.tri_ymin                  = 1020;
    cfg.tri_ymax                  = 2000;
    cfg.tri_ydel                  = 0;          // [0-1000ms] Tri Yaw Arm delay: Time in ms after wich the yaw servo after arming will engage (useful with "yaw arm"). 0 disables Yawservo always active.

    // flying wing
    cfg.wing_left_min             = 1020;
    cfg.wing_left_mid             = 1500;
    cfg.wing_left_max             = 2000;
    cfg.wing_right_min            = 1020;
    cfg.wing_right_mid            = 1500;
    cfg.wing_right_max            = 2000;
    cfg.pitch_direction_l         = 1;
    cfg.pitch_direction_r         = -1;
    cfg.roll_direction_l          = 1;
    cfg.roll_direction_r          = 1;

    // gimbal
    cfg.gbl_pgn                   = 10;
    cfg.gbl_rgn                   = 10;
    cfg.gbl_flg                   = GIMBAL_NORMAL;
    cfg.gbl_pmn                   = 1020;
    cfg.gbl_pmx                   = 2000;
    cfg.gbl_pmd                   = 1500;
    cfg.gbl_rmn                   = 1020;
    cfg.gbl_rmx                   = 2000;
    cfg.gbl_rmd                   = 1500;

    // gps/nav
    cfg.gps_type                  = 1;          // GPS_NMEA = 0, GPS_UBLOX = 1, GPS_MTK16 = 2, GPS_MTK19 = 3, GPS_UBLOX_DUMB = 4
    cfg.gps_baudrate              = 115200;     //38400; // Changed 8/6/13 to 115200;
    cfg.gps_ins_vel               = 0.6f;       // Crashpilot GPS INS The LOWER the value the closer to gps speed // Dont go to high here
    cfg.gps_lag                   = 2000;       // GPS Lag in ms
    cfg.gps_ph_minsat             = 6;          // Minimal Satcount for PH, PH on RTL is still done with 5Sats or more
    cfg.gps_expo                  = 20;         // 1 - 99 % defines the actual Expo applied for GPS
    cfg.gps_ph_settlespeed        = 10;         // 1 - 200 cm/s PH settlespeed in cm/s
    cfg.gps_ph_brakemaxangle      = 15;         // 1 - 45 Degree Maximal Overspeedbrake
    cfg.gps_ph_minbrakepercent    = 50;         // 1 - 99% minimal percent of "brakemaxangle" left over for braking. Example brakemaxangle = 6 so 50 Percent is 3..
    cfg.gps_ph_brkacc             = 40;         // [1 - 500] Is the assumed negative braking acceleration in cm/(s*s) of copter. Value is positive though. It will be a timeout. The lower the Value the longe the Timeout
    cfg.gps_maxangle              = 35;         // 10 - 45 Degree Maximal over all GPS bank angle
    cfg.gps_wp_radius             = 200;
//  cfg.rtl_mnh                   = 20;         // (0 - 200m) Minimal RTL hight in m, 0 disables feature
	  cfg.rtl_mnh                   = 0;          // (0 - 200m) Minimal RTL hight in m, 0 disables feature
    cfg.rtl_cr                    = 80;         // [10 - 200cm/s] When rtl_mnh is defined this is the climbrate in cm/s
    cfg.rtl_mnd                   = 0;          // 0 Disables. Minimal distance for RTL in m, otherwise it will just autoland, prevent Failsafe jump in your face, when arming copter and turning off TX
    cfg.gps_rtl_flyaway           = 0;          // [0 - 100m] 0 Disables. If during RTL the distance increases beyond this value (in meters relative to RTL activation point), something is wrong, autoland

    cfg.gps_yaw                   = 30;         // Thats the MAG P during GPS functions, substitute for "cfg.P8[PIDMAG]"
    cfg.nav_rtl_lastturn          = 1;          // 1 = when copter gets to home position it rotates it's head to takeoff direction independend of nav_controls_heading
    cfg.nav_tail_first            = 0;          // 1 = Copter comes back with ass first (only works with nav_controls_heading = 1)
    cfg.nav_controls_heading      = 0;          // 1 = Nav controls YAW during WP ONLY
//  cfg.nav_controls_heading      = 1;          // 1 = Nav controls YAW during WP ONLY
    cfg.nav_speed_min             = 100;        // 10 - 200 cm/s don't set higher than nav_speed_max! That dumbness is not covered.
    cfg.nav_speed_max             = 350;        // 50 - 2000 cm/s don't set lower than nav_speed_min! That dumbness is not covered.
    cfg.nav_approachdiv           = 3;          // 2 - 10 This is the divisor for approach speed for wp_distance. Example: 400cm / 3 = 133cm/s if below nav_speed_min it will be adjusted
    cfg.nav_tiltcomp              = 30;         // 0 - 100 (20 TestDefault) Only arducopter really knows. Dfault was 54. This is some kind of a hack of them to reach actual nav_speed_max. 54 was Dfault, 0 disables
    cfg.nav_ctrkgain              = 0.5f;       // 0 - 10.0 (0.5 TestDefault) (Floatvariable) That is the "Crosstrackgain" APM Dfault is "1". "0" disables

    // Failsafe Variables
    cfg.fs_delay                  = 10;         // in 0.1s (10 = 1sec)
    cfg.fs_ofdel                  = 200;        // in 0.1s (200 = 20sec)
    cfg.fs_rcthr                  = 1200;       // decent Dfault which should always be below hover throttle for people.
    cfg.fs_ddplt                  = 0;		      // EXPERIMENTAL Time in sec when FS is engaged after idle on THR/YAW/ROLL/PITCH, 0 disables max 250
    cfg.fs_jstph                  = 0;          // Does just PH&Autoland an not RTL, use this in difficult areas with many obstacles to avoid RTL crash into something
    cfg.fs_nosnr                  = 1;          // When snr_land is set to 1, it is possible to ignore that on Failsafe, because FS over a tree could turn off copter

    // serial (USART1) baudrate
    cfg.serial_baudrate           = 115200;
    cfg.tele_prot                 = 0;          // Protocol ONLY used when Armed including Baudchange if necessary. 0 (Dfault)=Keep Multiwii @CurrentUSB Baud, 1=Frsky @9600Baud, 2=Mavlink @CurrentUSB Baud, 3=Mavlink @57KBaud (like stock minimOSD wants it)

    // LED Stuff
    cfg.LED_invert                = 0;          // Crashpilot: Inversion of LED 0&1 Partly implemented because Bootup is not affected
    cfg.LED_Type                  = 1;		      // 1=MWCRGB / 2=MONO_LED / 3=LEDRing
    cfg.LED_Pinout                = 1;		      // rc6
    cfg.LED_ControlChannel        = 8;		      // AUX4 (Channel 8)
    cfg.LED_Armed                 = 0;		      // 0 = Show LED only if armed, 1 = always show LED
    cfg.LED_Pattern1			        = 1300; 		  // 32bit bit pattern to have flickering led patterns / the pattern for MWCRGB 1000-2000
    cfg.LED_Pattern2			        = 1800; 		  // 32bit bit pattern to have flickering led patterns / the pattern for MWCRGB 1000-2000
    cfg.LED_Pattern3			        = 1900; 		  // 32bit bit pattern to have flickering led patterns / the pattern for MWCRGB 1000-2000
    cfg.LED_Toggle_Delay1         = 0x08;       // slow down LED_Pattern
    cfg.LED_Toggle_Delay2         = 0x08;       // slow down LED_Pattern
    cfg.LED_Toggle_Delay3         = 0x08;       // slow down LED_Pattern

    // SONAR
    // SOME INFO ON SONAR:
    // PWM56 are 5V resistant, RC78 only tolerate 3.3V(!!) so add a 1K Ohms resistor!!!
    // Note: You will never see the maximum possible sonar range in a copter, so go for the half of it (or less?)
    //
    // Connection possibilities depending on Receivertype:
    // PPSUM: RC78 possible, PWM56 possible (on max. quadcopters, see below)
    // Normal RX: Just Connection on Motorchannel 5&6 (PWM56) is possible.
    // The PWM56 sonar connection option is only available in setups with max motors 4, otherwise sonar is not initialized.
    //
    // HC-SR04:
    // Operation Voltage: 5V (!! Use PWM56 or 1K resistor !!)
    // Range: 2cm - 400cm
    // Angle: 15 Degrees (Test out for yourself: cfg.snr_tilt = X)
    //
    // Maxbotix in general
    // Operation Voltage: (some 2.5V)3.3V - 5V ((!! Use PWM56 or resistor with 5V !!)
    // Only wire the Maxbotics for PWM output (more precise anyway), not the analog etc. modes, just wire echopin (normally pin 2)
    // Range: 20cm(!) - 765cm (some >1000cm), MaxTiltAngle is not specified, depending on Model
    // Tested on MB1200 XL-MaxSonar-EZ0
    //
    // I2C sonar in general (by mj666)
    // If operation voltage of the sonar sensor is 5 Volt (NAZE I2C is 3.3 Volt), take care they do not have pull up resistors connected to 5 Volt.
    // Outputs are always open drain so there is no risk kill something only signals may be critical so keep wires short as possible.
    // Maxbotix I2CXL series operates with 3.3 and 5 Volt but 5Volt are preferred for best performance and stability.
    //
    // Devantech Ltd. (SRF02, SRF235, SRF08, SRF10):
    // Type; Range; Cycletime; Angle; Comment
    // SRF02; 16 to 600cm; 65ms; 55 degree; automatic calibration, minimum rage can be read from sensor (not implemented)
    // SRF235; 10 - 1200cm; 10ms; 15 degree; angle is may be to small for the use case
    // SRF08; 3 - 600cm; 65ms; 55 degree; range, gain an cycletime can be adjusted, multiple echos are measured (both not implemented)
    // SRF10; 6 - 600cm; 65ms; 72 degree; range, gain an cycletime can be adjusted (not implemented)
    // be sure to adjust settings accordingly, no additional test are done.
    // more details at: http://www.robot-electronics.co.uk/index.html
    //
    // Maxbotix I2CXL (MB1202, MB1212, MB1222, MB1232, MB1242)
    // I"CXL Series of sensors only differentiated by the beam pattern and sensibility. Maxbotix is recommending the MX1242 for quadcopter applications. The interface is always the same
    // NOTE: Maxbotix Sonars only operate with lower I2C speed, so the speed is changed on the fly during Maxbotix readout.
    // Thanks must go to mj666 for implementing that!
    // GENERAL WARNING: DON'T SET snr_min TOO LOW, OTHERWISE THE WRONG SONARVALUE WILL BE TAKEN AS REAL MEASUREMENT!!
    // I implemented some checks to prevent that user error, but still keep that in mind.
    // Min/Max are checked and changed if they are too stupid for your sonar. So if you suddenly see other values, thats not an eeprom error or so.
    // MAXBOTICS: SET snr_min to at least 30! I check this in sensors and change the value, if needed.
    // NOTE: I limited Maxbotics to 7 meters in the code, knowing that some types will do >10m, if you have one of them 7m is still the limit for you.
    // HC-SR04:   SET snr_min to at least 10 ! I check this in sensors and change the value, if needed.
    // DaddyWalross Sonar: I DON'T KNOW! But it uses HC-SR04 so i apply the same limits (10cm-400cm) to its output
    // Sonar minimal hight must be higher (including temperature difference) than the physical lower limit of the sensor to do a proximity alert
    // NOTE: Sonar is def. not a must - have. But nice to have.
    cfg.snr_type                  = 3;          // 0=PWM56 HC-SR04, 1=RC78 HC-SR04, 2=I2C(DaddyWalross), 3=MBPWM56, 4=MBRC78, 5=I2C(SRFxx), 6=I2C (MX12x2)
    cfg.snr_min                   = 30;         // Valid Sonar minimal range in cm (10 - 200) see warning above
    cfg.snr_max                   = 200;        // Valid Sonar maximal range in cm (50 - 700)
    cfg.snr_dbg                   = 0;          // 1 Sends Sonardata (within defined range and tilt) to debug[0] and tiltvalue to debug[1], debug[0] will be -1 if out of range/tilt. debug[2] contains raw sonaralt, like before
    cfg.snr_tilt                  = 18;         // Somehow copter tiltrange in degrees (Not exactly but good enough. Value * 0.9 = realtilt) in wich Sonar is possible
    cfg.snr_cf                    = 0.5f;       // The bigger, the more Sonarinfluence, makes switch between Baro/Sonar smoother and defines baroinfluence when sonarcontact. 1.0f just takes Sonar, if contact (otherwise baro)
    cfg.snr_diff                  = 0;          // 0 disables that check. Range (0-200) Maximal allowed difference in cm between sonar readouts (100ms rate and snr_diff = 50 means max 5m/s)
    cfg.snr_land                  = 1;          // Aided Sonar - landing, by setting upper throttle limit to current throttle. - Beware of Trees!! Can be disabled for Failsafe with fs_nosnr = 1

    cfg.FDUsedDatasets            = 0;          // Default no Datasets stored
    cfg.stat_clear                = 1;          // This will clear the stats between flights, or you can set to 0 and treasue overallstats, but you have to write manually eeprom or have logging enabled
    cfg.sens_1G                   = 1;          // Just feed a dummy "1" to avoid div by zero
    ClearStats();

    for (i = 0; i < MAX_MOTORS; i++) cfg.customMixer[i].throttle = 0.0f;// custom mixer. clear by Dfaults.
    writeParams(0);
}
void DictionaryStats::OutputStats()
{
    if (!dictionaryTypes)
        return;

    EnterCriticalSection(&DictionaryStats::dictionaryTypesCriticalSection);
    DictionaryType* current = dictionaryTypes;
    Output::Print(L"PROFILE DICTIONARY\n");
    Output::Print(L"%8s  %13s  %13s  %13s  %13s  %13s  %13s  %13s  %14s  %14s  %13s  %13s  %13s    %s\n", L"Metric",L"StartSize", L"EndSize", L"Resizes", L"Items", L"MaxDepth", L"EmptyBuckets", L"Lookups", L"Collisions", L"AvgLookupDepth", L"AvgCollDepth", L"MaxLookupDepth", L"Instances", L"Type");
    while(current)
    {
        DictionaryType *type = current;

        DictionaryStats *instance = type->instances;
        double size = 0, max_size = 0;
        double endSize = 0, max_endSize = 0;
        double resizes = 0, max_resizes = 0;
        double items = 0, max_items = 0;
        double depth = 0, max_depth = 0;
        double empty = 0, max_empty = 0;
        double lookups = 0, max_lookups = 0;
        double collisions = 0, max_collisions = 0;
        double avglookupdepth = 0, max_avglookupdepth = 0;
        double avgcollisiondepth = 0, max_avgcollisiondepth = 0;
        double maxlookupdepth = 0, max_maxlookupdepth = 0;

        bool dumpInstances = false;
        //if(strstr(type->name, "SimpleDictionaryPropertyDescriptor") != nullptr)
        //{
        //    dumpInstances = true;
        //}
        while(instance)
        {
            ComputeStats(instance->initialSize, size, max_size);
            ComputeStats(instance->finalSize, endSize, max_endSize);
            ComputeStats(instance->countOfResize, resizes, max_resizes);
            ComputeStats(instance->itemCount, items, max_items);
            ComputeStats(instance->maxDepth, depth, max_depth);
            ComputeStats(instance->countOfEmptyBuckets, empty, max_empty);
            ComputeStats(instance->lookupCount, lookups, max_lookups);
            ComputeStats(instance->collisionCount, collisions, max_collisions);
            if (instance->lookupCount > 0)
            {
                ComputeStats((double)instance->lookupDepthTotal / (double)instance->lookupCount, avglookupdepth, max_avglookupdepth);
            }
            if (instance->collisionCount > 0)
            {
                ComputeStats((double)instance->lookupDepthTotal / (double)instance->collisionCount, avgcollisiondepth, max_avgcollisiondepth);
            }
            ComputeStats(instance->maxLookupDepth, maxlookupdepth, max_maxlookupdepth);

            if(dumpInstances)
            {
                double avgld = 0.0;
                double avgcd = 0.0;
                if (instance->lookupCount > 0)
                {
                    avgld = (double)instance->lookupDepthTotal / (double)instance->lookupCount;
                    avgcd = (double)instance->lookupDepthTotal / (double)instance->collisionCount;
                }
                Output::Print(L"%8s  %13d  %13d  %13d  %13d  %13d  %13d  %13d  %14d  %14.2f  %13.2f  %13d \n",
                    L"INS:",
                    instance->initialSize, instance->finalSize, instance->countOfResize,
                    instance->itemCount, instance->maxDepth, instance->countOfEmptyBuckets,
                    instance->lookupCount, instance->collisionCount, avgld, avgcd,
                    instance->maxLookupDepth);
            }
            instance = instance->pNext;
        }

        if (max_depth >= Js::Configuration::Global.flags.ProfileDictionary)
        {
            Output::Print(L"%8s  %13.0f  %13.0f  %13.2f  %13.0f  %13.2f  %13.0f  %13.0f  %14.0f  %14.2f  %13.2f  %13.2f  %13d    %S\n", L"AVG:",
                size/type->instancesCount, endSize/type->instancesCount, resizes/type->instancesCount, items/type->instancesCount,
                depth/type->instancesCount, empty/type->instancesCount, lookups/type->instancesCount, collisions/type->instancesCount,
                avglookupdepth/type->instancesCount, avgcollisiondepth/type->instancesCount, maxlookupdepth/type->instancesCount, type->instancesCount, type->name);
            Output::Print(L"%8s  %13.0f  %13.0f  %13.2f  %13.0f  %13.2f  %13.0f  %13.0f  %14.0f  %14.2f  %13.2f  %13.2f  %13d    %S\n\n", L"MAX:",
                max_size, max_endSize, max_resizes, max_items, max_depth, max_empty, max_lookups, max_collisions, max_avglookupdepth,
                max_avgcollisiondepth, max_maxlookupdepth, type->instancesCount, type->name);

        }
        current = current->pNext;
    }
    Output::Print(L"====================================================================================\n");
    ClearStats();
    LeaveCriticalSection(&DictionaryStats::dictionaryTypesCriticalSection);
    DeleteCriticalSection(&DictionaryStats::dictionaryTypesCriticalSection);
}
Beispiel #9
0
/******************************************************************************
**   Main Function  main()
******************************************************************************/
int main (void)
{
#if !(BURST_MODE || SINGLE_BURST_MODE)
  uint32_t i;
#endif
  
  SystemCoreClockUpdate();

#if ADC_DEBUG  
  /* NVIC is installed inside UARTInit file. */
  UARTInit(9600);
#endif
  ClearStats();

  /* Initialize ADC  */
  ADCInit( ADC_CLK );

  while ( 1 )
  {
#if (BURST_MODE	|| SINGLE_BURST_MODE)				/* Interrupt driven only */
  	/* Burst mode */
  	ADCBurstRead();
  	while ( !ADCIntDone );
  	ADCIntDone = 0;
  	if ( OverRunCounter != 0 )
  	{
  	  while ( 1 );
  	}
  	ADCConversionBurstCounter++;
  	UpdateStats();
#else
  	/* uncomment this block to read from all ADC channels*/
	// Non burst mode, get ADC from all channels.
  	for ( i = 0; i < ADC_NUM; i++ ) 
  	{
#if ADC_INTERRUPT_FLAG				/* Interrupt driven */
  	  ADCRead( i );
  	  while ( !ADCIntDone );
  	  ADCIntDone = 0;
  	  if ( OverRunCounter != 0 )
    	while ( 1 );

#else
	    ADCValue[i] = ADCRead( i );	/* Polling */
#endif
	    ADCConversionCounter++;
	  }
    UpdateStats();
#endif

#if ADC_DEBUG
    if (DebugUpdateCounter++ >= ADC_DEBUG_UPDATE_CNT)
    {
      if (ClearCounter-- < 0)
      {
        ClearStats();
        ClearCounter = ADC_DEBUG_CLEAR_CNT;
      }
      PrintoutADCValue();
      DebugUpdateCounter = 0;
    }
#endif
  }
}
Beispiel #10
0
// Default settings
static void resetConf(void)
{
    uint8_t i;
    const int8_t default_align[3][3] = { /* GYRO */ { 0, 0, 0 }, /* ACC */ { 0, 0, 0 }, /* MAG */ { -2, -3, 1 } };
    memset(&cfg, 0, sizeof(config_t));

    cfg.version = EEPROM_CONF_VERSION;
    cfg.mixerConfiguration = MULTITYPE_QUADX;
    featureClearAll();
//    featureSet(FEATURE_VBAT);
    featureSet(FEATURE_PPM);
//    featureSet(FEATURE_FAILSAFE);
//    featureSet(FEATURE_LCD);
//    featureSet(FEATURE_GPS);
//    featureSet(FEATURE_PASS);                   // Just pass Throttlechannel
//    featureSet(FEATURE_SONAR);

    cfg.P8[ROLL]                  = 35;         // 40
    cfg.I8[ROLL]                  = 20;
    cfg.D8[ROLL]                  = 30;

    cfg.P8[PITCH]                 = 35;         // 40
    cfg.I8[PITCH]                 = 20;
    cfg.D8[PITCH]                 = 30;

    cfg.P8[YAW]                   = 60;         // 70
    cfg.I8[YAW]                   = 45;

    cfg.P8[PIDALT]                = 100;
    cfg.I8[PIDALT]                = 30;
    cfg.D8[PIDALT]                = 80;

    cfg.P8[PIDPOS]                = 10;         // FIND YOUR VALUE
    cfg.I8[PIDPOS]                =  0;         // NOT USED
    cfg.D8[PIDPOS]                =  0;         // NOT USED

    cfg.P8[PIDPOSR]               = 50;         // FIND YOUR VALUE                    // Controls the speed part with my PH logic
    cfg.I8[PIDPOSR]               =  0;         // 25;  // DANGER "I" may lead to circeling   // Controls the speed part with my PH logic
    cfg.D8[PIDPOSR]               = 40;         // FIND YOUR VALUE                    // Controls the speed part with my PH logic

    cfg.P8[PIDNAVR]               = 15;         // 14 More ?
    cfg.I8[PIDNAVR]               =  0;         // NAV_I * 100;                       // Scaling/Purpose unchanged
    cfg.D8[PIDNAVR]               =  0;         // NAV_D * 1000;                      // Scaling/Purpose unchanged

//    cfg.P8[PIDPOS]                = 11;         // APM PH Stock values
//    cfg.I8[PIDPOS]                = 0;
//    cfg.D8[PIDPOS]                = 0;

//    cfg.P8[PIDPOSR]               = 20;         // POSHOLD_RATE_P * 10;
//    cfg.I8[PIDPOSR]               = 8;          // POSHOLD_RATE_I * 100;
//    cfg.D8[PIDPOSR]               = 45;         // POSHOLD_RATE_D * 1000;

//    cfg.P8[PIDNAVR]               = 14;         // NAV_P * 10;
//    cfg.I8[PIDNAVR]               = 20;         // NAV_I * 100;
//    cfg.D8[PIDNAVR]               = 80;         // NAV_D * 1000;

    cfg.P8[PIDLEVEL]              = 60;         // 70
    cfg.I8[PIDLEVEL]              = 10;
    cfg.D8[PIDLEVEL]              = 50;

    cfg.P8[PIDMAG]                = 80;         // cfg.P8[PIDVEL] = 0;// cfg.I8[PIDVEL] = 0;// cfg.D8[PIDVEL] = 0;

    cfg.rcRate8                   = 100;
    cfg.rcExpo8                   = 80;         // cfg.rollPitchRate = 0;// cfg.yawRate = 0;// cfg.dynThrPID = 0;
    cfg.thrMid8                   = 50;
    // cfg.thrExpo8 = 0;//for (i = 0; i < CHECKBOXITEMS; i++)//cfg.activate[i] = 0;
    // cfg.angleTrim[0] = 0;// cfg.angleTrim[1] = 0;// cfg.accZero[0] = 0;// cfg.accZero[1] = 0;
    // cfg.accZero[2] = 0;// cfg.mag_declination = 0;    // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero.
    memcpy(&cfg.align, default_align, sizeof(cfg.align));

//    cfg.mag_declination           = 0;          // For example, -6deg 37min, = -637 Japan, format is [sign]dddmm (degreesminutes) default is zero.
    cfg.mag_declination           = 107;        // Crashpilot //cfg.acc_hardware = ACC_DEFAULT;// default/autodetect
    cfg.mag_oldcalib              = 0;          // 1 = old hard iron calibration // 0 = extended calibration (better)
    cfg.mag_oldctime              = 1;          // 1 - 5 Time in MINUTES for old calibration. Use this together with mag_oldcalib = 1 if you have a monster of a copter
    cfg.acc_hardware              = 2;          // Crashpilot MPU6050
    cfg.acc_lpf_factor            = 100;	      // changed 27.11.2012
    cfg.acc_ins_lpf               = 10;         // General LPF for all INS stuff

    cfg.looptime                  = 3000;	      // changed 27.11.2012 //    cfg.acc_lpf_factor = 4;
    cfg.mainpidctrl               = 1;          // 1 = OriginalMwiiPid pimped by me, 2 = New mwii controller (experimental, float pimped + pt1)
    cfg.mainpt1cut                = 15;         // (0-50Hz) 0 Disables pt1element. Cuf Off Frequency for pt1 element D term in Hz of main Pid controller
    cfg.newpidimax                = 256;        // [10-65000) 256 Default. Imax of new Pidcontroller
    cfg.gpspt1cut                 = 10;         // (1-50Hz) Cuf Off Frequency for D term in Hz of GPS Pid controller 
    cfg.gyro_cmpf_factor          = 1000;       // (10-1000) 400 default. Now 1000. The higher, the more weight gets the gyro and the lower is the correction with Acc data.
    cfg.gyro_cmpfm_factor         = 1000;       // (10-2000) 200 default for 10Hz. Now 1000 for 70Hz seems ok. Gyro/Magnetometer Complement. Greater Value means more filter on mag/delay
    
    cfg.gyro_lpf                  = 42;         // Possible values 256 188 98 42 20 10 (HZ)

    // Baro
    cfg.accz_vel_cf               = 0.985f;     // Crashpilot: Value for complementary filter accz and barovelocity
    cfg.accz_alt_cf               = 0.940f;     // Crashpilot: Value for complementary filter accz and altitude
    cfg.baro_lag                  = 0.3f;       // Lag of Baro/Althold stuff in general, makes stop in hightchange snappier
    cfg.barodownscale             = 0.7f;       // Scale downmovement down (because copter drops faster than rising)

    // Autoland
    cfg.al_barolr                 = 75;         // Temporary value "64" increase to increase Landingspeed
    cfg.al_snrlr                  = 75;         // You can specify different landingfactor here on sonar contact, because sonar land maybe too fast when snr_cf is high
    cfg.al_lndthr                 = 0;          // This is the absolute throttle that kicks off the "has landed timer" if it is too low cfg.minthrottle is taken.
    cfg.al_debounce               = 5;          // (0-20%) 0 Disables. Defines a Throttlelimiter on Autoland. Percentage defines the maximum deviation of assumed hoverthrottle during Autoland
    cfg.al_tobaro                 = 2000;       // Timeout in ms (100 - 5000) before shutoff on autoland. "al_lndthr" must be undershot for that timeperiod
    cfg.al_tosnr                  = 1000;       // Timeout in ms (100 - 5000) If sonar aided land is wanted (snr_land = 1) you can choose a different timeout here

    cfg.baro_debug                = 0;          // Crashpilot: 1 = Debug Barovalues //cfg.baro_noise_lpf = 0.6f;// Crashpilot: Not used anymore//cfg.baro_cf = 0.985f;// Crashpilot: Not used anymore
    cfg.moron_threshold           = 32;
    cfg.gyro_smoothing_factor     = 0x00141403; // default factors of 20, 20, 3 for R/P/Y
    cfg.vbatscale                 = 110;
    cfg.vbatmaxcellvoltage        = 43;
    cfg.vbatmincellvoltage        = 33;
    cfg.power_adc_channel         = 0;

    // Radio
    parseRcChannels("AETR1234");
    cfg.deadband                  = 15;         // Crashpilot: A little deadband will not harm our crappy RC
    cfg.yawdeadband               = 15;         // Crashpilot: A little deadband will not harm our crappy RC
    cfg.alt_hold_throttle_neutral = 50;         // Crashpilot: A little deadband will not harm our crappy RC
    cfg.gps_adddb                 = 5;          // Additional Deadband for all GPS functions;

    // cfg.spektrum_hires = 0;
    cfg.midrc                     = 1500;
    cfg.mincheck                  = 1100;
    cfg.maxcheck                  = 1900;
    cfg.retarded_arm              = 0;          // disable arm/disarm on roll left/right
    cfg.auxChannels               = 4;          // [4 - 10] cGiesen: Default = 4, then like the standard!
    cfg.killswitchtime            = 0;          // Time in ms when your arm switch becomes a Killswitch, 0 disables the Killswitch, can not be used together with FEATURE_INFLIGHT_ACC_CAL

    // Motor/ESC/Servo
    cfg.minthrottle               = 1150;       // ORIG
//    cfg.minthrottle               = 1100;
    cfg.maxthrottle               = 1950;
    cfg.passmotor                 = 0;          // Crashpilot: Only used with feature pass. If 0 = all Motors, otherwise specific Motor
    cfg.mincommand                = 1000;
    cfg.motor_pwm_rate            = 400;
    cfg.servo_pwm_rate            = 50;

    // servos
    cfg.yaw_direction             = 1;
    cfg.tri_yaw_middle            = 1500;
    cfg.tri_yaw_min               = 1020;
    cfg.tri_yaw_max               = 2000;

    // flying wing
    cfg.wing_left_min             = 1020;
    cfg.wing_left_mid             = 1500;
    cfg.wing_left_max             = 2000;
    cfg.wing_right_min            = 1020;
    cfg.wing_right_mid            = 1500;
    cfg.wing_right_max            = 2000;
    cfg.pitch_direction_l         = 1;
    cfg.pitch_direction_r         = -1;
    cfg.roll_direction_l          = 1;
    cfg.roll_direction_r          = 1;

    // gimbal
    cfg.gimbal_pitch_gain         = 10;
    cfg.gimbal_roll_gain          = 10;
    cfg.gimbal_flags              = GIMBAL_NORMAL;
    cfg.gimbal_pitch_min          = 1020;
    cfg.gimbal_pitch_max          = 2000;
    cfg.gimbal_pitch_mid          = 1500;
    cfg.gimbal_roll_min           = 1020;
    cfg.gimbal_roll_max           = 2000;
    cfg.gimbal_roll_mid           = 1500;

    // gps/nav
    cfg.gps_type                  = 1;          // GPS_NMEA = 0, GPS_UBLOX = 1, GPS_MTK16 = 2, GPS_MTK19 = 3, GPS_UBLOX_DUMB = 4
    cfg.gps_baudrate              = 115200;     //38400; // Changed 8/6/13 to 115200;
//    cfg.gps_baudrate              = 38400;      //38400; // Changed 8/6/13 to 115200;
//    cfg.gps_ins_vel               = 0.72f;      // Crashpilot GPS INS The LOWER the value the closer to gps speed // Dont go to high here
    cfg.gps_ins_vel               = 0.6f;       // Crashpilot GPS INS The LOWER the value the closer to gps speed // Dont go to high here
    cfg.gps_ins_mdl               = 1;          // NOTE: KEEP THIS TO "1" FOR NOW because other models work like shit currently. GPS ins model. 1 = Based on lat/lon, 2 = based on Groundcourse & speed,(3 = based on ublx velned deleted)
    cfg.gps_lag                   = 2000;       // GPS Lag in ms
    cfg.gps_phase                 = 0;          // +- 30 Degree Make a phaseshift of GPS output for whatever reason you might want that (frametype etc)
    cfg.gps_ph_minsat             = 6;          // Minimal Satcount for PH, PH on RTL is still done with 5Sats or more
    cfg.gps_ph_settlespeed        = 10;         // 1 - 200 cm/s PH settlespeed in cm/s
    cfg.gps_ph_brakemaxangle      = 10;         // 1 - 45 Degree Maximal 5 Degree Overspeedbrake
    cfg.gps_ph_minbrakepercent    = 50;         // 1 - 99% minimal percent of "brakemaxangle" left over for braking. Example brakemaxangle = 6 so 50 Percent is 3..
    cfg.gps_ph_brkacc             = 40;         // [1 - 500] Is the assumed negative braking acceleration in cm/(s*s) of copter. Value is positive though. It will be a timeout. The lower the Value the longe the Timeout
    cfg.gps_ph_abstub             = 100;        // 0 - 1000cm (300 Dfault, 0 disables) Defines the "bath tub" around current absolute PH Position, where PosP is diminished, reaction gets harder on tubs edge and then goes on linear
    cfg.gps_maxangle              = 25;         // 10 - 45 Degree Maximal over all GPS bank angle
    cfg.gps_wp_radius             = 150;
//    cfg.gps_rtl_minhight          = 20;         // (0 - 200) Minimal RTL hight in m, 0 disables feature
	  cfg.gps_rtl_minhight          = 0;          // (0 - 200) Minimal RTL hight in m, 0 disables feature
    cfg.gps_rtl_mindist           = 0;          // 0 Disables. Minimal distance for RTL in m, otherwise it will just autoland, prevent Failsafe jump in your face, when arming copter and turning off TX
    cfg.gps_rtl_flyaway           = 0;          // 0 Disables. If during RTL the distance increases beyond this value (in meters relative to RTL activation point), something is wrong, autoland
    cfg.gps_yaw                   = 30;         // Thats the MAG P during GPS functions, substitute for "cfg.P8[PIDMAG]"
    cfg.nav_rtl_lastturn          = 1;          // 1 = when copter gets to home position it rotates it's head to takeoff direction independend of nav_controls_heading
//    cfg.nav_slew_rate             = 30;         // was 30 and 50 before
    cfg.nav_slew_rate             = 20;         // was 30 and 50 before
    cfg.nav_tail_first            = 0;          // 1 = Copter comes back with ass first (only works with nav_controls_heading = 1)
    cfg.nav_controls_heading      = 0;          // 1 = Nav controls YAW during WP ONLY
//    cfg.nav_controls_heading      = 1;          // 1 = Nav controls YAW during WP ONLY
    cfg.nav_speed_min             = 100;        // 10 - 200 cm/s don't set higher than nav_speed_max! That dumbness is not covered.
    cfg.nav_speed_max             = 350;        // 50 - 2000 cm/s don't set lower than nav_speed_min! That dumbness is not covered.
    cfg.nav_approachdiv           = 3;          // 2 - 10 This is the divisor for approach speed for wp_distance. Example: 400cm / 3 = 133cm/s if below nav_speed_min it will be adjusted
    cfg.nav_tiltcomp              = 20;         // 0 - 100 (20 TestDefault) Only arducopter really knows. Dfault was 54. This is some kind of a hack of them to reach actual nav_speed_max. 54 was Dfault, 0 disables
    cfg.nav_ctrkgain              = 0.5f;       // 0 - 10.0 (0.5 TestDefault) (Floatvariable) That is the "Crosstrackgain" APM Dfault is "1". "0" disables

    // Failsafe Variables
    cfg.failsafe_delay            = 10;         // in 0.1s (10 = 1sec)
    cfg.failsafe_off_delay        = 200;        // in 0.1s (200 = 20sec)
    cfg.failsafe_throttle         = 1200;       // decent Dfault which should always be below hover throttle for people.
    cfg.failsafe_deadpilot        = 0;		      // DONT USE, EXPERIMENTAL Time in sec when FS is engaged after idle on THR/YAW/ROLL/PITCH, 0 disables max 250
    cfg.failsafe_justph           = 0;          // Does just PH&Autoland an not RTL, use this in difficult areas with many obstacles to avoid RTL crash into something
    cfg.failsafe_ignoreSNR        = 1;          // When snr_land is set to 1, it is possible to ignore that on Failsafe, because FS over a tree could turn off copter

    // serial (USART1) baudrate
    cfg.serial_baudrate           = 115200;
    cfg.tele_prot                 = 0;          // Protocol ONLY used when Armed including Baudchange if necessary. 0 (Dfault)=Keep Multiwii @CurrentUSB Baud, 1=Frsky @9600Baud, 2=Mavlink @CurrentUSB Baud, 3=Mavlink @57KBaud (like stock minimOSD wants it)

    // LED Stuff
    cfg.LED_invert                = 0;          // Crashpilot: Inversion of LED 0&1 Partly implemented because Bootup is not affected
    cfg.LED_Type                  = 1;		      // 1=MWCRGB / 2=MONO_LED / 3=LEDRing
    cfg.LED_Pinout                = 1;		      // rc6
    cfg.LED_ControlChannel        = 8;		      // AUX4 (Channel 8)
    cfg.LED_Armed                 = 0;		      // 0 = Show LED only if armed, 1 = always show LED
    cfg.LED_Pattern1			        = 1300; 		  // 32bit bit pattern to have flickering led patterns / the pattern for MWCRGB 1000-2000
    cfg.LED_Pattern2			        = 1800; 		  // 32bit bit pattern to have flickering led patterns / the pattern for MWCRGB 1000-2000
    cfg.LED_Pattern3			        = 1900; 		  // 32bit bit pattern to have flickering led patterns / the pattern for MWCRGB 1000-2000
    cfg.LED_Toggle_Delay1         = 0x08;       // slow down LED_Pattern
    cfg.LED_Toggle_Delay2         = 0x08;       // slow down LED_Pattern
    cfg.LED_Toggle_Delay3         = 0x08;       // slow down LED_Pattern

    // SONAR

    // SOME INFO ON SONAR:
    // PWM56 are 5V resistant, RC78 only tolerate 3.3V(!!) so add a 1K Ohms resistor!!!
    // Note: You will never see the maximum possible sonar range in a copter, so go for the half of it (or less?)
    //
    // Connection possibilities depending on Receivertype:
    // PPSUM: RC78 possible, PWM56 possible (on max. quadcopters, see below)
    // Normal RX: Just Connection on Motorchannel 5&6 (PWM56) is possible.
    // The PWM56 sonar connection option is only available in setups with max motors 4, otherwise sonar is not initialized.
    //
    // HC-SR04:
    // Operation Voltage: 5V (!! Use PWM56 or 1K resistor !!)
    // Range: 2cm - 400cm
    // Angle: 15 Degrees (Test out for yourself: cfg.snr_tilt = X)
    //
    // Maxbotics in general
    // Operation Voltage: (some 2.5V)3.3V - 5V ((!! Use PWM56 or resistor with 5V !!)
    // Only wire the Maxbotics for PWM output (more precise anyway), not the analog etc. modes, just wire echopin (normally pin 2)
    // Range: 20cm(!) - 765cm (some >1000cm), MaxTiltAngle is not specified, depending on Model
    // Tested on MB1200 XL-MaxSonar-EZ0
    //
    // GENERAL WARNING: DON'T SET snr_min TOO LOW, OTHERWISE THE WRONG SONARVALUE WILL BE TAKEN AS REAL MEASUREMENT!!
    // I implemented some checks to prevent that user error, but still keep that in mind.
    // Min/Max are checked and changed if they are too stupid for your sonar. So if you suddenly see other values, thats not an eeprom error or so.
    // MAXBOTICS: SET snr_min to at least 25! I check this in sensors and change the value, if needed.
    // NOTE: I limited Maxbotics to 7 meters in the code, knowing that some types will do >10m, if you have one of them 7m is still the limit for you.
    // HC-SR04:   SET snr_min to at least 5 ! I check this in sensors and change the value, if needed.
    // DaddyWalross Sonar: I DON'T KNOW! But it uses HC-SR04 so i apply the same limits (5cm-400cm) to its output
    // NOTE: Sonar is def. not a must - have. But nice to have.
    cfg.snr_type                  = 3;          // 0 = PWM56 HC-SR04, 1 = RC78 HC-SR04, 2 = I2C (DaddyWalross), 3 = MBPWM56, 4 = MBRC78
    cfg.snr_min                   = 25;         // Valid Sonar minimal range in cm (5-200) see warning above
    cfg.snr_max                   = 200;        // Valid Sonar maximal range in cm (50-700)
    cfg.snr_debug                 = 0;          // 1 Sends Sonardata (within defined range and tilt) to debug[0] and tiltvalue to debug[1], debug[0] will be -1 if out of range/tilt. debug[2] contains raw sonaralt, like before
    cfg.snr_tilt                  = 18;         // Somehow copter tiltrange in degrees (Not exactly but good enough. Value * 0.9 = realtilt) in wich Sonar is possible
    cfg.snr_cf                    = 0.7f;       // The bigger, the more Sonarinfluence, makes switch between Baro/Sonar smoother and defines baroinfluence when sonarcontact. 1.0f just takes Sonar, if contact (otherwise baro)
    cfg.snr_diff                  = 0;          // 0 disables that check. Range (0-200) Maximal allowed difference in cm between sonar readouts (100ms rate and snr_diff = 50 means max 5m/s)
    cfg.snr_land                  = 1;          // Aided Sonar - landing, by setting upper throttle limit to current throttle. - Beware of Trees!! Can be disabled for Failsafe with failsafe_ignoreSNR = 1

    // LOGGING
    cfg.floppy_mode               = FD_MODE_GPSLOGGER; // Usagemode of free Space. 1 = GPS Logger
    cfg.FDUsedDatasets            = 0;          // Default no Datasets stored
    cfg.stat_clear                = 1;          // This will clear the stats between flights, or you can set to 0 and treasue overallstats, but you have to write manually eeprom or have logging enabled
    cfg.sens_1G                   = 1;          // Just feed a dummy "1" to avoid div by zero
    ClearStats();
    // custom mixer. clear by Dfaults.
    for (i = 0; i < MAX_MOTORS; i++) cfg.customMixer[i].throttle = 0.0f;
    writeParams(0);
}