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
95011df1
Commit
95011df1
authored
Sep 20, 2010
by
Bryan Godbolt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filled in functions for airfoils and switch
parent
a47b16fb
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
206 additions
and
44 deletions
+206
-44
qgroundcontrol.pro
qgroundcontrol.pro
+4
-2
AbstractCalibrator.cc
src/ui/RadioCalibration/AbstractCalibrator.cc
+52
-0
AbstractCalibrator.h
src/ui/RadioCalibration/AbstractCalibrator.h
+26
-0
AirfoilServoCalibrator.cc
src/ui/RadioCalibration/AirfoilServoCalibrator.cc
+70
-4
AirfoilServoCalibrator.h
src/ui/RadioCalibration/AirfoilServoCalibrator.h
+12
-12
CurveCalibrator.cc
src/ui/RadioCalibration/CurveCalibrator.cc
+1
-6
CurveCalibrator.h
src/ui/RadioCalibration/CurveCalibrator.h
+3
-4
SwitchCalibrator.cc
src/ui/RadioCalibration/SwitchCalibrator.cc
+29
-5
SwitchCalibrator.h
src/ui/RadioCalibration/SwitchCalibrator.h
+9
-11
No files found.
qgroundcontrol.pro
View file @
95011df1
...
@@ -164,7 +164,8 @@ HEADERS += src/MG.h \
...
@@ -164,7 +164,8 @@ HEADERS += src/MG.h \
src
/
ui
/
RadioCalibration
/
RadioCalibrationWindow
.
h
\
src
/
ui
/
RadioCalibration
/
RadioCalibrationWindow
.
h
\
src
/
ui
/
RadioCalibration
/
AirfoilServoCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AirfoilServoCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
h
SOURCES
+=
src
/
main
.
cc
\
SOURCES
+=
src
/
main
.
cc
\
src
/
Core
.
cc
\
src
/
Core
.
cc
\
src
/
uas
/
UASManager
.
cc
\
src
/
uas
/
UASManager
.
cc
\
...
@@ -234,7 +235,8 @@ SOURCES += src/main.cc \
...
@@ -234,7 +235,8 @@ SOURCES += src/main.cc \
src
/
ui
/
RadioCalibration
/
RadioCalibrationWindow
.
cc
\
src
/
ui
/
RadioCalibration
/
RadioCalibrationWindow
.
cc
\
src
/
ui
/
RadioCalibration
/
AirfoilServoCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AirfoilServoCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
SwitchCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
cc
RESOURCES
=
mavground
.
qrc
RESOURCES
=
mavground
.
qrc
#
Include
RT
-
LAB
Library
#
Include
RT
-
LAB
Library
...
...
src/ui/RadioCalibration/AbstractCalibrator.cc
0 → 100644
View file @
95011df1
#include "AbstractCalibrator.h"
AbstractCalibrator
::
AbstractCalibrator
(
QWidget
*
parent
)
:
QWidget
(
parent
),
pulseWidth
(
new
QLabel
()),
log
(
new
QVector
<
float
>
())
{
}
AbstractCalibrator
::~
AbstractCalibrator
()
{
delete
log
;
}
float
AbstractCalibrator
::
logAverage
()
{
float
total
=
0
;
for
(
int
i
=
0
;
i
<
log
->
size
();
++
i
)
total
+=
log
->
value
(
i
);
return
(
total
/
log
->
size
());
}
float
AbstractCalibrator
::
logExtrema
()
{
float
extrema
=
logAverage
();
if
(
logAverage
()
<
1500
)
{
for
(
int
i
=
0
;
i
<
log
->
size
();
++
i
)
{
if
(
log
->
value
(
i
)
<
extrema
)
extrema
=
log
->
value
(
i
);
}
}
else
{
for
(
int
i
=
0
;
i
<
log
->
size
();
++
i
)
{
if
(
log
->
value
(
i
)
>
extrema
)
extrema
=
log
->
value
(
i
);
}
}
return
extrema
;
}
void
AbstractCalibrator
::
channelChanged
(
float
raw
)
{
pulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
raw
)));
if
(
log
->
size
()
==
5
)
log
->
pop_front
();
log
->
push_back
(
raw
);
}
src/ui/RadioCalibration/AbstractCalibrator.h
0 → 100644
View file @
95011df1
#ifndef ABSTRACTCALIBRATOR_H
#define ABSTRACTCALIBRATOR_H
#include <QWidget>
#include <QString>
#include <QLabel>
class
AbstractCalibrator
:
public
QWidget
{
Q_OBJECT
public:
explicit
AbstractCalibrator
(
QWidget
*
parent
=
0
);
~
AbstractCalibrator
();
public
slots
:
void
channelChanged
(
float
raw
);
protected:
QLabel
*
pulseWidth
;
QVector
<
float
>
*
log
;
float
logExtrema
();
float
logAverage
();
};
#endif // ABSTRACTCALIBRATOR_H
src/ui/RadioCalibration/AirfoilServoCalibrator.cc
View file @
95011df1
#include "AirfoilServoCalibrator.h"
#include "AirfoilServoCalibrator.h"
AirfoilServoCalibrator
::
AirfoilServoCalibrator
(
AirfoilType
type
,
QWidget
*
parent
)
:
AirfoilServoCalibrator
::
AirfoilServoCalibrator
(
AirfoilType
type
,
QWidget
*
parent
)
:
QWidget
(
parent
)
AbstractCalibrator
(
parent
),
highPulseWidth
(
new
QLabel
()),
centerPulseWidth
(
new
QLabel
()),
lowPulseWidth
(
new
QLabel
())
{
{
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
QGridLayout
*
grid
=
new
QGridLayout
(
this
);
...
@@ -26,16 +29,79 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
...
@@ -26,16 +29,79 @@ AirfoilServoCalibrator::AirfoilServoCalibrator(AirfoilType type, QWidget *parent
/* Add current Pulse Width Display */
/* Add current Pulse Width Display */
QLabel
*
pulseWidthTitle
=
new
QLabel
(
tr
(
"Pulse Width (us)"
));
QLabel
*
pulseWidthTitle
=
new
QLabel
(
tr
(
"Pulse Width (us)"
));
pulseWidth
=
new
QLabel
();
QHBoxLayout
*
pulseLayout
=
new
QHBoxLayout
();
QHBoxLayout
*
pulseLayout
=
new
QHBoxLayout
();
pulseLayout
->
addWidget
(
pulseWidthTitle
);
pulseLayout
->
addWidget
(
pulseWidthTitle
);
pulseLayout
->
addWidget
(
pulseWidth
);
pulseLayout
->
addWidget
(
pulseWidth
);
grid
->
addLayout
(
pulseLayout
,
1
,
0
,
1
,
3
);
grid
->
addLayout
(
pulseLayout
,
1
,
0
,
1
,
3
);
QLabel
*
highPulseString
;
QLabel
*
centerPulseString
;
QLabel
*
lowPulseString
;
if
(
type
==
AILERON
)
{
highPulseString
=
new
QLabel
(
tr
(
"Bank Left"
));
centerPulseString
=
new
QLabel
(
tr
(
"Center"
));
lowPulseString
=
new
QLabel
(
tr
(
"Bank Right"
));
}
else
if
(
type
==
ELEVATOR
)
{
highPulseString
=
new
QLabel
(
tr
(
"Nose Down"
));
centerPulseString
=
new
QLabel
(
tr
(
"Center"
));
lowPulseString
=
new
QLabel
(
tr
(
"Nose Up"
));
}
else
if
(
type
==
RUDDER
)
{
highPulseString
=
new
QLabel
(
tr
(
"Nose Left"
));
centerPulseString
=
new
QLabel
(
tr
(
"Center"
));
lowPulseString
=
new
QLabel
(
tr
(
"Nose Right"
));
}
else
{
highPulseString
=
new
QLabel
(
tr
(
"High"
));
centerPulseString
=
new
QLabel
(
tr
(
"Center"
));
lowPulseString
=
new
QLabel
(
tr
(
"Low"
));
}
QPushButton
*
highButton
=
new
QPushButton
(
tr
(
"Set"
));
QPushButton
*
centerButton
=
new
QPushButton
(
tr
(
"Set"
));
QPushButton
*
lowButton
=
new
QPushButton
(
tr
(
"Set"
));
grid
->
addWidget
(
highPulseString
,
2
,
0
);
grid
->
addWidget
(
highPulseWidth
,
2
,
1
);
grid
->
addWidget
(
highButton
,
2
,
2
);
grid
->
addWidget
(
centerPulseString
,
3
,
0
);
grid
->
addWidget
(
centerPulseWidth
,
3
,
1
);
grid
->
addWidget
(
centerButton
,
3
,
2
);
grid
->
addWidget
(
lowPulseString
,
4
,
0
);
grid
->
addWidget
(
lowPulseWidth
,
4
,
1
);
grid
->
addWidget
(
lowButton
,
4
,
2
);
this
->
setLayout
(
grid
);
this
->
setLayout
(
grid
);
connect
(
highButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setHigh
()));
connect
(
centerButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setCenter
()));
connect
(
lowButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setLow
()));
}
void
AirfoilServoCalibrator
::
setHigh
()
{
highPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
())));
emit
highSetpointChanged
(
logExtrema
());
}
void
AirfoilServoCalibrator
::
setCenter
()
{
centerPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logAverage
())));
emit
centerSetpointChanged
(
logAverage
());
}
}
void
AirfoilServoCalibrator
::
channelChanged
(
float
raw
)
void
AirfoilServoCalibrator
::
setLow
(
)
{
{
pulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
raw
)));
lowPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
())));
emit
lowSetpointChanged
(
logExtrema
());
}
}
src/ui/RadioCalibration/AirfoilServoCalibrator.h
View file @
95011df1
...
@@ -8,7 +8,9 @@
...
@@ -8,7 +8,9 @@
#include <QGridLayout>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QHBoxLayout>
class
AirfoilServoCalibrator
:
public
QWidget
#include "AbstractCalibrator.h"
class
AirfoilServoCalibrator
:
public
AbstractCalibrator
{
{
Q_OBJECT
Q_OBJECT
public:
public:
...
@@ -21,26 +23,24 @@ public:
...
@@ -21,26 +23,24 @@ public:
explicit
AirfoilServoCalibrator
(
AirfoilType
type
=
AILERON
,
QWidget
*
parent
=
0
);
explicit
AirfoilServoCalibrator
(
AirfoilType
type
=
AILERON
,
QWidget
*
parent
=
0
);
signals:
signals:
void
highSetpointChanged
(
float
);
void
highSetpointChanged
(
float
);
void
centerSetpointChanged
(
float
);
void
centerSetpointChanged
(
float
);
void
lowSetpointChanged
(
float
);
void
lowSetpointChanged
(
float
);
public
slots
:
protected
slots
:
void
channelChanged
(
float
raw
);
void
setHigh
();
protected:
void
setCenter
();
QLabel
*
pulseWidth
;
void
setLow
();
QPushButton
*
highButton
;
QPushButton
*
centerButton
;
protected:
QPushButton
*
lowButton
;
QLabel
*
highPulseWidth
;
QLabel
*
centerPulseWidth
;
QLabel
*
lowPulseWidth
;
float
high
;
float
high
;
float
center
;
float
center
;
float
low
;
float
low
;
QVector
<
float
>
log
;
};
};
#endif // AIRFOILSERVOCALIBRATOR_H
#endif // AIRFOILSERVOCALIBRATOR_H
src/ui/RadioCalibration/CurveCalibrator.cc
View file @
95011df1
#include "CurveCalibrator.h"
#include "CurveCalibrator.h"
CurveCalibrator
::
CurveCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
CurveCalibrator
::
CurveCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
QWidget
(
parent
),
AbstractCalibrator
(
parent
),
setpoints
(
QVector
<
double
>
(
5
)),
setpoints
(
QVector
<
double
>
(
5
)),
positions
(
QVector
<
double
>
())
positions
(
QVector
<
double
>
())
...
@@ -39,8 +39,3 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
...
@@ -39,8 +39,3 @@ CurveCalibrator::CurveCalibrator(QString titleString, QWidget *parent) :
this
->
setLayout
(
grid
);
this
->
setLayout
(
grid
);
}
}
void
CurveCalibrator
::
channelChanged
(
float
raw
)
{
pulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
raw
)));
}
src/ui/RadioCalibration/CurveCalibrator.h
View file @
95011df1
...
@@ -10,7 +10,9 @@
...
@@ -10,7 +10,9 @@
#include <QLabel>
#include <QLabel>
#include <QPushButton>
#include <QPushButton>
class
CurveCalibrator
:
public
QWidget
#include "AbstractCalibrator.h"
class
CurveCalibrator
:
public
AbstractCalibrator
{
{
Q_OBJECT
Q_OBJECT
public:
public:
...
@@ -18,15 +20,12 @@ public:
...
@@ -18,15 +20,12 @@ public:
signals:
signals:
void
setpointChanged
(
float
[
5
]);
void
setpointChanged
(
float
[
5
]);
public
slots
:
void
channelChanged
(
float
raw
);
protected:
protected:
QVector
<
double
>
setpoints
;
QVector
<
double
>
setpoints
;
QVector
<
double
>
positions
;
QVector
<
double
>
positions
;
QwtPlot
*
plot
;
QwtPlot
*
plot
;
QwtPlotCurve
*
curve
;
QwtPlotCurve
*
curve
;
QLabel
*
pulseWidth
;
};
};
#endif // CURVECALIBRATOR_H
#endif // CURVECALIBRATOR_H
src/ui/RadioCalibration/SwitchCalibrator.cc
View file @
95011df1
#include "SwitchCalibrator.h"
#include "SwitchCalibrator.h"
SwitchCalibrator
::
SwitchCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
SwitchCalibrator
::
SwitchCalibrator
(
QString
titleString
,
QWidget
*
parent
)
:
QWidget
(
parent
)
AbstractCalibrator
(
parent
),
defaultPulseWidth
(
new
QLabel
()),
toggledPulseWidth
(
new
QLabel
())
{
{
/* Add title label*/
/* Add title label*/
QLabel
*
title
=
new
QLabel
(
titleString
);
QLabel
*
title
=
new
QLabel
(
titleString
);
...
@@ -9,17 +11,39 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
...
@@ -9,17 +11,39 @@ SwitchCalibrator::SwitchCalibrator(QString titleString, QWidget *parent) :
grid
->
addWidget
(
title
,
0
,
0
,
1
,
3
);
grid
->
addWidget
(
title
,
0
,
0
,
1
,
3
);
/* Add current Pulse Width Display */
/* Add current Pulse Width Display */
QLabel
*
pulseWidthTitle
=
new
QLabel
(
tr
(
"Pulse Width (us)"
));
QLabel
*
pulseWidthTitle
=
new
QLabel
(
tr
(
"Pulse Width (us)"
));
pulseWidth
=
new
QLabel
();
QHBoxLayout
*
pulseLayout
=
new
QHBoxLayout
();
QHBoxLayout
*
pulseLayout
=
new
QHBoxLayout
();
pulseLayout
->
addWidget
(
pulseWidthTitle
);
pulseLayout
->
addWidget
(
pulseWidthTitle
);
pulseLayout
->
addWidget
(
pulseWidth
);
pulseLayout
->
addWidget
(
pulseWidth
);
grid
->
addLayout
(
pulseLayout
,
1
,
0
,
1
,
3
);
grid
->
addLayout
(
pulseLayout
,
1
,
0
,
1
,
3
);
QLabel
*
defaultPulseString
=
new
QLabel
(
tr
(
"Default Position"
));
QPushButton
*
defaultButton
=
new
QPushButton
(
tr
(
"Set"
));
grid
->
addWidget
(
defaultPulseString
,
2
,
0
);
grid
->
addWidget
(
defaultPulseWidth
,
2
,
1
);
grid
->
addWidget
(
defaultButton
,
2
,
2
);
QLabel
*
toggledPulseString
=
new
QLabel
(
tr
(
"Toggled Position"
));
QPushButton
*
toggledButton
=
new
QPushButton
(
tr
(
"Set"
));
grid
->
addWidget
(
toggledPulseString
,
3
,
0
);
grid
->
addWidget
(
toggledPulseWidth
,
3
,
1
);
grid
->
addWidget
(
toggledButton
,
3
,
2
);
this
->
setLayout
(
grid
);
this
->
setLayout
(
grid
);
connect
(
defaultButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setDefault
()));
connect
(
toggledButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
setToggled
()));
}
void
SwitchCalibrator
::
setDefault
()
{
defaultPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
())));
emit
defaultSetpointChanged
(
logExtrema
());
}
}
void
SwitchCalibrator
::
channelChanged
(
float
raw
)
void
SwitchCalibrator
::
setToggled
(
)
{
{
pulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
raw
)));
toggledPulseWidth
->
setText
(
QString
::
number
(
static_cast
<
double
>
(
logExtrema
())));
emit
toggledSetpointChanged
(
logExtrema
());
}
}
src/ui/RadioCalibration/SwitchCalibrator.h
View file @
95011df1
...
@@ -8,7 +8,9 @@
...
@@ -8,7 +8,9 @@
#include <QGridLayout>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QHBoxLayout>
class
SwitchCalibrator
:
public
QWidget
#include "AbstractCalibrator.h"
class
SwitchCalibrator
:
public
AbstractCalibrator
{
{
Q_OBJECT
Q_OBJECT
public:
public:
...
@@ -18,17 +20,13 @@ signals:
...
@@ -18,17 +20,13 @@ signals:
void
defaultSetpointChanged
(
float
);
void
defaultSetpointChanged
(
float
);
void
toggledSetpointChanged
(
float
);
void
toggledSetpointChanged
(
float
);
public
slots
:
protected
slots
:
void
channelChanged
(
float
raw
);
void
setDefault
();
protected:
void
setToggled
();
QLabel
*
pulseWidth
;
QPushButton
*
defaultButton
;
QPushButton
*
toggledButton
;
float
defaultPos
;
float
toggled
;
QVector
<
float
>
log
;
protected:
QLabel
*
defaultPulseWidth
;
QLabel
*
toggledPulseWidth
;
};
};
...
...
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