Commit d018be5d authored by Bryan Godbolt's avatar Bryan Godbolt

radio cal data now passed properly via mavlink

parent 47165eaa
......@@ -142,7 +142,7 @@ void OpalLink::writeBytes(const char *bytes, qint64 length)
this->sendRCValues = static_cast<bool>(rc.enabled);
}
break;
#ifdef MAVLINK_ENABLE_UALBERTA_MESSAGES
#ifdef MAVLINK_ENABLED_UALBERTA_MESSAGES
case MAVLINK_MSG_ID_RADIO_CALIBRATION:
{
mavlink_radio_calibration_t radio;
......
......@@ -110,7 +110,7 @@ void QGCRemoteControlView::setUASId(int id)
// New UAS exists, connect
nameLabel->setText(QString("RC Input of %1").arg(newUAS->getUASName()));
calibrationWindow->setUASId(id);
connect(newUAS, SIGNAL(radioCalibrationReceived(const QPointer<RadioCalibrationData>)), calibrationWindow, SLOT(receive(const QPointer<RadioCalibrationData>&)));
connect(newUAS, SIGNAL(radioCalibrationReceived(const QPointer<RadioCalibrationData>&)), calibrationWindow, SLOT(receive(const QPointer<RadioCalibrationData>&)));
connect(newUAS, SIGNAL(remoteControlChannelChanged(int,float,float)), this, SLOT(setChannel(int,float,float)));
connect(newUAS, SIGNAL(remoteControlChannelChanged(int,float,float)), calibrationWindow, SLOT(setChannel(int,float,float)));
connect(newUAS, SIGNAL(remoteControlRSSIChanged(float)), this, SLOT(setRemoteRSSI(float)));
......
......@@ -16,6 +16,8 @@ public:
~AbstractCalibrator();
virtual void set(const QVector<float>& data)=0;
signals:
void setpointChanged(int index, float value);
public slots:
void channelChanged(float raw);
......
......@@ -91,19 +91,19 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
void AirfoilServoCalibrator::setHigh()
{
highPulseWidth->setText(QString::number(static_cast<double>(logExtrema())));
emit highSetpointChanged(logExtrema());
emit setpointChanged(2, logExtrema());
}
void AirfoilServoCalibrator::setCenter()
{
centerPulseWidth->setText(QString::number(static_cast<double>(logAverage())));
emit centerSetpointChanged(logAverage());
emit setpointChanged(1, logAverage());
}
void AirfoilServoCalibrator::setLow()
{
lowPulseWidth->setText(QString::number(static_cast<double>(logExtrema())));
emit lowSetpointChanged(logExtrema());
emit setpointChanged(0, logExtrema());
}
void AirfoilServoCalibrator::set(const QVector<float> &data)
......
......@@ -26,10 +26,10 @@ public:
/** @param data must have exaclty 3 elemets. they are assumed to be low center high */
void set(const QVector<float>& data);
signals:
void highSetpointChanged(float);
void centerSetpointChanged(float);
void lowSetpointChanged(float);
//signals:
// void highSetpointChanged(float);
// void centerSetpointChanged(float);
// void lowSetpointChanged(float);
protected slots:
void setHigh();
......
......@@ -25,8 +25,8 @@ public:
~CurveCalibrator();
void set(const QVector<float> &data);
signals:
void setpointChanged(int setpoint, float raw);
//signals:
// void setpointChanged(int setpoint, float raw);
protected slots:
void setSetpoint(int setpoint);
......
......@@ -2,7 +2,13 @@
RadioCalibrationData::RadioCalibrationData()
{
data = new QVector<QVector<float> >();
data = new QVector<QVector<float> >(6);
(*data).insert(AILERON, QVector<float>(3));
(*data).insert(ELEVATOR, QVector<float>(3));
(*data).insert(RUDDER, QVector<float>(3));
(*data).insert(GYRO, QVector<float>(2));
(*data).insert(PITCH, QVector<float>(5));
(*data).insert(THROTTLE, QVector<float>(5));
}
RadioCalibrationData::RadioCalibrationData(const QVector<float> &aileron,
......@@ -45,5 +51,5 @@ const QVector<float>& RadioCalibrationData::operator ()(int i) const
}
// This is not good. If it is ever used after being returned it will cause a crash
return QVector<float>();
// return QVector<float>();
}
......@@ -30,12 +30,21 @@ public:
THROTTLE
};
void loadFile();
void saveFile();
void send();
void receive();
// void loadFile();
// void saveFile();
// void send();
// void receive();
const float* operator[](int i) const;
const QVector<float>& operator()(int i) const;
void set(int element, int index, float value) {(*data)[element][index] = value;}
public slots:
void setAileron(int index, float value) {set(AILERON, index, value);}
void setElevator(int index, float value) {set(ELEVATOR, index, value);}
void setRudeer(int index, float value) {set(RUDDER, index, value);}
void setGyro(int index, float value) {set(GYRO, index, value);}
void setPitch(int index, float value) {set(PITCH, index, value);}
void setThrottle(int index, float value) {set(THROTTLE, index, value);}
protected:
QVector<QVector<float> > *data;
......
......@@ -43,6 +43,7 @@ RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) :
connect(transmit, SIGNAL(clicked()), this, SLOT(send()));
connect(get, SIGNAL(clicked()), this, SLOT(request()));
connect(aileron, SIGNAL(setpointChanged(int,float)), radio, SLOT(setAileron(int,float)));
setUASId(0);
}
......@@ -94,7 +95,6 @@ void RadioCalibrationWindow::send()
UAS *uas = dynamic_cast<UAS*>(UASManager::instance()->getUASForId(uasId));
if (uas)
{
qDebug()<< "we have a uas";
mavlink_message_t msg;
mavlink_msg_radio_calibration_pack(uasId, 0, &msg,
(*radio)[RadioCalibrationData::AILERON],
......
......@@ -50,6 +50,7 @@ protected:
CurveCalibrator *throttle;
int uasId;
QPointer<RadioCalibrationData> radio;
QSignalMapper mapper;
};
#endif // RADIOCALIBRATIONWINDOW_H
......@@ -39,13 +39,13 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
void SwitchCalibrator::setDefault()
{
defaultPulseWidth->setText(QString::number(static_cast<double>(logExtrema())));
emit defaultSetpointChanged(logExtrema());
emit setpointChanged(0, logExtrema());
}
void SwitchCalibrator::setToggled()
{
toggledPulseWidth->setText(QString::number(static_cast<double>(logExtrema())));
emit toggledSetpointChanged(logExtrema());
emit setpointChanged(1, logExtrema());
}
void SwitchCalibrator::set(const QVector<float> &data)
......
......@@ -17,9 +17,9 @@ public:
explicit SwitchCalibrator(QString title=QString(), QWidget *parent = 0);
void set(const QVector<float> &data);
signals:
void defaultSetpointChanged(float);
void toggledSetpointChanged(float);
//signals:
// void defaultSetpointChanged(float);
// void toggledSetpointChanged(float);
protected slots:
void setDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment