Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9481145a
Commit
9481145a
authored
Jul 15, 2011
by
Bryan Godbolt
Browse files
working on radio calibration window
parent
ca13be59
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/uas/UAS.cc
View file @
9481145a
...
@@ -958,12 +958,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
...
@@ -958,12 +958,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
case
MAVLINK_MSG_ID_RADIO_CALIBRATION
:
{
case
MAVLINK_MSG_ID_RADIO_CALIBRATION
:
{
mavlink_radio_calibration_t
radioMsg
;
mavlink_radio_calibration_t
radioMsg
;
mavlink_msg_radio_calibration_decode
(
&
message
,
&
radioMsg
);
mavlink_msg_radio_calibration_decode
(
&
message
,
&
radioMsg
);
QVector
<
floa
t
>
aileron
;
QVector
<
uint16_
t
>
aileron
;
QVector
<
floa
t
>
elevator
;
QVector
<
uint16_
t
>
elevator
;
QVector
<
floa
t
>
rudder
;
QVector
<
uint16_
t
>
rudder
;
QVector
<
floa
t
>
gyro
;
QVector
<
uint16_
t
>
gyro
;
QVector
<
floa
t
>
pitch
;
QVector
<
uint16_
t
>
pitch
;
QVector
<
floa
t
>
throttle
;
QVector
<
uint16_
t
>
throttle
;
for
(
int
i
=
0
;
i
<
MAVLINK_MSG_RADIO_CALIBRATION_FIELD_AILERON_LEN
;
++
i
)
for
(
int
i
=
0
;
i
<
MAVLINK_MSG_RADIO_CALIBRATION_FIELD_AILERON_LEN
;
++
i
)
aileron
<<
radioMsg
.
aileron
[
i
];
aileron
<<
radioMsg
.
aileron
[
i
];
...
...
src/ui/RadioCalibration/AbstractCalibrator.cc
View file @
9481145a
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
AbstractCalibrator
::
AbstractCalibrator
(
QWidget
*
parent
)
:
AbstractCalibrator
::
AbstractCalibrator
(
QWidget
*
parent
)
:
QWidget
(
parent
),
QWidget
(
parent
),
pulseWidth
(
new
QLabel
()),
pulseWidth
(
new
QLabel
()),
log
(
new
QVector
<
floa
t
>
())
log
(
new
QVector
<
uint16_
t
>
())
{
{
}
}
...
...
src/ui/RadioCalibration/AbstractCalibrator.h
View file @
9481145a
...
@@ -36,6 +36,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -36,6 +36,7 @@ This file is part of the QGROUNDCONTROL project
#include
<QVector>
#include
<QVector>
#include
<math.h>
#include
<math.h>
#include
<stdint.h>
/**
/**
@brief Holds the code which is common to all the radio calibration widgets.
@brief Holds the code which is common to all the radio calibration widgets.
...
...
src/ui/RadioCalibration/AirfoilServoCalibrator.cc
View file @
9481145a
...
@@ -78,19 +78,19 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
...
@@ -78,19 +78,19 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
void
AirfoilServoCalibrator
::
setHigh
()
void
AirfoilServoCalibrator
::
setHigh
()
{
{
highPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()))
)
;
highPulseWidth
->
setText
(
QString
::
number
(
logExtrema
()));
emit
setpointChanged
(
2
,
logExtrema
());
emit
setpointChanged
(
2
,
logExtrema
());
}
}
void
AirfoilServoCalibrator
::
setCenter
()
void
AirfoilServoCalibrator
::
setCenter
()
{
{
centerPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logAverage
()))
)
;
centerPulseWidth
->
setText
(
QString
::
number
(
logAverage
()));
emit
setpointChanged
(
1
,
logAverage
());
emit
setpointChanged
(
1
,
logAverage
());
}
}
void
AirfoilServoCalibrator
::
setLow
()
void
AirfoilServoCalibrator
::
setLow
()
{
{
lowPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()))
)
;
lowPulseWidth
->
setText
(
QString
::
number
(
logExtrema
()));
emit
setpointChanged
(
0
,
logExtrema
());
emit
setpointChanged
(
0
,
logExtrema
());
}
}
...
...
src/ui/RadioCalibration/CurveCalibrator.cc
View file @
9481145a
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
CurveCalibrator
::
CurveCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
CurveCalibrator
::
CurveCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
AbstractCalibrator
(
parent
),
AbstractCalibrator
(
parent
),
setpoints
(
new
QVector
<
double
>
(
5
)),
setpoints
(
new
QVector
<
uint16_t
>
(
5
)),
positions
(
new
QVector
<
double
>
())
positions
(
new
QVector
<
uint16_t
>
())
{
{
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
QLabel
*
title
=
new
QLabel
(
titleString
);
QLabel
*
title
=
new
QLabel
(
titleString
);
...
@@ -32,7 +32,17 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
...
@@ -32,7 +32,17 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
curve
=
new
QwtPlotCurve
();
curve
=
new
QwtPlotCurve
();
curve
->
setPen
(
QPen
(
QColor
(
QString
(
"lime"
))));
curve
->
setPen
(
QPen
(
QColor
(
QString
(
"lime"
))));
curve
->
setData
(
*
positions
,
*
setpoints
);
QVector
<
double
>
pos
(
positions
->
size
());
QVector
<
double
>
set
(
setpoints
->
size
());
for
(
int
i
=
0
;
i
<
positions
->
size
()
&&
i
<
setpoints
->
size
();
i
++
)
{
pos
[
i
]
=
static_cast
<
double
>
((
*
positions
)[
i
]);
set
[
i
]
=
static_cast
<
double
>
((
*
setpoints
)[
i
]);
}
curve
->
setData
(
pos
,
set
);
curve
->
attach
(
plot
);
curve
->
attach
(
plot
);
plot
->
replot
();
plot
->
replot
();
...
@@ -79,18 +89,36 @@ void CurveCalibrator::setSetpoint(int setpoint)
...
@@ -79,18 +89,36 @@ void CurveCalibrator::setSetpoint(int setpoint)
}
else
{
}
else
{
setpoints
->
replace
(
setpoint
,
logAverage
());
setpoints
->
replace
(
setpoint
,
logAverage
());
}
}
curve
->
setData
(
*
positions
,
*
setpoints
);
QVector
<
double
>
pos
(
positions
->
size
());
QVector
<
double
>
set
(
setpoints
->
size
());
for
(
int
i
=
0
;
i
<
positions
->
size
()
&&
i
<
setpoints
->
size
();
i
++
)
{
pos
[
i
]
=
static_cast
<
double
>
((
*
positions
)[
i
]);
set
[
i
]
=
static_cast
<
double
>
((
*
setpoints
)[
i
]);
}
curve
->
setData
(
pos
,
set
);
plot
->
replot
();
plot
->
replot
();
emit
setpointChanged
(
setpoint
,
static_cast
<
float
>
(
setpoints
->
value
(
setpoint
))
)
;
emit
setpointChanged
(
setpoint
,
setpoints
->
value
(
setpoint
));
}
}
void
CurveCalibrator
::
set
(
const
QVector
<
uint16_t
>
&
data
)
void
CurveCalibrator
::
set
(
const
QVector
<
uint16_t
>
&
data
)
{
{
if
(
data
.
size
()
==
5
)
{
if
(
data
.
size
()
==
5
)
{
for
(
int
i
=
0
;
i
<
data
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
data
.
size
();
++
i
)
setpoints
->
replace
(
i
,
static_cast
<
double
>
(
data
[
i
]));
setpoints
->
replace
(
i
,
data
[
i
]);
curve
->
setData
(
*
positions
,
*
setpoints
);
QVector
<
double
>
pos
(
positions
->
size
());
QVector
<
double
>
set
(
setpoints
->
size
());
for
(
int
i
=
0
;
i
<
positions
->
size
()
&&
i
<
setpoints
->
size
();
i
++
)
{
pos
[
i
]
=
static_cast
<
double
>
((
*
positions
)[
i
]);
set
[
i
]
=
static_cast
<
double
>
((
*
setpoints
)[
i
]);
}
curve
->
setData
(
pos
,
set
);
plot
->
replot
();
plot
->
replot
();
}
else
{
}
else
{
qDebug
()
<<
__FILE__
<<
__LINE__
<<
": wrong data vector size"
;
qDebug
()
<<
__FILE__
<<
__LINE__
<<
": wrong data vector size"
;
...
...
src/ui/RadioCalibration/RadioCalibrationData.cc
View file @
9481145a
...
@@ -2,23 +2,23 @@
...
@@ -2,23 +2,23 @@
RadioCalibrationData
::
RadioCalibrationData
()
RadioCalibrationData
::
RadioCalibrationData
()
{
{
data
=
new
QVector
<
QVector
<
floa
t
>
>
(
6
);
data
=
new
QVector
<
QVector
<
uint16_
t
>
>
(
6
);
(
*
data
).
insert
(
AILERON
,
QVector
<
floa
t
>
(
3
));
(
*
data
).
insert
(
AILERON
,
QVector
<
uint16_
t
>
(
3
));
(
*
data
).
insert
(
ELEVATOR
,
QVector
<
floa
t
>
(
3
));
(
*
data
).
insert
(
ELEVATOR
,
QVector
<
uint16_
t
>
(
3
));
(
*
data
).
insert
(
RUDDER
,
QVector
<
floa
t
>
(
3
));
(
*
data
).
insert
(
RUDDER
,
QVector
<
uint16_
t
>
(
3
));
(
*
data
).
insert
(
GYRO
,
QVector
<
floa
t
>
(
2
));
(
*
data
).
insert
(
GYRO
,
QVector
<
uint16_
t
>
(
2
));
(
*
data
).
insert
(
PITCH
,
QVector
<
floa
t
>
(
5
));
(
*
data
).
insert
(
PITCH
,
QVector
<
uint16_
t
>
(
5
));
(
*
data
).
insert
(
THROTTLE
,
QVector
<
floa
t
>
(
5
));
(
*
data
).
insert
(
THROTTLE
,
QVector
<
uint16_
t
>
(
5
));
}
}
RadioCalibrationData
::
RadioCalibrationData
(
const
QVector
<
floa
t
>
&
aileron
,
RadioCalibrationData
::
RadioCalibrationData
(
const
QVector
<
uint16_
t
>
&
aileron
,
const
QVector
<
floa
t
>
&
elevator
,
const
QVector
<
uint16_
t
>
&
elevator
,
const
QVector
<
floa
t
>
&
rudder
,
const
QVector
<
uint16_
t
>
&
rudder
,
const
QVector
<
floa
t
>
&
gyro
,
const
QVector
<
uint16_
t
>
&
gyro
,
const
QVector
<
floa
t
>
&
pitch
,
const
QVector
<
uint16_
t
>
&
pitch
,
const
QVector
<
floa
t
>
&
throttle
)
const
QVector
<
uint16_
t
>
&
throttle
)
{
{
data
=
new
QVector
<
QVector
<
floa
t
>
>
();
data
=
new
QVector
<
QVector
<
uint16_
t
>
>
();
(
*
data
)
<<
aileron
(
*
data
)
<<
aileron
<<
elevator
<<
elevator
<<
rudder
<<
rudder
...
@@ -30,7 +30,7 @@ RadioCalibrationData::RadioCalibrationData(const QVector<float> &aileron,
...
@@ -30,7 +30,7 @@ RadioCalibrationData::RadioCalibrationData(const QVector<float> &aileron,
RadioCalibrationData
::
RadioCalibrationData
(
const
RadioCalibrationData
&
other
)
RadioCalibrationData
::
RadioCalibrationData
(
const
RadioCalibrationData
&
other
)
:
QObject
()
:
QObject
()
{
{
data
=
new
QVector
<
QVector
<
floa
t
>
>
(
*
other
.
data
);
data
=
new
QVector
<
QVector
<
uint16_
t
>
>
(
*
other
.
data
);
}
}
RadioCalibrationData
::~
RadioCalibrationData
()
RadioCalibrationData
::~
RadioCalibrationData
()
...
@@ -38,7 +38,7 @@ RadioCalibrationData::~RadioCalibrationData()
...
@@ -38,7 +38,7 @@ RadioCalibrationData::~RadioCalibrationData()
delete
data
;
delete
data
;
}
}
const
floa
t
*
RadioCalibrationData
::
operator
[](
int
i
)
const
const
uint16_
t
*
RadioCalibrationData
::
operator
[](
int
i
)
const
{
{
if
(
i
<
data
->
size
())
{
if
(
i
<
data
->
size
())
{
return
(
*
data
)[
i
].
constData
();
return
(
*
data
)[
i
].
constData
();
...
@@ -47,7 +47,7 @@ const float* RadioCalibrationData::operator [](int i) const
...
@@ -47,7 +47,7 @@ const float* RadioCalibrationData::operator [](int i) const
return
NULL
;
return
NULL
;
}
}
const
QVector
<
floa
t
>&
RadioCalibrationData
::
operator
()(
const
int
i
)
const
throw
(
std
::
out_of_range
)
const
QVector
<
uint16_
t
>&
RadioCalibrationData
::
operator
()(
const
int
i
)
const
throw
(
std
::
out_of_range
)
{
{
if
((
i
<
data
->
size
())
&&
(
i
>=
0
))
{
if
((
i
<
data
->
size
())
&&
(
i
>=
0
))
{
return
(
*
data
)[
i
];
return
(
*
data
)[
i
];
...
...
src/ui/RadioCalibration/RadioCalibrationData.h
View file @
9481145a
...
@@ -36,6 +36,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -36,6 +36,8 @@ This file is part of the QGROUNDCONTROL project
#include
<QString>
#include
<QString>
#include
<stdexcept>
#include
<stdexcept>
#include
<stdint.h>
/**
/**
@brief Class to hold the calibration data.
@brief Class to hold the calibration data.
...
@@ -48,12 +50,12 @@ class RadioCalibrationData : public QObject
...
@@ -48,12 +50,12 @@ class RadioCalibrationData : public QObject
public:
public:
explicit
RadioCalibrationData
();
explicit
RadioCalibrationData
();
RadioCalibrationData
(
const
RadioCalibrationData
&
);
RadioCalibrationData
(
const
RadioCalibrationData
&
);
RadioCalibrationData
(
const
QVector
<
floa
t
>&
aileron
,
RadioCalibrationData
(
const
QVector
<
uint16_
t
>&
aileron
,
const
QVector
<
floa
t
>&
elevator
,
const
QVector
<
uint16_
t
>&
elevator
,
const
QVector
<
floa
t
>&
rudder
,
const
QVector
<
uint16_
t
>&
rudder
,
const
QVector
<
floa
t
>&
gyro
,
const
QVector
<
uint16_
t
>&
gyro
,
const
QVector
<
floa
t
>&
pitch
,
const
QVector
<
uint16_
t
>&
pitch
,
const
QVector
<
floa
t
>&
throttle
);
const
QVector
<
uint16_
t
>&
throttle
);
~
RadioCalibrationData
();
~
RadioCalibrationData
();
enum
RadioElement
{
enum
RadioElement
{
...
@@ -65,33 +67,33 @@ public:
...
@@ -65,33 +67,33 @@ public:
THROTTLE
THROTTLE
};
};
const
floa
t
*
operator
[](
int
i
)
const
;
const
uint16_
t
*
operator
[](
int
i
)
const
;
#ifdef _MSC_VER
#ifdef _MSC_VER
const
QVector
<
floa
t
>&
operator
()(
int
i
)
const
;
const
QVector
<
uint16_
t
>&
operator
()(
int
i
)
const
;
#else
#else
const
QVector
<
floa
t
>&
operator
()(
int
i
)
const
throw
(
std
::
out_of_range
);
const
QVector
<
uint16_
t
>&
operator
()(
int
i
)
const
throw
(
std
::
out_of_range
);
#endif
#endif
void
set
(
int
element
,
int
index
,
float
value
)
{
void
set
(
int
element
,
int
index
,
float
value
)
{
(
*
data
)[
element
][
index
]
=
value
;
(
*
data
)[
element
][
index
]
=
value
;
}
}
public
slots
:
public
slots
:
void
setAileron
(
int
index
,
floa
t
value
)
{
void
setAileron
(
int
index
,
uint16_
t
value
)
{
set
(
AILERON
,
index
,
value
);
set
(
AILERON
,
index
,
value
);
}
}
void
setElevator
(
int
index
,
floa
t
value
)
{
void
setElevator
(
int
index
,
uint16_
t
value
)
{
set
(
ELEVATOR
,
index
,
value
);
set
(
ELEVATOR
,
index
,
value
);
}
}
void
setRudder
(
int
index
,
floa
t
value
)
{
void
setRudder
(
int
index
,
uint16_
t
value
)
{
set
(
RUDDER
,
index
,
value
);
set
(
RUDDER
,
index
,
value
);
}
}
void
setGyro
(
int
index
,
floa
t
value
)
{
void
setGyro
(
int
index
,
uint16_
t
value
)
{
set
(
GYRO
,
index
,
value
);
set
(
GYRO
,
index
,
value
);
}
}
void
setPitch
(
int
index
,
floa
t
value
)
{
void
setPitch
(
int
index
,
uint16_
t
value
)
{
set
(
PITCH
,
index
,
value
);
set
(
PITCH
,
index
,
value
);
}
}
void
setThrottle
(
int
index
,
floa
t
value
)
{
void
setThrottle
(
int
index
,
uint16_
t
value
)
{
set
(
THROTTLE
,
index
,
value
);
set
(
THROTTLE
,
index
,
value
);
}
}
...
@@ -100,7 +102,7 @@ public:
...
@@ -100,7 +102,7 @@ public:
QString
toString
(
const
RadioElement
element
)
const
;
QString
toString
(
const
RadioElement
element
)
const
;
protected:
protected:
QVector
<
QVector
<
floa
t
>
>
*
data
;
QVector
<
QVector
<
uint16_
t
>
>
*
data
;
void
init
(
const
QVector
<
float
>&
aileron
,
void
init
(
const
QVector
<
float
>&
aileron
,
const
QVector
<
float
>&
elevator
,
const
QVector
<
float
>&
elevator
,
...
...
src/ui/RadioCalibration/RadioCalibrationWindow.h
View file @
9481145a
...
@@ -44,6 +44,8 @@ This file is part of the QGROUNDCONTROL project
...
@@ -44,6 +44,8 @@ This file is part of the QGROUNDCONTROL project
#include
<QtXml>
#include
<QtXml>
#include
<QTextStream>
#include
<QTextStream>
#include
<stdint.h>
#include
"AirfoilServoCalibrator.h"
#include
"AirfoilServoCalibrator.h"
#include
"SwitchCalibrator.h"
#include
"SwitchCalibrator.h"
#include
"CurveCalibrator.h"
#include
"CurveCalibrator.h"
...
...
src/ui/RadioCalibration/SwitchCalibrator.cc
View file @
9481145a
...
@@ -38,17 +38,17 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
...
@@ -38,17 +38,17 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
void
SwitchCalibrator
::
setDefault
()
void
SwitchCalibrator
::
setDefault
()
{
{
defaultPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()))
)
;
defaultPulseWidth
->
setText
(
QString
::
number
(
logExtrema
()));
emit
setpointChanged
(
0
,
logExtrema
());
emit
setpointChanged
(
0
,
logExtrema
());
}
}
void
SwitchCalibrator
::
setToggled
()
void
SwitchCalibrator
::
setToggled
()
{
{
toggledPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()))
)
;
toggledPulseWidth
->
setText
(
QString
::
number
(
logExtrema
()));
emit
setpointChanged
(
1
,
logExtrema
());
emit
setpointChanged
(
1
,
logExtrema
());
}
}
void
SwitchCalibrator
::
set
(
const
QVector
<
floa
t
>
&
data
)
void
SwitchCalibrator
::
set
(
const
QVector
<
uint16_
t
>
&
data
)
{
{
if
(
data
.
size
()
==
2
)
{
if
(
data
.
size
()
==
2
)
{
defaultPulseWidth
->
setText
(
QString
::
number
(
data
[
0
]));
defaultPulseWidth
->
setText
(
QString
::
number
(
data
[
0
]));
...
...
src/ui/RadioCalibration/SwitchCalibrator.h
View file @
9481145a
...
@@ -49,7 +49,7 @@ class SwitchCalibrator : public AbstractCalibrator
...
@@ -49,7 +49,7 @@ class SwitchCalibrator : public AbstractCalibrator
public:
public:
explicit
SwitchCalibrator
(
QString
title
=
QString
(),
QWidget
*
parent
=
0
);
explicit
SwitchCalibrator
(
QString
title
=
QString
(),
QWidget
*
parent
=
0
);
void
set
(
const
QVector
<
floa
t
>
&
data
);
void
set
(
const
QVector
<
uint16_
t
>
&
data
);
protected
slots
:
protected
slots
:
void
setDefault
();
void
setDefault
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment