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
eaf48fe3
Commit
eaf48fe3
authored
May 21, 2019
by
Willian Galvani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vehicle: add csv logging of facts
parent
cbed3887
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+50
-0
Vehicle.h
src/Vehicle/Vehicle.h
+5
-0
No files found.
src/Vehicle/Vehicle.cc
View file @
eaf48fe3
...
...
@@ -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,7 @@ Vehicle::Vehicle(LinkInterface* link,
connect
(
&
_adsbTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_adsbTimerTimeout
);
_adsbTimer
.
setSingleShot
(
false
);
_adsbTimer
.
start
(
1000
);
_initializeCsv
();
}
// Disconnected Vehicle for offline editing
...
...
@@ -323,6 +325,7 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
,
_soloFirmware
(
false
)
,
_toolbox
(
qgcApp
()
->
toolbox
())
,
_settingsManager
(
_toolbox
->
settingsManager
())
,
_csvLogTimer
(
this
)
,
_joystickMode
(
JoystickModeRC
)
,
_joystickEnabled
(
false
)
,
_uas
(
nullptr
)
...
...
@@ -4005,6 +4008,53 @@ void Vehicle::_pidTuningAdjustRates(bool setRatesForTuning)
_setpointFactGroup
.
setLiveUpdates
(
setRatesForTuning
);
}
void
Vehicle
::
_initializeCsv
()
{
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
"
;
connect
(
&
_csvLogTimer
,
&
QTimer
::
timeout
,
this
,
&
Vehicle
::
_writeCsvLine
);
_csvLogTimer
.
start
(
1000
);
}
void
Vehicle
::
_writeCsvLine
()
{
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 @
eaf48fe3
...
...
@@ -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
;
...
...
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