mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Start on ESC Calib page
This commit is contained in:
parent
9cb5c21f23
commit
f487ed3852
@ -0,0 +1,131 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file EscCalibrationPage.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
||||
* @addtogroup
|
||||
* @{
|
||||
* @addtogroup EscCalibrationPage
|
||||
* @{
|
||||
* @brief
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include "esccalibrationpage.h"
|
||||
#include "ui_esccalibrationpage.h"
|
||||
#include "setupwizard.h"
|
||||
|
||||
EscCalibrationPage::EscCalibrationPage(SetupWizard *wizard, QWidget *parent) :
|
||||
AbstractWizardPage(wizard, parent),
|
||||
ui(new Ui::EscCalibrationPage), m_calibrationUtil(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->levelButton, SIGNAL(clicked()), this, SLOT(performCalibration()));
|
||||
}
|
||||
|
||||
EscCalibrationPage::~EscCalibrationPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool EscCalibrationPage::validatePage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EscCalibrationPage::isComplete() const
|
||||
{
|
||||
return ui->levelButton->isEnabled();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::enableButtons(bool enable)
|
||||
{
|
||||
ui->levelButton->setEnabled(enable);
|
||||
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::performCalibration()
|
||||
{
|
||||
if (!getWizard()->getConnectionManager()->isConnected()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("An OpenPilot controller must be connected to your computer to perform bias "
|
||||
"calculations.\nPlease connect your OpenPilot controller to your computer and try again."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
enableButtons(false);
|
||||
ui->progressLabel->setText(QString(tr("Retrieving data...")));
|
||||
|
||||
|
||||
if (!m_calibrationUtil) {
|
||||
m_calibrationUtil = new BiasCalibrationUtil(BIAS_CYCLES, BIAS_RATE);
|
||||
}
|
||||
|
||||
connect(m_calibrationUtil, SIGNAL(progress(long, long)), this, SLOT(calibrationProgress(long, long)));
|
||||
connect(m_calibrationUtil, SIGNAL(done(accelGyroBias)), this, SLOT(calibrationDone(accelGyroBias)));
|
||||
connect(m_calibrationUtil, SIGNAL(timeout(QString)), this, SLOT(calibrationTimeout(QString)));
|
||||
|
||||
m_calibrationUtil->start();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::calibrationProgress(long current, long total)
|
||||
{
|
||||
if (ui->levellinProgressBar->maximum() != (int)total) {
|
||||
ui->levellinProgressBar->setMaximum((int)total);
|
||||
}
|
||||
if (ui->levellinProgressBar->value() != (int)current) {
|
||||
ui->levellinProgressBar->setValue((int)current);
|
||||
}
|
||||
}
|
||||
|
||||
void EscCalibrationPage::calibrationDone(accelGyroBias bias)
|
||||
{
|
||||
stopCalibration();
|
||||
getWizard()->setLevellingBias(bias);
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::calibrationTimeout(QString message)
|
||||
{
|
||||
stopCalibration();
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::stopCalibration()
|
||||
{
|
||||
if (m_calibrationUtil) {
|
||||
disconnect(m_calibrationUtil, SIGNAL(progress(long, long)), this, SLOT(calibrationProgress(long, long)));
|
||||
disconnect(m_calibrationUtil, SIGNAL(done(accelGyroBias)), this, SLOT(calibrationDone(accelGyroBias)));
|
||||
disconnect(m_calibrationUtil, SIGNAL(timeout(QString)), this, SLOT(calibrationTimeout(QString)));
|
||||
ui->progressLabel->setText(QString(tr("<font color='green'>Done!</font>")));
|
||||
enableButtons(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file biascalibrationpage.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||
* @addtogroup
|
||||
* @{
|
||||
* @addtogroup BiasCalibrationPage
|
||||
* @{
|
||||
* @brief
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef ESCCALIBRATIONPAGE_H
|
||||
#define ESCCALIBRATIONPAGE_H
|
||||
|
||||
#include "abstractwizardpage.h"
|
||||
|
||||
namespace Ui {
|
||||
class EscCalibrationPage;
|
||||
}
|
||||
|
||||
class EscCalibrationPage : public AbstractWizardPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EscCalibrationPage(SetupWizard *wizard, QWidget *parent = 0);
|
||||
~EscCalibrationPage();
|
||||
bool validatePage();
|
||||
bool isComplete() const;
|
||||
|
||||
private slots:
|
||||
void performCalibration();
|
||||
void calibrationProgress(long current, long total);
|
||||
void calibrationDone(accelGyroBias bias);
|
||||
void calibrationTimeout(QString message);
|
||||
|
||||
private:
|
||||
static const int BIAS_CYCLES = 200;
|
||||
static const int BIAS_RATE = 50;
|
||||
|
||||
Ui::EscCalibrationPage *ui;
|
||||
BiasCalibrationUtil *m_calibrationUtil;
|
||||
|
||||
void stopCalibration();
|
||||
void enableButtons(bool enable);
|
||||
};
|
||||
|
||||
#endif // ESCCALIBRATIONPAGE_H
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BiasCalibrationPage</class>
|
||||
<widget class="QWizardPage" name="BiasCalibrationPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WizardPage</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot ESC Calibration Procedure</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">As you have selected to use a MultiRotor and Fast / Flashed ESCs, we need to calibrate the endpoints of these ESCs so they can see the full throttle range from the flight controller. </span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This part of the wizard will tell you to connect the battery to your aircraft, before doing so you </span><span style=" font-family:'MS Shell Dlg 2,sans-serif'; font-size:10pt;">absolutely must </span><span style=" font-family:'MS Shell Dlg 2,sans-serif'; font-size:10pt; font-weight:600; color:#ff0000;">remove the props from all motors</span><span style=" font-family:'MS Shell Dlg 2,sans-serif'; font-size:10pt;">.</span> </p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">The steps to perform this calibration are as follows:</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">1. Press the start button on this page </span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">2. Connect the battery to your airframe</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">3. Wait for 2 seconds after the ESC beeps stop </span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">4. Press the stop button on this page</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">When ready push the start button below.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progressLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../wizardResources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user