From d018be5d424bc9c3c1d5ef61b53b562d88cc40fa Mon Sep 17 00:00:00 2001 From: Bryan Godbolt Date: Wed, 22 Sep 2010 14:37:57 -0600 Subject: [PATCH] radio cal data now passed properly via mavlink --- src/comm/OpalLink.cc | 2 +- src/ui/QGCRemoteControlView.cc | 2 +- src/ui/RadioCalibration/AbstractCalibrator.h | 2 ++ .../RadioCalibration/AirfoilServoCalibrator.cc | 6 +++--- .../RadioCalibration/AirfoilServoCalibrator.h | 8 ++++---- src/ui/RadioCalibration/CurveCalibrator.h | 4 ++-- src/ui/RadioCalibration/RadioCalibrationData.cc | 10 ++++++++-- src/ui/RadioCalibration/RadioCalibrationData.h | 17 +++++++++++++---- .../RadioCalibration/RadioCalibrationWindow.cc | 2 +- .../RadioCalibration/RadioCalibrationWindow.h | 1 + src/ui/RadioCalibration/SwitchCalibrator.cc | 4 ++-- src/ui/RadioCalibration/SwitchCalibrator.h | 6 +++--- 12 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/comm/OpalLink.cc b/src/comm/OpalLink.cc index 454a3ad7e..bda6b35b9 100644 --- a/src/comm/OpalLink.cc +++ b/src/comm/OpalLink.cc @@ -142,7 +142,7 @@ void OpalLink::writeBytes(const char *bytes, qint64 length) this->sendRCValues = static_cast(rc.enabled); } break; -#ifdef MAVLINK_ENABLE_UALBERTA_MESSAGES +#ifdef MAVLINK_ENABLED_UALBERTA_MESSAGES case MAVLINK_MSG_ID_RADIO_CALIBRATION: { mavlink_radio_calibration_t radio; diff --git a/src/ui/QGCRemoteControlView.cc b/src/ui/QGCRemoteControlView.cc index 52ac01e74..922221d29 100644 --- a/src/ui/QGCRemoteControlView.cc +++ b/src/ui/QGCRemoteControlView.cc @@ -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)), calibrationWindow, SLOT(receive(const QPointer&))); + connect(newUAS, SIGNAL(radioCalibrationReceived(const QPointer&)), calibrationWindow, SLOT(receive(const QPointer&))); 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))); diff --git a/src/ui/RadioCalibration/AbstractCalibrator.h b/src/ui/RadioCalibration/AbstractCalibrator.h index fa56810f7..74897cf67 100644 --- a/src/ui/RadioCalibration/AbstractCalibrator.h +++ b/src/ui/RadioCalibration/AbstractCalibrator.h @@ -16,6 +16,8 @@ public: ~AbstractCalibrator(); virtual void set(const QVector& data)=0; +signals: + void setpointChanged(int index, float value); public slots: void channelChanged(float raw); diff --git a/src/ui/RadioCalibration/AirfoilServoCalibrator.cc b/src/ui/RadioCalibration/AirfoilServoCalibrator.cc index 7b0f9d8ab..99f134cc8 100644 --- a/src/ui/RadioCalibration/AirfoilServoCalibrator.cc +++ b/src/ui/RadioCalibration/AirfoilServoCalibrator.cc @@ -91,19 +91,19 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent void AirfoilServoCalibrator::setHigh() { highPulseWidth->setText(QString::number(static_cast(logExtrema()))); - emit highSetpointChanged(logExtrema()); + emit setpointChanged(2, logExtrema()); } void AirfoilServoCalibrator::setCenter() { centerPulseWidth->setText(QString::number(static_cast(logAverage()))); - emit centerSetpointChanged(logAverage()); + emit setpointChanged(1, logAverage()); } void AirfoilServoCalibrator::setLow() { lowPulseWidth->setText(QString::number(static_cast(logExtrema()))); - emit lowSetpointChanged(logExtrema()); + emit setpointChanged(0, logExtrema()); } void AirfoilServoCalibrator::set(const QVector &data) diff --git a/src/ui/RadioCalibration/AirfoilServoCalibrator.h b/src/ui/RadioCalibration/AirfoilServoCalibrator.h index 34a2e9b10..0d4c02dc7 100644 --- a/src/ui/RadioCalibration/AirfoilServoCalibrator.h +++ b/src/ui/RadioCalibration/AirfoilServoCalibrator.h @@ -26,10 +26,10 @@ public: /** @param data must have exaclty 3 elemets. they are assumed to be low center high */ void set(const QVector& 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(); diff --git a/src/ui/RadioCalibration/CurveCalibrator.h b/src/ui/RadioCalibration/CurveCalibrator.h index 4dd1ddac6..6fd3e454d 100644 --- a/src/ui/RadioCalibration/CurveCalibrator.h +++ b/src/ui/RadioCalibration/CurveCalibrator.h @@ -25,8 +25,8 @@ public: ~CurveCalibrator(); void set(const QVector &data); -signals: - void setpointChanged(int setpoint, float raw); +//signals: +// void setpointChanged(int setpoint, float raw); protected slots: void setSetpoint(int setpoint); diff --git a/src/ui/RadioCalibration/RadioCalibrationData.cc b/src/ui/RadioCalibration/RadioCalibrationData.cc index c7139b375..0643b595f 100644 --- a/src/ui/RadioCalibration/RadioCalibrationData.cc +++ b/src/ui/RadioCalibration/RadioCalibrationData.cc @@ -2,7 +2,13 @@ RadioCalibrationData::RadioCalibrationData() { - data = new QVector >(); + data = new QVector >(6); + (*data).insert(AILERON, QVector(3)); + (*data).insert(ELEVATOR, QVector(3)); + (*data).insert(RUDDER, QVector(3)); + (*data).insert(GYRO, QVector(2)); + (*data).insert(PITCH, QVector(5)); + (*data).insert(THROTTLE, QVector(5)); } RadioCalibrationData::RadioCalibrationData(const QVector &aileron, @@ -45,5 +51,5 @@ const QVector& RadioCalibrationData::operator ()(int i) const } // This is not good. If it is ever used after being returned it will cause a crash - return QVector(); +// return QVector(); } diff --git a/src/ui/RadioCalibration/RadioCalibrationData.h b/src/ui/RadioCalibration/RadioCalibrationData.h index 726d01f26..9aab6b161 100644 --- a/src/ui/RadioCalibration/RadioCalibrationData.h +++ b/src/ui/RadioCalibration/RadioCalibrationData.h @@ -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& 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 > *data; diff --git a/src/ui/RadioCalibration/RadioCalibrationWindow.cc b/src/ui/RadioCalibration/RadioCalibrationWindow.cc index 3efc756b7..928e6f23e 100644 --- a/src/ui/RadioCalibration/RadioCalibrationWindow.cc +++ b/src/ui/RadioCalibration/RadioCalibrationWindow.cc @@ -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(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], diff --git a/src/ui/RadioCalibration/RadioCalibrationWindow.h b/src/ui/RadioCalibration/RadioCalibrationWindow.h index af98e987f..c631308a4 100644 --- a/src/ui/RadioCalibration/RadioCalibrationWindow.h +++ b/src/ui/RadioCalibration/RadioCalibrationWindow.h @@ -50,6 +50,7 @@ protected: CurveCalibrator *throttle; int uasId; QPointer radio; + QSignalMapper mapper; }; #endif // RADIOCALIBRATIONWINDOW_H diff --git a/src/ui/RadioCalibration/SwitchCalibrator.cc b/src/ui/RadioCalibration/SwitchCalibrator.cc index d09fee3f3..61c5e583c 100644 --- a/src/ui/RadioCalibration/SwitchCalibrator.cc +++ b/src/ui/RadioCalibration/SwitchCalibrator.cc @@ -39,13 +39,13 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) : void SwitchCalibrator::setDefault() { defaultPulseWidth->setText(QString::number(static_cast(logExtrema()))); - emit defaultSetpointChanged(logExtrema()); + emit setpointChanged(0, logExtrema()); } void SwitchCalibrator::setToggled() { toggledPulseWidth->setText(QString::number(static_cast(logExtrema()))); - emit toggledSetpointChanged(logExtrema()); + emit setpointChanged(1, logExtrema()); } void SwitchCalibrator::set(const QVector &data) diff --git a/src/ui/RadioCalibration/SwitchCalibrator.h b/src/ui/RadioCalibration/SwitchCalibrator.h index 6950f03a4..cb0cfef44 100644 --- a/src/ui/RadioCalibration/SwitchCalibrator.h +++ b/src/ui/RadioCalibration/SwitchCalibrator.h @@ -17,9 +17,9 @@ public: explicit SwitchCalibrator(QString title=QString(), QWidget *parent = 0); void set(const QVector &data); -signals: - void defaultSetpointChanged(float); - void toggledSetpointChanged(float); +//signals: +// void defaultSetpointChanged(float); +// void toggledSetpointChanged(float); protected slots: void setDefault(); -- 2.22.0