ardupilot-log-reader 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/PKG-INFO +1 -1
- ardupilot_log_reader-0.2.0/ReadMe.md +18 -0
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader/reader.py +20 -65
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/PKG-INFO +1 -1
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/SOURCES.txt +3 -1
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/setup.cfg +1 -1
- ardupilot_log_reader-0.2.0/tests/test_ardupilot.py +51 -0
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader/__init__.py +0 -0
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/dependency_links.txt +0 -0
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/requires.txt +0 -0
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/top_level.txt +0 -0
- {ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/setup.py +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Ardupilot Log Reader
|
|
2
|
+
|
|
3
|
+
This package wraps untidily around mavlogdump in pymavlink, to read an ardupilot log to a pandas dataframe.
|
|
4
|
+
|
|
5
|
+
## usage
|
|
6
|
+
|
|
7
|
+
#set up the parser
|
|
8
|
+
from ArdupilotLogReader import Ardupilot
|
|
9
|
+
parser = Ardupilot(
|
|
10
|
+
log_file, # the log file, .bin
|
|
11
|
+
types = ['ARSP', 'ATT', 'BARO', 'GPS', 'IMU', 'RCIN', 'RCOU', 'BAT', 'MODE', 'NKF1', 'STAT', 'XKF1'], # fields to read from the log
|
|
12
|
+
zero_time_base=True # arguments passed to pymavlink
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
parser.dfs # a dict containing a dataframes of log data for each field requested.
|
|
16
|
+
parser.join_logs(['ARSP', 'ATT']) #returns a pandas dataframe containing the ARSP and ATT data joined on time
|
|
17
|
+
parser.parms # returns the parameters read from the top of the log
|
|
18
|
+
|
|
@@ -86,13 +86,6 @@ class Ardupilot(object):
|
|
|
86
86
|
dialect=dialect,
|
|
87
87
|
zero_time_base=zero_time_base)
|
|
88
88
|
|
|
89
|
-
ext = os.path.splitext(filename)[1]
|
|
90
|
-
isbin = ext in ['.bin', '.BIN', '.px4log']
|
|
91
|
-
islog = ext in ['.log', '.LOG'] # NOTE: "islog" does not mean a tlog
|
|
92
|
-
istlog = ext in ['.tlog', '.TLOG']
|
|
93
|
-
|
|
94
|
-
# Track types found
|
|
95
|
-
available_types = set()
|
|
96
89
|
|
|
97
90
|
types = list(set(types + ['PARM']))
|
|
98
91
|
|
|
@@ -134,10 +127,8 @@ class Ardupilot(object):
|
|
|
134
127
|
continue
|
|
135
128
|
if link is not None and link != m._link:
|
|
136
129
|
continue
|
|
137
|
-
|
|
138
130
|
if types is not None and m.get_type() != 'BAD_DATA' and not match_type(m.get_type(), types):
|
|
139
131
|
continue
|
|
140
|
-
|
|
141
132
|
if nottypes is not None and match_type(m.get_type(), nottypes):
|
|
142
133
|
continue
|
|
143
134
|
|
|
@@ -146,65 +137,29 @@ class Ardupilot(object):
|
|
|
146
137
|
if m.get_type() == 'BAD_DATA':
|
|
147
138
|
continue
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
timestamp = getattr(m, '_timestamp', 0.0)
|
|
140
|
+
key=m.get_type()
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
dfs_dicts[
|
|
154
|
-
|
|
155
|
-
dfs_dicts[m.get_type()] = {}
|
|
156
|
-
dfs_dicts[m.get_type()]['timestamp'] = []
|
|
142
|
+
if not key in dfs_dicts:
|
|
143
|
+
dfs_dicts[key] = {}
|
|
144
|
+
dfs_dicts[key]['timestamp'] = []
|
|
157
145
|
for field in m.get_fieldnames():
|
|
158
|
-
dfs_dicts[
|
|
146
|
+
dfs_dicts[key][field] = []
|
|
147
|
+
|
|
148
|
+
dfs_dicts[key]['timestamp'].append( getattr(m,'_timestamp', 0.0) )
|
|
159
149
|
|
|
160
|
-
dfs_dicts[m.get_type()]['timestamp'].append( getattr(m,'_timestamp', 0.0) )
|
|
161
150
|
for field in m.get_fieldnames():
|
|
162
|
-
dfs_dicts[
|
|
163
|
-
|
|
164
|
-
self._dfs = {}
|
|
165
|
-
for msgType in dfs_dicts.keys():
|
|
166
|
-
self._dfs[msgType] = pd.DataFrame(data=dfs_dicts[msgType])
|
|
167
|
-
|
|
168
|
-
new_cols = []
|
|
169
|
-
for val in self._dfs[msgType].columns:
|
|
170
|
-
if val == 'timestamp':
|
|
171
|
-
new_cols.append(val)
|
|
172
|
-
else:
|
|
173
|
-
new_cols.append(msgType + val)
|
|
174
|
-
|
|
175
|
-
self._dfs[msgType].columns = new_cols
|
|
176
|
-
|
|
151
|
+
dfs_dicts[key][field].append( getattr(m,field) )
|
|
152
|
+
|
|
177
153
|
mlog.filehandle.close()
|
|
178
154
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
"""Merge logs on timestamp
|
|
191
|
-
"""
|
|
192
|
-
available_titles = [title for title in titles if title in self.dfs.keys()]
|
|
193
|
-
joined_log = self.dfs[available_titles[0]]
|
|
194
|
-
for title in available_titles[1:]:
|
|
195
|
-
if title=='PARM':
|
|
196
|
-
continue
|
|
197
|
-
ln= len(self.dfs[title])
|
|
198
|
-
l0 = len(joined_log)
|
|
199
|
-
joined_log = pd.merge_asof(
|
|
200
|
-
joined_log,
|
|
201
|
-
self.dfs[title],
|
|
202
|
-
on='timestamp'
|
|
203
|
-
)
|
|
204
|
-
l1 = len(joined_log)
|
|
205
|
-
if l1 < l0:
|
|
206
|
-
pass
|
|
207
|
-
return joined_log
|
|
208
|
-
|
|
209
|
-
def full_df(self):
|
|
210
|
-
return self.join_logs(list(self.dfs.keys())) # TODO remove PARA from here.
|
|
155
|
+
self.dfs = {}
|
|
156
|
+
for k, v in dfs_dicts.items():
|
|
157
|
+
self.dfs[k] = pd.DataFrame(v)
|
|
158
|
+
#self.dfs[k].columns = list(v.keys())#[val if val == "timestamp" else k + val for val in v.keys()]
|
|
159
|
+
self.parms = self.dfs['PARM'].set_index('Name')['Value'].to_dict()
|
|
160
|
+
|
|
161
|
+
def __getattr__(self, name):
|
|
162
|
+
if name in self.dfs:
|
|
163
|
+
return self.dfs[name]
|
|
164
|
+
raise AttributeError(f"No such attribute: {name}")
|
|
165
|
+
|
{ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/SOURCES.txt
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
ReadMe.md
|
|
1
2
|
setup.cfg
|
|
2
3
|
setup.py
|
|
3
4
|
ardupilot_log_reader/__init__.py
|
|
@@ -6,4 +7,5 @@ ardupilot_log_reader.egg-info/PKG-INFO
|
|
|
6
7
|
ardupilot_log_reader.egg-info/SOURCES.txt
|
|
7
8
|
ardupilot_log_reader.egg-info/dependency_links.txt
|
|
8
9
|
ardupilot_log_reader.egg-info/requires.txt
|
|
9
|
-
ardupilot_log_reader.egg-info/top_level.txt
|
|
10
|
+
ardupilot_log_reader.egg-info/top_level.txt
|
|
11
|
+
tests/test_ardupilot.py
|
|
@@ -5,7 +5,7 @@ author_email = thomasdavid0@gmail.com
|
|
|
5
5
|
description = module to read ardupilot binary logs to memory
|
|
6
6
|
long_description = file: ReadMe.md
|
|
7
7
|
long_description_content_type = text/markdown
|
|
8
|
-
version = 0.
|
|
8
|
+
version = 0.2.0
|
|
9
9
|
url = https://github.com/PyFlightCoach/ardupilot_log_reader
|
|
10
10
|
|
|
11
11
|
[options]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
3
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
4
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
5
|
+
version.
|
|
6
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
7
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
8
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
9
|
+
You should have received a copy of the GNU General Public License along with
|
|
10
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
11
|
+
"""
|
|
12
|
+
from ardupilot_log_reader.reader import Ardupilot
|
|
13
|
+
import numpy as np
|
|
14
|
+
import pandas as pd
|
|
15
|
+
|
|
16
|
+
import pytest
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture(scope="session")
|
|
20
|
+
def type_request():
|
|
21
|
+
return ['XKF1', 'XKQ1', 'ARSP', 'GPS', 'RCIN', 'RCOU', 'IMU', 'BARO', 'MODE', 'RPM', 'MAG']
|
|
22
|
+
|
|
23
|
+
@pytest.fixture(scope="session")
|
|
24
|
+
def log(type_request):
|
|
25
|
+
return Ardupilot('tests/test_inputs/test_log_00000052.BIN', types=type_request, zero_time_base=True)
|
|
26
|
+
|
|
27
|
+
@pytest.fixture(scope="session")
|
|
28
|
+
def log2(type_request):
|
|
29
|
+
return Ardupilot('tests/test_inputs/00000129.BIN', types=type_request, zero_time_base=True)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_dfs(type_request, log):
|
|
33
|
+
assert set(log.dfs.keys()) == set(type_request + ['PARM'])
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_full_df_frequency(log, type_request):
|
|
37
|
+
fulldf = log.join_logs(type_request)
|
|
38
|
+
assert len(log.dfs['XKF1']) == len(fulldf)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_time_epioch(log):
|
|
42
|
+
gpsdf = log.dfs['GPS']
|
|
43
|
+
assert "GPSTimeUS" in gpsdf.columns
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_time_index(log2):
|
|
47
|
+
assert "XKF1" in log2.dfs
|
|
48
|
+
assert log2.dfs["XKF1"].timestamp.is_monotonic_increasing
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
File without changes
|
|
File without changes
|
{ardupilot_log_reader-0.1.0 → ardupilot_log_reader-0.2.0}/ardupilot_log_reader.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|