Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
9481145a
Commit
9481145a
authored
Jul 15, 2011
by
Bryan Godbolt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on radio calibration window
parent
ca13be59
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
87 additions
and
54 deletions
+87
-54
UAS.cc
src/uas/UAS.cc
+6
-6
AbstractCalibrator.cc
src/ui/RadioCalibration/AbstractCalibrator.cc
+1
-1
AbstractCalibrator.h
src/ui/RadioCalibration/AbstractCalibrator.h
+1
-0
AirfoilServoCalibrator.cc
src/ui/RadioCalibration/AirfoilServoCalibrator.cc
+3
-3
CurveCalibrator.cc
src/ui/RadioCalibration/CurveCalibrator.cc
+35
-7
RadioCalibrationData.cc
src/ui/RadioCalibration/RadioCalibrationData.cc
+17
-17
RadioCalibrationData.h
src/ui/RadioCalibration/RadioCalibrationData.h
+18
-16
RadioCalibrationWindow.h
src/ui/RadioCalibration/RadioCalibrationWindow.h
+2
-0
SwitchCalibrator.cc
src/ui/RadioCalibration/SwitchCalibrator.cc
+3
-3
SwitchCalibrator.h
src/ui/RadioCalibration/SwitchCalibrator.h
+1
-1
No files found.
src/uas/UAS.cc
View file @
9481145a
...
...
@@ -958,12 +958,12 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message)
case
MAVLINK_MSG_ID_RADIO_CALIBRATION
:
{
mavlink_radio_calibration_t
radioMsg
;
mavlink_msg_radio_calibration_decode
(
&
message
,
&
radioMsg
);
QVector
<
floa
t
>
aileron
;
QVector
<
floa
t
>
elevator
;
QVector
<
floa
t
>
rudder
;
QVector
<
floa
t
>
gyro
;
QVector
<
floa
t
>
pitch
;
QVector
<
floa
t
>
throttle
;
QVector
<
uint16_
t
>
aileron
;
QVector
<
uint16_
t
>
elevator
;
QVector
<
uint16_
t
>
rudder
;
QVector
<
uint16_
t
>
gyro
;
QVector
<
uint16_
t
>
pitch
;
QVector
<
uint16_
t
>
throttle
;
for
(
int
i
=
0
;
i
<
MAVLINK_MSG_RADIO_CALIBRATION_FIELD_AILERON_LEN
;
++
i
)
aileron
<<
radioMsg
.
aileron
[
i
];
...
...
src/ui/RadioCalibration/AbstractCalibrator.cc
View file @
9481145a
...
...
@@ -3,7 +3,7 @@
AbstractCalibrator
::
AbstractCalibrator
(
QWidget
*
parent
)
:
QWidget
(
parent
),
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
#include <QVector>
#include <math.h>
#include <stdint.h>
/**
@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
void
AirfoilServoCalibrator
::
setHigh
()
{
highPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()
)));
highPulseWidth
->
setText
(
QString
::
number
(
logExtrema
(
)));
emit
setpointChanged
(
2
,
logExtrema
());
}
void
AirfoilServoCalibrator
::
setCenter
()
{
centerPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logAverage
()
)));
centerPulseWidth
->
setText
(
QString
::
number
(
logAverage
(
)));
emit
setpointChanged
(
1
,
logAverage
());
}
void
AirfoilServoCalibrator
::
setLow
()
{
lowPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()
)));
lowPulseWidth
->
setText
(
QString
::
number
(
logExtrema
(
)));
emit
setpointChanged
(
0
,
logExtrema
());
}
...
...
src/ui/RadioCalibration/CurveCalibrator.cc
View file @
9481145a
...
...
@@ -2,8 +2,8 @@
CurveCalibrator
::
CurveCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
AbstractCalibrator
(
parent
),
setpoints
(
new
QVector
<
double
>
(
5
)),
positions
(
new
QVector
<
double
>
())
setpoints
(
new
QVector
<
uint16_t
>
(
5
)),
positions
(
new
QVector
<
uint16_t
>
())
{
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
QLabel
*
title
=
new
QLabel
(
titleString
);
...
...
@@ -32,7 +32,17 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
curve
=
new
QwtPlotCurve
();
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
);
plot
->
replot
();
...
...
@@ -79,18 +89,36 @@ void CurveCalibrator::setSetpoint(int setpoint)
}
else
{
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
();
emit
setpointChanged
(
setpoint
,
s
tatic_cast
<
float
>
(
setpoints
->
value
(
setpoint
)
));
emit
setpointChanged
(
setpoint
,
s
etpoints
->
value
(
setpoint
));
}
void
CurveCalibrator
::
set
(
const
QVector
<
uint16_t
>
&
data
)
{
if
(
data
.
size
()
==
5
)
{
for
(
int
i
=
0
;
i
<
data
.
size
();
++
i
)
setpoints
->
replace
(
i
,
static_cast
<
double
>
(
data
[
i
]));
curve
->
setData
(
*
positions
,
*
setpoints
);
setpoints
->
replace
(
i
,
data
[
i
]);
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
();
}
else
{
qDebug
()
<<
__FILE__
<<
__LINE__
<<
": wrong data vector size"
;
...
...
src/ui/RadioCalibration/RadioCalibrationData.cc
View file @
9481145a
...
...
@@ -2,23 +2,23 @@
RadioCalibrationData
::
RadioCalibrationData
()
{
data
=
new
QVector
<
QVector
<
floa
t
>
>
(
6
);
(
*
data
).
insert
(
AILERON
,
QVector
<
floa
t
>
(
3
));
(
*
data
).
insert
(
ELEVATOR
,
QVector
<
floa
t
>
(
3
));
(
*
data
).
insert
(
RUDDER
,
QVector
<
floa
t
>
(
3
));
(
*
data
).
insert
(
GYRO
,
QVector
<
floa
t
>
(
2
));
(
*
data
).
insert
(
PITCH
,
QVector
<
floa
t
>
(
5
));
(
*
data
).
insert
(
THROTTLE
,
QVector
<
floa
t
>
(
5
));
data
=
new
QVector
<
QVector
<
uint16_
t
>
>
(
6
);
(
*
data
).
insert
(
AILERON
,
QVector
<
uint16_
t
>
(
3
));
(
*
data
).
insert
(
ELEVATOR
,
QVector
<
uint16_
t
>
(
3
));
(
*
data
).
insert
(
RUDDER
,
QVector
<
uint16_
t
>
(
3
));
(
*
data
).
insert
(
GYRO
,
QVector
<
uint16_
t
>
(
2
));
(
*
data
).
insert
(
PITCH
,
QVector
<
uint16_
t
>
(
5
));
(
*
data
).
insert
(
THROTTLE
,
QVector
<
uint16_
t
>
(
5
));
}
RadioCalibrationData
::
RadioCalibrationData
(
const
QVector
<
floa
t
>
&
aileron
,
const
QVector
<
floa
t
>
&
elevator
,
const
QVector
<
floa
t
>
&
rudder
,
const
QVector
<
floa
t
>
&
gyro
,
const
QVector
<
floa
t
>
&
pitch
,
const
QVector
<
floa
t
>
&
throttle
)
RadioCalibrationData
::
RadioCalibrationData
(
const
QVector
<
uint16_
t
>
&
aileron
,
const
QVector
<
uint16_
t
>
&
elevator
,
const
QVector
<
uint16_
t
>
&
rudder
,
const
QVector
<
uint16_
t
>
&
gyro
,
const
QVector
<
uint16_
t
>
&
pitch
,
const
QVector
<
uint16_
t
>
&
throttle
)
{
data
=
new
QVector
<
QVector
<
floa
t
>
>
();
data
=
new
QVector
<
QVector
<
uint16_
t
>
>
();
(
*
data
)
<<
aileron
<<
elevator
<<
rudder
...
...
@@ -30,7 +30,7 @@ RadioCalibrationData::RadioCalibrationData(const QVector<float> &aileron,
RadioCalibrationData
::
RadioCalibrationData
(
const
RadioCalibrationData
&
other
)
:
QObject
()
{
data
=
new
QVector
<
QVector
<
floa
t
>
>
(
*
other
.
data
);
data
=
new
QVector
<
QVector
<
uint16_
t
>
>
(
*
other
.
data
);
}
RadioCalibrationData
::~
RadioCalibrationData
()
...
...
@@ -38,7 +38,7 @@ RadioCalibrationData::~RadioCalibrationData()
delete
data
;
}
const
floa
t
*
RadioCalibrationData
::
operator
[](
int
i
)
const
const
uint16_
t
*
RadioCalibrationData
::
operator
[](
int
i
)
const
{
if
(
i
<
data
->
size
())
{
return
(
*
data
)[
i
].
constData
();
...
...
@@ -47,7 +47,7 @@ const float* RadioCalibrationData::operator [](int i) const
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
))
{
return
(
*
data
)[
i
];
...
...
src/ui/RadioCalibration/RadioCalibrationData.h
View file @
9481145a
...
...
@@ -36,6 +36,8 @@ This file is part of the QGROUNDCONTROL project
#include <QString>
#include <stdexcept>
#include <stdint.h>
/**
@brief Class to hold the calibration data.
...
...
@@ -48,12 +50,12 @@ class RadioCalibrationData : public QObject
public:
explicit
RadioCalibrationData
();
RadioCalibrationData
(
const
RadioCalibrationData
&
);
RadioCalibrationData
(
const
QVector
<
floa
t
>&
aileron
,
const
QVector
<
floa
t
>&
elevator
,
const
QVector
<
floa
t
>&
rudder
,
const
QVector
<
floa
t
>&
gyro
,
const
QVector
<
floa
t
>&
pitch
,
const
QVector
<
floa
t
>&
throttle
);
RadioCalibrationData
(
const
QVector
<
uint16_
t
>&
aileron
,
const
QVector
<
uint16_
t
>&
elevator
,
const
QVector
<
uint16_
t
>&
rudder
,
const
QVector
<
uint16_
t
>&
gyro
,
const
QVector
<
uint16_
t
>&
pitch
,
const
QVector
<
uint16_
t
>&
throttle
);
~
RadioCalibrationData
();
enum
RadioElement
{
...
...
@@ -65,33 +67,33 @@ public:
THROTTLE
};
const
floa
t
*
operator
[](
int
i
)
const
;
const
uint16_
t
*
operator
[](
int
i
)
const
;
#ifdef _MSC_VER
const
QVector
<
floa
t
>&
operator
()(
int
i
)
const
;
const
QVector
<
uint16_
t
>&
operator
()(
int
i
)
const
;
#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
void
set
(
int
element
,
int
index
,
float
value
)
{
(
*
data
)[
element
][
index
]
=
value
;
}
public
slots
:
void
setAileron
(
int
index
,
floa
t
value
)
{
void
setAileron
(
int
index
,
uint16_
t
value
)
{
set
(
AILERON
,
index
,
value
);
}
void
setElevator
(
int
index
,
floa
t
value
)
{
void
setElevator
(
int
index
,
uint16_
t
value
)
{
set
(
ELEVATOR
,
index
,
value
);
}
void
setRudder
(
int
index
,
floa
t
value
)
{
void
setRudder
(
int
index
,
uint16_
t
value
)
{
set
(
RUDDER
,
index
,
value
);
}
void
setGyro
(
int
index
,
floa
t
value
)
{
void
setGyro
(
int
index
,
uint16_
t
value
)
{
set
(
GYRO
,
index
,
value
);
}
void
setPitch
(
int
index
,
floa
t
value
)
{
void
setPitch
(
int
index
,
uint16_
t
value
)
{
set
(
PITCH
,
index
,
value
);
}
void
setThrottle
(
int
index
,
floa
t
value
)
{
void
setThrottle
(
int
index
,
uint16_
t
value
)
{
set
(
THROTTLE
,
index
,
value
);
}
...
...
@@ -100,7 +102,7 @@ public:
QString
toString
(
const
RadioElement
element
)
const
;
protected:
QVector
<
QVector
<
floa
t
>
>
*
data
;
QVector
<
QVector
<
uint16_
t
>
>
*
data
;
void
init
(
const
QVector
<
float
>&
aileron
,
const
QVector
<
float
>&
elevator
,
...
...
src/ui/RadioCalibration/RadioCalibrationWindow.h
View file @
9481145a
...
...
@@ -44,6 +44,8 @@ This file is part of the QGROUNDCONTROL project
#include <QtXml>
#include <QTextStream>
#include <stdint.h>
#include "AirfoilServoCalibrator.h"
#include "SwitchCalibrator.h"
#include "CurveCalibrator.h"
...
...
src/ui/RadioCalibration/SwitchCalibrator.cc
View file @
9481145a
...
...
@@ -38,17 +38,17 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
void
SwitchCalibrator
::
setDefault
()
{
defaultPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()
)));
defaultPulseWidth
->
setText
(
QString
::
number
(
logExtrema
(
)));
emit
setpointChanged
(
0
,
logExtrema
());
}
void
SwitchCalibrator
::
setToggled
()
{
toggledPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
()
)));
toggledPulseWidth
->
setText
(
QString
::
number
(
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
)
{
defaultPulseWidth
->
setText
(
QString
::
number
(
data
[
0
]));
...
...
src/ui/RadioCalibration/SwitchCalibrator.h
View file @
9481145a
...
...
@@ -49,7 +49,7 @@ class SwitchCalibrator : public AbstractCalibrator
public:
explicit
SwitchCalibrator
(
QString
title
=
QString
(),
QWidget
*
parent
=
0
);
void
set
(
const
QVector
<
floa
t
>
&
data
);
void
set
(
const
QVector
<
uint16_
t
>
&
data
);
protected
slots
:
void
setDefault
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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