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
b397e0be
Unverified
Commit
b397e0be
authored
Sep 04, 2019
by
Don Gagne
Committed by
GitHub
Sep 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7477 from Williangalvani/addCsv
Add csv logging of telemetry
parents
8f919fed
1daf1e79
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
0 deletions
+85
-0
App.SettingsGroup.json
src/Settings/App.SettingsGroup.json
+7
-0
AppSettings.cc
src/Settings/AppSettings.cc
+1
-0
AppSettings.h
src/Settings/AppSettings.h
+1
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+63
-0
Vehicle.h
src/Vehicle/Vehicle.h
+5
-0
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+8
-0
No files found.
src/Settings/App.SettingsGroup.json
View file @
b397e0be
...
...
@@ -263,5 +263,12 @@
"longDescription"
:
"Use Link Pairing."
,
"type"
:
"bool"
,
"defaultValue"
:
false
},
{
"name"
:
"saveCsvTelemetry"
,
"shortDescription"
:
"Save CSV Telementry Logs"
,
"longDescription"
:
"If this option is enabled, all Facts will be written to a CSV file with a 1 Hertz frequency."
,
"type"
:
"bool"
,
"defaultValue"
:
false
}
]
src/Settings/AppSettings.cc
View file @
b397e0be
...
...
@@ -97,6 +97,7 @@ DECLARE_SETTINGSFACT(AppSettings, enableMicrohard)
DECLARE_SETTINGSFACT
(
AppSettings
,
language
)
DECLARE_SETTINGSFACT
(
AppSettings
,
disableAllPersistence
)
DECLARE_SETTINGSFACT
(
AppSettings
,
usePairing
)
DECLARE_SETTINGSFACT
(
AppSettings
,
saveCsvTelemetry
)
DECLARE_SETTINGSFACT_NO_FUNC
(
AppSettings
,
indoorPalette
)
{
...
...
src/Settings/AppSettings.h
View file @
b397e0be
...
...
@@ -52,6 +52,7 @@ public:
DEFINE_SETTINGFACT
(
language
)
DEFINE_SETTINGFACT
(
disableAllPersistence
)
DEFINE_SETTINGFACT
(
usePairing
)
DEFINE_SETTINGFACT
(
saveCsvTelemetry
)
// Although this is a global setting it only affects ArduPilot vehicle since PX4 automatically starts the stream from the vehicle side
DEFINE_SETTINGFACT
(
apmStartMavlinkStreams
)
...
...
src/Vehicle/Vehicle.cc
View file @
b397e0be
...
...
@@ -111,6 +111,7 @@ Vehicle::Vehicle(LinkInterface* link,
,
_soloFirmware
(
false
)
,
_toolbox
(
qgcApp
()
->
toolbox
())
,
_settingsManager
(
_toolbox
->
settingsManager
())
,
_csvLogTimer
(
this
)
,
_joystickMode
(
JoystickModeRC
)
,
_joystickEnabled
(
false
)
,
_uas
(
nullptr
)
...
...
@@ -302,6 +303,10 @@ Vehicle::Vehicle(LinkInterface* link,
connect
(
&
_adsbTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_adsbTimerTimeout
);
_adsbTimer
.
setSingleShot
(
false
);
_adsbTimer
.
start
(
1000
);
// Start csv logger
connect
(
&
_csvLogTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_writeCsvLine
);
_csvLogTimer
.
start
(
1000
);
}
// Disconnected Vehicle for offline editing
...
...
@@ -323,6 +328,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
,
_soloFirmware
(
false
)
,
_toolbox
(
qgcApp
()
->
toolbox
())
,
_settingsManager
(
_toolbox
->
settingsManager
())
,
_csvLogTimer
(
this
)
,
_joystickMode
(
JoystickModeRC
)
,
_joystickEnabled
(
false
)
,
_uas
(
nullptr
)
...
...
@@ -4005,6 +4011,63 @@ void Vehicle::_pidTuningAdjustRates(bool setRatesForTuning)
_setpointFactGroup
.
setLiveUpdates
(
setRatesForTuning
);
}
void
Vehicle
::
_initializeCsv
()
{
if
(
!
_toolbox
->
settingsManager
()
->
appSettings
()
->
saveCsvTelemetry
()
->
rawValue
().
toBool
()){
return
;
}
QString
now
=
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd hh-mm-ss"
);
QString
fileName
=
QString
(
"%1 vehicle%2.csv"
).
arg
(
now
).
arg
(
_id
);
QDir
saveDir
(
_toolbox
->
settingsManager
()
->
appSettings
()
->
telemetrySavePath
());
_csvLogFile
.
setFileName
(
saveDir
.
absoluteFilePath
(
fileName
));
if
(
!
_csvLogFile
.
open
(
QIODevice
::
Append
))
{
qCWarning
(
VehicleLog
)
<<
"unable to open file for csv logging, Stopping csv logging!"
;
return
;
}
QTextStream
stream
(
&
_csvLogFile
);
QStringList
allFactNames
;
allFactNames
<<
factNames
();
for
(
const
QString
&
groupName
:
factGroupNames
())
{
for
(
const
QString
&
factName
:
getFactGroup
(
groupName
)
->
factNames
()){
allFactNames
<<
QString
(
"%1.%2"
).
arg
(
groupName
,
factName
);
}
}
qCDebug
(
VehicleLog
)
<<
"Facts logged to csv:"
<<
allFactNames
;
stream
<<
"Timestamp,"
<<
allFactNames
.
join
(
","
)
<<
"
\n
"
;
}
void
Vehicle
::
_writeCsvLine
()
{
// Only save the logs after the the vehicle gets armed, unless "Save logs even if vehicle was not armed" is checked
if
(
!
_csvLogFile
.
isOpen
()
&&
(
_armed
||
_toolbox
->
settingsManager
()
->
appSettings
()
->
telemetrySaveNotArmed
()
->
rawValue
().
toBool
())){
_initializeCsv
();
}
if
(
!
_csvLogFile
.
isOpen
()){
return
;
}
QStringList
allFactValues
;
QTextStream
stream
(
&
_csvLogFile
);
// Write timestamp to csv file
allFactValues
<<
QDateTime
::
currentDateTime
().
toString
();
// Write Vehicle's own facts
for
(
const
QString
&
factName
:
factNames
())
{
allFactValues
<<
getFact
(
factName
)
->
cookedValueString
();
}
// write facts from Vehicle's FactGroups
for
(
const
QString
&
groupName
:
factGroupNames
())
{
for
(
const
QString
&
factName
:
getFactGroup
(
groupName
)
->
factNames
())
{
allFactValues
<<
getFactGroup
(
groupName
)
->
getFact
(
factName
)
->
cookedValueString
();
}
}
stream
<<
allFactValues
.
join
(
","
)
<<
"
\n
"
;
}
#if !defined(NO_ARDUPILOT_DIALECT)
void
Vehicle
::
flashBootloader
(
void
)
...
...
src/Vehicle/Vehicle.h
View file @
b397e0be
...
...
@@ -1331,6 +1331,8 @@ private:
void
_pidTuningAdjustRates
(
bool
setRatesForTuning
);
void
_handleUnsupportedRequestAutopilotCapabilities
(
void
);
void
_handleUnsupportedRequestProtocolVersion
(
void
);
void
_initializeCsv
();
void
_writeCsvLine
();
int
_id
;
///< Mavlink system id
int
_defaultComponentId
;
...
...
@@ -1347,6 +1349,9 @@ private:
QGCToolbox
*
_toolbox
;
SettingsManager
*
_settingsManager
;
QTimer
_csvLogTimer
;
QFile
_csvLogFile
;
QList
<
LinkInterface
*>
_links
;
JoystickMode_t
_joystickMode
;
...
...
src/ui/preferences/GeneralSettings.qml
View file @
b397e0be
...
...
@@ -420,6 +420,14 @@ Rectangle {
enabled
:
promptSaveLog
.
checked
&&
!
disableDataPersistence
.
checked
property
Fact
_telemetrySaveNotArmed
:
QGroundControl
.
settingsManager
.
appSettings
.
telemetrySaveNotArmed
}
FactCheckBox
{
id
:
promptSaveCsv
text
:
qsTr
(
"
Save CSV log of telemetry data
"
)
fact
:
_saveCsvTelemetry
visible
:
_saveCsvTelemetry
.
visible
enabled
:
!
disableDataPersistence
.
checked
property
Fact
_saveCsvTelemetry
:
QGroundControl
.
settingsManager
.
appSettings
.
saveCsvTelemetry
}
}
}
...
...
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