Esempio n. 1
0
        public void Activate()
        {
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                Enabled = false;
                return;
            }
            if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduCopter2)
            {
                Enabled = true;
            }
            else
            {
                Enabled = false;
                return;
            }

            startup = true;

            changes.Clear();

            // ensure the fields are populated before setting them
            TUNE.setup(
                ParameterMetaDataRepository.GetParameterOptionsInt("TUNE", MainV2.comPort.MAV.cs.firmware.ToString())
                .ToList(), "TUNE", MainV2.comPort.MAV.param);

            CH7_OPTION.setup(new[] { "CH7_OPT", "CH7_OPTION", "RC7_OPTION" }, MainV2.comPort.MAV.param);
            CH8_OPTION.setup(new[] { "CH8_OPT", "CH8_OPTION", "RC8_OPTION" }, MainV2.comPort.MAV.param);
            CH9_OPTION.setup(new[] { "CH9_OPT", "CH9_OPTION", "RC9_OPTION" }, MainV2.comPort.MAV.param);
            CH10_OPTION.setup(new[] { "CH10_OPT", "CH10_OPTION", "RC10_OPTION" }, MainV2.comPort.MAV.param);

            TUNE_LOW.setup(0, 10000, 1000, 0.01f, new[] { "TUNE_LOW", "TUNE_MIN" }, MainV2.comPort.MAV.param);
            TUNE_HIGH.setup(0, 10000, 1000, 0.01f, new[] { "TUNE_HIGH", "TUNE_MIN" }, MainV2.comPort.MAV.param);

            HLD_LAT_P.setup(0, 0, 1, 0.001f, new[] { "HLD_LAT_P", "POS_XY_P", "PSC_POSXY_P" }, MainV2.comPort.MAV.param);
            LOITER_LAT_D.setup(0, 0, 1, 0.001f, new[] { "LOITER_LAT_D", "PSC_VELXY_D" }, MainV2.comPort.MAV.param);
            LOITER_LAT_I.setup(0, 0, 1, 0.001f, new[] { "LOITER_LAT_I", "VEL_XY_I", "PSC_VELXY_I" }, MainV2.comPort.MAV.param);
            LOITER_LAT_IMAX.setup(0, 0, 10, 1f, new[] { "LOITER_LAT_IMAX", "VEL_XY_IMAX", "PSC_VELXY_IMAX" }, MainV2.comPort.MAV.param);
            LOITER_LAT_P.setup(0, 0, 1, 0.001f, new[] { "LOITER_LAT_P", "VEL_XY_P", "PSC_VELXY_P" }, MainV2.comPort.MAV.param);

            RATE_PIT_D.setup(0, 0, 1, 0.001f, new[] { "RATE_PIT_D", "ATC_RAT_PIT_D" }, MainV2.comPort.MAV.param);
            RATE_PIT_I.setup(0, 0, 1, 0.001f, new[] { "RATE_PIT_I", "ATC_RAT_PIT_I" }, MainV2.comPort.MAV.param);
            if (MainV2.comPort.MAV.param.ContainsKey("ATC_RAT_PIT_IMAX")) // 3.4 changes scaling
            {
                RATE_PIT_IMAX.setup(0, 0, 1, 1f, new[] { "ATC_RAT_PIT_IMAX" }, MainV2.comPort.MAV.param);
            }
            else
            {
                RATE_PIT_IMAX.setup(0, 0, 10, 1f, new[] { "RATE_PIT_IMAX" }, MainV2.comPort.MAV.param);
            }
            RATE_PIT_P.setup(0, 0, 1, 0.001f, new[] { "RATE_PIT_P", "ATC_RAT_PIT_P" }, MainV2.comPort.MAV.param);
            RATE_PIT_FILT.setup(0, 0, 1, 0.001f, new[] { "RATE_PIT_FILT", "ATC_RAT_PIT_FILT", "ATC_RAT_PIT_FLTE" }, MainV2.comPort.MAV.param);

            RATE_RLL_D.setup(0, 0, 1, 0.001f, new[] { "RATE_RLL_D", "ATC_RAT_RLL_D" }, MainV2.comPort.MAV.param);
            RATE_RLL_I.setup(0, 0, 1, 0.001f, new[] { "RATE_RLL_I", "ATC_RAT_RLL_I" }, MainV2.comPort.MAV.param);
            if (MainV2.comPort.MAV.param.ContainsKey("ATC_RAT_RLL_IMAX")) // 3.4 changes scaling
            {
                RATE_RLL_IMAX.setup(0, 0, 1, 1f, new[] { "ATC_RAT_RLL_IMAX" }, MainV2.comPort.MAV.param);
            }
            else
            {
                RATE_RLL_IMAX.setup(0, 0, 10, 1f, new[] { "RATE_RLL_IMAX" }, MainV2.comPort.MAV.param);
            }
            RATE_RLL_P.setup(0, 0, 1, 0.001f, new[] { "RATE_RLL_P", "ATC_RAT_RLL_P" }, MainV2.comPort.MAV.param);
            RATE_RLL_FILT.setup(0, 0, 1, 0.001f, new[] { "RATE_RLL_FILT", "ATC_RAT_RLL_FILT", "ATC_RAT_RLL_FLTE" }, MainV2.comPort.MAV.param);

            RATE_YAW_D.setup(0, 0, 1, 0.001f, new[] { "RATE_YAW_D", "ATC_RAT_YAW_D" }, MainV2.comPort.MAV.param);
            RATE_YAW_I.setup(0, 0, 1, 0.001f, new[] { "RATE_YAW_I", "ATC_RAT_YAW_I" }, MainV2.comPort.MAV.param);
            if (MainV2.comPort.MAV.param.ContainsKey("ATC_RAT_YAW_IMAX")) // 3.4 changes scaling
            {
                RATE_YAW_IMAX.setup(0, 0, 1, 1f, new[] { "ATC_RAT_YAW_IMAX" }, MainV2.comPort.MAV.param);
            }
            else
            {
                RATE_YAW_IMAX.setup(0, 0, 10, 1f, new[] { "RATE_YAW_IMAX" }, MainV2.comPort.MAV.param);
            }
            RATE_YAW_P.setup(0, 0, 1, 0.001f, new[] { "RATE_YAW_P", "ATC_RAT_YAW_P" }, MainV2.comPort.MAV.param);
            RATE_YAW_FILT.setup(0, 0, 1, 0.001f, new[] { "RATE_YAW_FILT", "ATC_RAT_YAW_FILT", "ATC_RAT_YAW_FLTE" }, MainV2.comPort.MAV.param);

            STB_PIT_P.setup(0, 0, 1, 0.001f, new[] { "STB_PIT_P", "ATC_ANG_PIT_P" }, MainV2.comPort.MAV.param);
            STB_RLL_P.setup(0, 0, 1, 0.001f, new[] { "STB_RLL_P", "ATC_ANG_RLL_P" }, MainV2.comPort.MAV.param);
            STB_YAW_P.setup(0, 0, 1, 0.001f, new[] { "STB_YAW_P", "ATC_ANG_YAW_P" }, MainV2.comPort.MAV.param);

            THR_ACCEL_D.setup(0, 0, 1, 0.001f, new[] { "THR_ACCEL_D", "ACCEL_Z_D", "PSC_ACCZ_D" }, MainV2.comPort.MAV.param);
            THR_ACCEL_I.setup(0, 0, 1, 0.001f, new[] { "THR_ACCEL_I", "ACCEL_Z_I", "PSC_ACCZ_I" }, MainV2.comPort.MAV.param);
            THR_ACCEL_IMAX.setup(0, 0, 10, 1f, new[] { "THR_ACCEL_IMAX", "ACCEL_Z_IMAX", "PSC_ACCZ_IMAX" }, MainV2.comPort.MAV.param);
            THR_ACCEL_P.setup(0, 0, 1, 0.001f, new[] { "THR_ACCEL_P", "ACCEL_Z_P", "PSC_ACCZ_P" }, MainV2.comPort.MAV.param);
            THR_ALT_P.setup(0, 0, 1, 0.001f, new[] { "THR_ALT_P", "POS_Z_P", "PSC_POSZ_P" }, MainV2.comPort.MAV.param);
            THR_RATE_P.setup(0, 0, 1, 0.001f, new[] { "THR_RATE_P", "VEL_Z_P", "PSC_VELZ_P" }, MainV2.comPort.MAV.param);

            WPNAV_LOIT_SPEED.setup(0, 0, 1, 0.001f, new[] { "WPNAV_LOIT_SPEED", "LOIT_SPEED" }, MainV2.comPort.MAV.param);
            WPNAV_RADIUS.setup(0, 0, 1, 0.001f, "WPNAV_RADIUS", MainV2.comPort.MAV.param);
            WPNAV_SPEED.setup(0, 0, 1, 0.001f, "WPNAV_SPEED", MainV2.comPort.MAV.param);
            WPNAV_SPEED_DN.setup(0, 0, 1, 0.001f, "WPNAV_SPEED_DN", MainV2.comPort.MAV.param);
            WPNAV_SPEED_UP.setup(0, 0, 1, 0.001f, "WPNAV_SPEED_UP", MainV2.comPort.MAV.param);

            mavlinkNumericUpDownatc_accel_r_max.setup(0, 0, 1, 0.001f, "ATC_ACCEL_R_MAX", MainV2.comPort.MAV.param);
            mavlinkNumericUpDownatc_accel_p_max.setup(0, 0, 1, 0.001f, "ATC_ACCEL_P_MAX", MainV2.comPort.MAV.param);
            mavlinkNumericUpDownatc_accel_y_max.setup(0, 0, 1, 0.001f, "ATC_ACCEL_Y_MAX", MainV2.comPort.MAV.param);
            mavlinkNumericUpDownatc_input_tc.setup(0, 0, 1, 0.001f, "ATC_INPUT_TC", MainV2.comPort.MAV.param);

            // unlock entries if they differ
            if (RATE_RLL_P.Value != RATE_PIT_P.Value || RATE_RLL_I.Value != RATE_PIT_I.Value ||
                RATE_RLL_D.Value != RATE_PIT_D.Value || RATE_RLL_IMAX.Value != RATE_PIT_IMAX.Value)
            {
                CHK_lockrollpitch.Checked = false;
            }

            if (MainV2.comPort.MAV.param["H_SWASH_TYPE"] != null)
            {
                CHK_lockrollpitch.Checked = false;
            }

            // add tooltips to all controls
            foreach (Control control1 in Controls)
            {
                foreach (Control control2 in control1.Controls)
                {
                    if (control2 is MavlinkNumericUpDown)
                    {
                        var ParamName = ((MavlinkNumericUpDown)control2).ParamName;
                        toolTip1.SetToolTip(control2,
                                            ParameterMetaDataRepository.GetParameterMetaData(ParamName,
                                                                                             ParameterMetaDataConstants.Description, MainV2.comPort.MAV.cs.firmware.ToString()));
                    }
                    if (control2 is MavlinkComboBox)
                    {
                        var ParamName = ((MavlinkComboBox)control2).ParamName;
                        toolTip1.SetToolTip(control2,
                                            ParameterMetaDataRepository.GetParameterMetaData(ParamName,
                                                                                             ParameterMetaDataConstants.Description, MainV2.comPort.MAV.cs.firmware.ToString()));
                    }
                }
            }

            startup = false;
        }
Esempio n. 2
0
        public void Activate()
        {
            if (!MainV2.comPort.BaseStream.IsOpen)
            {
                Enabled = false;
                return;
            }
            if (MainV2.comPort.MAV.cs.firmware == Firmwares.ArduRover)
            {
                Enabled = true;
            }
            else
            {
                Enabled = false;
                return;
            }

            startup = true;

            CH7_OPTION.setup(new[] { "CH7_OPTION", "RC7_OPTION" }, MainV2.comPort.MAV.param);
            CH8_OPTION.setup(new[] { "CH8_OPTION", "RC8_OPTION" }, MainV2.comPort.MAV.param);
            CH9_OPTION.setup(new[] { "CH9_OPTION", "RC9_OPTION" }, MainV2.comPort.MAV.param);
            CH10_OPTION.setup(new[] { "CH10_OPTION", "RC10_OPTION" }, MainV2.comPort.MAV.param);

            ATC_BRAKE.setup(new[] { "ATC_BRAKE" }, MainV2.comPort.MAV.param);
            MOT_PWM_TYPE.setup(new[] { "MOT_PWM_TYPE" }, MainV2.comPort.MAV.param);

            STEER2SRV_P.setup(0, 0, 1, 0.1f, new[] { "STEER2SRV_P", "ATC_STR_RAT_P" }, MainV2.comPort.MAV.param);
            STEER2SRV_I.setup(0, 0, 1, 0.1f, new[] { "STEER2SRV_I", "ATC_STR_RAT_I" }, MainV2.comPort.MAV.param);
            STEER2SRV_D.setup(0, 0, 1, 0.1f, new[] { "STEER2SRV_D", "ATC_STR_RAT_D" }, MainV2.comPort.MAV.param);
            STEER2SRV_IMAX.setup(0, 0, 1, 0.1f, new[] { "STEER2SRV_IMAX", "ATC_STR_RAT_IMAX" }, MainV2.comPort.MAV.param);
            ATC_STR_RAT_FF.setup(0, 100, 1, 0.1f, "ATC_STR_RAT_FF", MainV2.comPort.MAV.param);

            TURN_RADIUS.setup(0, 0, 1, 0.1f, "TURN_RADIUS", MainV2.comPort.MAV.param);

            SPEED2THR_P.setup(0, 0, 1, 0.1f, new[] { "SPEED2THR_P", "ATC_SPEED_P" }, MainV2.comPort.MAV.param);
            SPEED2THR_I.setup(0, 0, 1, 0.1f, new[] { "SPEED2THR_I", "ATC_SPEED_I" }, MainV2.comPort.MAV.param);
            SPEED2THR_D.setup(0, 0, 1, 0.1f, new[] { "SPEED2THR_D", "ATC_SPEED_D" }, MainV2.comPort.MAV.param);
            SPEED2THR_IMAX.setup(0, 0, 1, 0.1f, new[] { "SPEED2THR_IMAX", "ATC_SPEED_IMAX" }, MainV2.comPort.MAV.param);
            ATC_ACCEL_MAX.setup(0, 0, 1, 0.1f, "ATC_ACCEL_MAX", MainV2.comPort.MAV.param);
            WP_SPEED.setup(0, 100, 1, 0.1f, "WP_SPEED", MainV2.comPort.MAV.param);

            CRUISE_SPEED.setup(0, 0, 1, 0.1f, "CRUISE_SPEED", MainV2.comPort.MAV.param);
            CRUISE_THROTTLE.setup(0, 0, 1, 1, "CRUISE_THROTTLE", MainV2.comPort.MAV.param);
            THR_MIN.setup(0, 0, 1, 1, new[] { "THR_MIN", "MOT_THR_MIN" }, MainV2.comPort.MAV.param);
            THR_MAX.setup(0, 0, 1, 1, new[] { "THR_MAX", "MOT_THR_MAX" }, MainV2.comPort.MAV.param);

            WP_RADIUS.setup(0, 0, 1, 0.1f, "WP_RADIUS", MainV2.comPort.MAV.param);
            WP_OVERSHOOT.setup(0, 0, 1, 0.1f, "WP_OVERSHOOT", MainV2.comPort.MAV.param);
            TURN_G_MAX.setup(0, 0, 1, 0.1f, "TURN_MAX_G", MainV2.comPort.MAV.param);
            NAVL1_PERIOD.setup(0, 0, 1, 1, "NAVL1_PERIOD", MainV2.comPort.MAV.param);
            NAVL1_DAMPING.setup(0, 0, 1, 0.05f, "NAVL1_DAMPING", MainV2.comPort.MAV.param);

            SONAR_TRIGGER_CM.setup(0, 0, 1, 1, new[] { "SONAR_TRIGGER_CM", "RNGFND_TRIGGR_CM" }, MainV2.comPort.MAV.param);
            SONAR_TURN_ANGLE.setup(0, 0, 1, 1, new[] { "SONAR_TURN_ANGLE", "RNGFND_TURN_ANGL" }, MainV2.comPort.MAV.param);
            SONAR_TURN_TIME.setup(0, 0, 1, 1, new[] { "SONAR_TURN_TIME", "RNGFND_TURN_TIME" }, MainV2.comPort.MAV.param);
            SONAR_DEBOUNCE.setup(0, 0, 1, 1, new[] { "SONAR_DEBOUNCE", "RNGFND_DEBOUNCE" }, MainV2.comPort.MAV.param);

            changes.Clear();

            // add tooltips to all controls
            foreach (Control control1 in Controls)
            {
                foreach (Control control2 in control1.Controls)
                {
                    if (control2 is MavlinkNumericUpDown)
                    {
                        var ParamName = ((MavlinkNumericUpDown)control2).ParamName;
                        toolTip1.SetToolTip(control2,
                                            ParameterMetaDataRepository.GetParameterMetaData(ParamName,
                                                                                             ParameterMetaDataConstants.Description, MainV2.comPort.MAV.cs.firmware.ToString()));
                    }
                    if (control2 is MavlinkComboBox)
                    {
                        var ParamName = ((MavlinkComboBox)control2).ParamName;
                        toolTip1.SetToolTip(control2,
                                            ParameterMetaDataRepository.GetParameterMetaData(ParamName,
                                                                                             ParameterMetaDataConstants.Description, MainV2.comPort.MAV.cs.firmware.ToString()));
                    }
                }
            }

            startup = false;
        }