From 4ebaa6f20536a694a13b25d61d6b471cc8fd4072 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 25 May 2014 16:05:13 -0400 Subject: [PATCH] set all the min and max values to 554 and 2400 per the Arduino servo library fix some cosmetic errors on the debug output fix the Vtail mixer setting that caused channel 4 to go crazy due to being undefined. Servo would sit and shake for no reason. --- .../setupwizard/outputcalibrationutil.cpp | 10 ++--- .../pages/outputcalibrationpage.cpp | 38 ++++++++++++++++++- .../vehicleconfigurationhelper.cpp | 19 +++++++++- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp index e75b95b2b..9cbf911fb 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp @@ -52,7 +52,7 @@ void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValu m_outputChannel = channel; m_safeValue = safeValue; - qDebug() << "Starting output for channel " << m_outputChannel << "..."; + qDebug() << "Starting output for channel " << m_outputChannel+1 << "..."; ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(m_uavObjectManager); Q_ASSERT(actuatorCommand); @@ -74,17 +74,17 @@ void OutputCalibrationUtil::startChannelOutput(quint16 channel, quint16 safeValu actuatorCommand->setMetadata(metaData); actuatorCommand->updated(); - qDebug() << "Output for channel " << m_outputChannel << " started."; + qDebug() << "Output for channel " << m_outputChannel+1 << " started."; } } void OutputCalibrationUtil::stopChannelOutput() { if (m_outputChannel >= 0) { - qDebug() << "Stopping output for channel " << m_outputChannel << "..."; + qDebug() << "Stopping output for channel " << m_outputChannel+1 << "..."; // Stop output... setChannelOutputValue(m_safeValue); - qDebug() << "Settings output for channel " << m_outputChannel << " to " << m_safeValue; + qDebug() << "Settings output for channel " << m_outputChannel+1 << " to " << m_safeValue; // Restore metadata to what it was before ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(m_uavObjectManager); @@ -93,7 +93,7 @@ void OutputCalibrationUtil::stopChannelOutput() actuatorCommand->setMetadata(m_savedActuatorCommandMetadata); actuatorCommand->updated(); - qDebug() << "Output for channel " << m_outputChannel << " stopped."; + qDebug() << "Output for channel " << m_outputChannel+1 << " stopped."; m_outputChannel = -1; } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index dba143375..5f5c9dd9c 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -161,6 +161,24 @@ void OutputCalibrationPage::setupVehicle() m_actuatorSettings[6].channelNeutral = 1500; m_actuatorSettings[7].channelNeutral = 1500; + // Arduino library defaults to 554 http://arduino.cc/en/Reference/ServoAttach, + // 600 is for HS85mg - http://www.servocity.com/html/hs-85mg__mighty_micro.html#.U4JEWhapKBU + // Same rules as above from the Arduino *generic* library and the servo city info for the 85mg + m_actuatorSettings[1].channelMin = 554; + m_actuatorSettings[1].channelMax = 2400; + m_actuatorSettings[2].channelMin = 554; + m_actuatorSettings[2].channelMax = 2400; + m_actuatorSettings[3].channelMin = 554; + m_actuatorSettings[3].channelMax = 2400; + m_actuatorSettings[4].channelMin = 554; + m_actuatorSettings[4].channelMax = 2400; + m_actuatorSettings[5].channelMin = 554; + m_actuatorSettings[5].channelMax = 2400; + m_actuatorSettings[6].channelMin = 554; + m_actuatorSettings[6].channelMax = 2400; + m_actuatorSettings[7].channelMin = 554; + m_actuatorSettings[7].channelMax = 2400; + getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::FIXED_WING_VTAIL: @@ -180,6 +198,24 @@ void OutputCalibrationPage::setupVehicle() m_actuatorSettings[6].channelNeutral = 1500; m_actuatorSettings[7].channelNeutral = 1500; + // Arduino library defaults to 554 http://arduino.cc/en/Reference/ServoAttach, + // 600 is for HS85mg - http://www.servocity.com/html/hs-85mg__mighty_micro.html#.U4JEWhapKBU + // Same rules as above from the Arduino *generic* library and the servo city info for the 85mg + m_actuatorSettings[1].channelMin = 554; + m_actuatorSettings[1].channelMax = 2400; + m_actuatorSettings[2].channelMin = 554; + m_actuatorSettings[2].channelMax = 2400; + m_actuatorSettings[3].channelMin = 554; + m_actuatorSettings[3].channelMax = 2400; + m_actuatorSettings[4].channelMin = 554; + m_actuatorSettings[4].channelMax = 2400; + m_actuatorSettings[5].channelMin = 554; + m_actuatorSettings[5].channelMax = 2400; + m_actuatorSettings[6].channelMin = 554; + m_actuatorSettings[6].channelMax = 2400; + m_actuatorSettings[7].channelMin = 554; + m_actuatorSettings[7].channelMax = 2400; + getWizard()->setActuatorSettings(m_actuatorSettings); break; default: @@ -255,7 +291,7 @@ void OutputCalibrationPage::setWizardPage() ui->calibrationStack->setCurrentIndex(currentPageIndex); int currentChannel = getCurrentChannel(); - qDebug() << "Current channel: " << currentChannel; + qDebug() << "Current channel: " << currentChannel+1; if (currentChannel >= 0) { if (currentPageIndex == 1) { ui->motorNeutralSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index ed8969589..07341fb94 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -311,13 +311,16 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() { ActuatorSettings::DataFields data = actSettings->getData(); - qDebug() << "Override center pulse for fixed wing servos\n"; + qDebug() << "Override center, min and max pulses for fixed wing servos\n"; // move all but first chan to 1500 center pluse QList actuatorSettings = m_configSource->getActuatorSettings(); for (quint16 i = 1; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) { data.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM; data.ChannelAddr[i] = i; + data.ChannelMin[i] = 554; // Arduino library defaults to 554 http://arduino.cc/en/Reference/ServoAttach, + // 600 is for HS85mg - http://www.servocity.com/html/hs-85mg__mighty_micro.html#.U4JEWhapKBU data.ChannelNeutral[i] = 1500; + data.ChannelMax[i] = 2400; // Same rules as above from the Arduino *generic* library and the servo city info for the 85mg } qDebug() << "Save Fixed Wing Actuator Data\n"; actSettings->setData(data); @@ -1346,6 +1349,20 @@ void VehicleConfigurationHelper::setupVtail() channels[2].pitch = -50; channels[2].yaw = 0; + channels[3].type = MIXER_TYPE_SERVO; + channels[3].throttle1 = 0; + channels[3].throttle2 = 0; + channels[3].roll = 0; + channels[3].pitch = 0; + channels[3].yaw = 0; + + channels[3].type = MIXER_TYPE_SERVO; + channels[3].throttle1 = 0; + channels[3].throttle2 = 0; + channels[3].roll = 0; + channels[3].pitch = 0; + channels[3].yaw = 0; + guiSettings.fixedwing.FixedWingThrottle = 1; guiSettings.fixedwing.FixedWingRoll1 = 2; guiSettings.fixedwing.FixedWingRoll2 = 3;