ardupilot-log-reader 0.2.1__tar.gz → 0.3.2__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.
Files changed (31) hide show
  1. ardupilot_log_reader-0.3.2/.github/workflows/publish_pypi.yml +99 -0
  2. ardupilot_log_reader-0.3.2/.gitignore +107 -0
  3. ardupilot_log_reader-0.3.2/.vscode/launch.json +16 -0
  4. ardupilot_log_reader-0.3.2/.vscode/settings.json +8 -0
  5. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/PKG-INFO +5 -6
  6. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/ReadMe.md +0 -1
  7. ardupilot_log_reader-0.3.2/ardupilot_log_reader/reader.py +128 -0
  8. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/ardupilot_log_reader.egg-info/PKG-INFO +5 -6
  9. ardupilot_log_reader-0.3.2/ardupilot_log_reader.egg-info/SOURCES.txt +25 -0
  10. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/ardupilot_log_reader.egg-info/requires.txt +0 -1
  11. ardupilot_log_reader-0.3.2/bld.bat +2 -0
  12. ardupilot_log_reader-0.3.2/build.sh +1 -0
  13. ardupilot_log_reader-0.3.2/meta.yaml +28 -0
  14. ardupilot_log_reader-0.3.2/pyproject.toml +21 -0
  15. ardupilot_log_reader-0.3.2/requirements.txt +3 -0
  16. ardupilot_log_reader-0.3.2/setup.cfg +4 -0
  17. ardupilot_log_reader-0.3.2/tests/__init__.py +0 -0
  18. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/tests/test_ardupilot.py +2 -18
  19. ardupilot_log_reader-0.3.2/tests/test_inputs/00000002.BIN +0 -0
  20. ardupilot_log_reader-0.3.2/tests/test_inputs/00000054.BIN +0 -0
  21. ardupilot_log_reader-0.3.2/tests/test_inputs/00000129.BIN +0 -0
  22. ardupilot_log_reader-0.3.2/tests/test_inputs/2023-07-20 17-52-06.bin +0 -0
  23. ardupilot_log_reader-0.3.2/tests/test_inputs/manual_Generic_Generic_23_05_01_00000129.json +402665 -0
  24. ardupilot_log_reader-0.3.2/tests/test_inputs/test_log_00000052.BIN +0 -0
  25. ardupilot_log_reader-0.2.1/ardupilot_log_reader/reader.py +0 -149
  26. ardupilot_log_reader-0.2.1/ardupilot_log_reader.egg-info/SOURCES.txt +0 -11
  27. ardupilot_log_reader-0.2.1/setup.cfg +0 -23
  28. ardupilot_log_reader-0.2.1/setup.py +0 -14
  29. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/ardupilot_log_reader/__init__.py +0 -0
  30. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/ardupilot_log_reader.egg-info/dependency_links.txt +0 -0
  31. {ardupilot_log_reader-0.2.1 → ardupilot_log_reader-0.3.2}/ardupilot_log_reader.egg-info/top_level.txt +0 -0
@@ -0,0 +1,99 @@
1
+ #https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2
+ name: Publish to PyPI and TestPyPI
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+ tags:
9
+ - '**'
10
+ jobs:
11
+ build:
12
+ name: Build distribution
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v4
20
+ with:
21
+ python-version: ^3.6
22
+
23
+ - name: Install dependencies
24
+ run: pip install -r requirements.txt
25
+
26
+ - name: Install pypa / build
27
+ run: python3 -m pip install build --user
28
+
29
+ - name: Build a binary wheel and a source tarball
30
+ run: python3 -m build
31
+
32
+ - name: Store the distribution packages
33
+ uses: actions/upload-artifact@v3
34
+ with:
35
+ name: python-package-distributions
36
+ path: dist/
37
+
38
+ publish-to-pypi:
39
+ name: Publish Python distribution to PyPI
40
+ needs: build
41
+ runs-on: ubuntu-latest
42
+ environment:
43
+ name: pypi
44
+ url: https://pypi.org/p/<package-name>
45
+ permissions:
46
+ id-token: write # IMPORTANT: mandatory for trusted publishing
47
+
48
+ steps:
49
+ - name: Download all the dists
50
+ uses: actions/download-artifact@v3
51
+ with:
52
+ name: python-package-distributions
53
+ path: dist/
54
+ - name: Publish distribution to PyPI
55
+ uses: pypa/gh-action-pypi-publish@release/v1
56
+
57
+ github-release:
58
+ name: >-
59
+ Sign the Python distribution with Sigstore
60
+ and upload them to GitHub Release
61
+ needs:
62
+ - publish-to-pypi
63
+ runs-on: ubuntu-latest
64
+
65
+ permissions:
66
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
67
+ id-token: write # IMPORTANT: mandatory for sigstore
68
+
69
+ steps:
70
+ - name: Download all the dists
71
+ uses: actions/download-artifact@v3
72
+ with:
73
+ name: python-package-distributions
74
+ path: dist/
75
+ - name: Sign the dists with Sigstore
76
+ uses: sigstore/gh-action-sigstore-python@v1.2.3
77
+ with:
78
+ inputs: >-
79
+ ./dist/*.tar.gz
80
+ ./dist/*.whl
81
+ - name: Create GitHub Release
82
+ env:
83
+ GITHUB_TOKEN: ${{ github.token }}
84
+ run: >-
85
+ gh release create
86
+ '${{ github.ref_name }}'
87
+ --repo '${{ github.repository }}'
88
+ --notes ""
89
+ - name: Upload artifact signatures to GitHub Release
90
+ env:
91
+ GITHUB_TOKEN: ${{ github.token }}
92
+ # Upload to GitHub Release using the `gh` CLI.
93
+ # `dist/` contains the built packages, and the
94
+ # sigstore-produced signatures and certificates.
95
+ run: >-
96
+ gh release upload
97
+ '${{ github.ref_name }}' dist/**
98
+ --repo '${{ github.repository }}'
99
+
@@ -0,0 +1,107 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ .Python
5
+ build/
6
+ develop-eggs/
7
+ dist/
8
+ downloads/
9
+ eggs/
10
+ .eggs/
11
+ lib/
12
+ lib64/
13
+ parts/
14
+ sdist/
15
+ var/
16
+ wheels/
17
+ share/python-wheels/
18
+ *.egg-info/
19
+ .installed.cfg
20
+ *.egg
21
+ MANIFESThtmlcov/
22
+ .tox/
23
+ .nox/
24
+ .coverage
25
+ .coverage.*
26
+ .cache
27
+ nosetests.xml
28
+ coverage.xml
29
+ *.cover
30
+ *.py,cover
31
+ .hypothesis/
32
+ .pytest_cache/
33
+ cover/
34
+
35
+ # Translations
36
+ *.mo
37
+ *.pot
38
+
39
+ # Django stuff:
40
+ *.log
41
+ local_settings.py
42
+ db.sqlite3
43
+ db.sqlite3-journal
44
+
45
+ # Flask stuff:
46
+ instance/
47
+ .webassets-cache
48
+
49
+ # Scrapy stuff:
50
+ .scrapy
51
+
52
+ # Sphinx documentation
53
+ docs/_build/
54
+
55
+ # PyBuilder
56
+ .pybuilder/
57
+ target/
58
+
59
+ # Jupyter Notebook
60
+ .ipynb_checkpoints
61
+
62
+ # IPython
63
+ profile_default/
64
+ ipython_config.py
65
+
66
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
67
+ __pypackages__/
68
+
69
+ # Celery stuff
70
+ celerybeat-schedule
71
+ celerybeat.pid
72
+
73
+ # SageMath parsed files
74
+ *.sage.py
75
+
76
+ # Environments
77
+ .env
78
+ .venv
79
+ env/
80
+ venv/
81
+ ENV/
82
+ env.bak/
83
+ venv.bak/
84
+
85
+ # Spyder project settings
86
+ .spyderproject
87
+ .spyproject
88
+
89
+ # Rope project settings
90
+ .ropeproject
91
+
92
+ # mkdocs documentation
93
+ /site
94
+
95
+ # mypy
96
+ .mypy_cache/
97
+ .dmypy.json
98
+ dmypy.json
99
+
100
+ # Pyre type checker
101
+ .pyre/
102
+
103
+ # pytype static type analyzer
104
+ .pytype/
105
+
106
+ # Cython debug symbols
107
+ cython_debug/
@@ -0,0 +1,16 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+
8
+ {
9
+ "name": "Python: Module",
10
+ "type": "python",
11
+ "request": "launch",
12
+ "redirectOutput": true,
13
+ "module": "ardupilot_log_reader.test"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "python.pythonPath": "/home/tomd/anaconda3/envs/ardupilotlogs/bin/python",
3
+ "python.testing.pytestArgs": [
4
+ "tests"
5
+ ],
6
+ "python.testing.unittestEnabled": false,
7
+ "python.testing.pytestEnabled": true
8
+ }
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ardupilot_log_reader
3
- Version: 0.2.1
3
+ Version: 0.3.2
4
4
  Summary: module to read ardupilot binary logs to memory
5
- Home-page: https://github.com/PyFlightCoach/ardupilot_log_reader
6
- Author: Thomas David
7
- Author-email: thomasdavid0@gmail.com
5
+ Author-email: Thomas David <thomasdavid0@gmail.com>
6
+ License: GNU GPL v3
7
+ Classifier: Programming Language :: Python :: 3
8
+ Requires-Python: >=3.12
8
9
  Description-Content-Type: text/markdown
9
- Requires-Dist: future
10
10
  Requires-Dist: numpy
11
11
  Requires-Dist: pandas
12
12
  Requires-Dist: pymavlink
@@ -22,7 +22,6 @@ from ArdupilotLogReader import Ardupilot
22
22
  parser = Ardupilot(
23
23
  log_file, # the log file, .bin
24
24
  types = ['ARSP', 'ATT', 'BARO', 'GPS', 'IMU', 'RCIN', 'RCOU', 'BAT', 'MODE', 'NKF1', 'STAT', 'XKF1'], # fields to read from the log
25
- zero_time_base=True # arguments passed to pymavlink
26
25
  )
27
26
 
28
27
  parser.dfs # a dict containing a dataframes of log data for each field requested.
@@ -9,7 +9,6 @@ from ArdupilotLogReader import Ardupilot
9
9
  parser = Ardupilot(
10
10
  log_file, # the log file, .bin
11
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
12
  )
14
13
 
15
14
  parser.dfs # a dict containing a dataframes of log data for each field requested.
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env python
2
+
3
+ '''
4
+ example program that dumps a Mavlink log file. The log file is
5
+ assumed to be in the format that qgroundcontrol uses, which consists
6
+ of a series of MAVLink packets, each with a 64 bit timestamp
7
+ header. The timestamp is in microseconds since 1970 (unix epoch)
8
+
9
+ This program is free software: you can redistribute it and/or modify it under
10
+ the terms of the GNU General Public License as published by the Free Software
11
+ Foundation, either version 3 of the License, or (at your option) any later
12
+ version.
13
+ This program is distributed in the hope that it will be useful, but WITHOUT
14
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
+ You should have received a copy of the GNU General Public License along with
17
+ this program. If not, see <http://www.gnu.org/licenses/>.
18
+ '''
19
+
20
+ from __future__ import annotations
21
+ import fnmatch
22
+ import os
23
+ import pandas as pd
24
+ from dataclasses import dataclass
25
+ from pymavlink.DFReader import DFReader_binary
26
+
27
+
28
+ @dataclass
29
+ class Ardupilot(object):
30
+ filename: str
31
+ dfs: dict[str, pd.DataFrame]
32
+
33
+ def __getattr__(self, name):
34
+ if name in self.dfs:
35
+ return self.dfs[name]
36
+ raise AttributeError(f"No such attribute: {name}")
37
+
38
+ @staticmethod
39
+ def process_patterns(available: list[str], patterns:list[str] = None, exclude_patterns: list[str]=None):
40
+ def match_type(mtype, patterns):
41
+ for p in patterns:
42
+ if fnmatch.fnmatch(mtype, p):
43
+ return True
44
+ return False
45
+ patterns = available if patterns is None else patterns
46
+ exclude_patterns = [] if exclude_patterns is None else exclude_patterns
47
+ return [k for k in available if match_type(k, patterns) and not match_type(k, exclude_patterns)]
48
+
49
+ @staticmethod
50
+ def parse(
51
+ bin_file, types=None, nottypes=None, zero_time_base=False,
52
+ source_system=None, source_component=None, link=None, mav10=False
53
+ ) -> Ardupilot:
54
+ """
55
+ Parses a binary file into an Ardupilot object.
56
+
57
+ Parameters:
58
+ bin_file (str): The binary file to parse.
59
+ types (list[str], optional): List of types or patterns to include in the parsing. Defaults to None.
60
+ nottypes (list[str], optional): List of types or patterns to exclude from the parsing. Defaults to None.
61
+ zero_time_base (bool, optional): If True, sets the time base to zero. Defaults to False.
62
+ source_system (int, optional): The source system ID to filter messages by. Defaults to None (all systems in log).
63
+ source_component (int, optional): The source component ID to filter messages by. Defaults to None (all components in log).
64
+ link (int, optional): The link to filter messages by. Defaults to None.
65
+ mav10 (bool, optional): If True, uses MAVLink 1.0. Defaults to False.
66
+
67
+ Returns:
68
+ Ardupilot: The parsed Ardupilot object.
69
+ """
70
+ if not mav10:
71
+ os.environ['MAVLINK20'] = '1'
72
+
73
+ mlog: DFReader_binary = DFReader_binary(str(bin_file), zero_time_base=zero_time_base)
74
+
75
+ match_types = Ardupilot.process_patterns(
76
+ list(mlog.name_to_id.keys()),
77
+ list(set(types + ['PARM'])),
78
+ nottypes
79
+ )
80
+
81
+ log = Ardupilot._parse(mlog, match_types, source_system, source_component, link)
82
+
83
+ mlog.filehandle.close()
84
+
85
+ return log
86
+
87
+ @staticmethod
88
+ def _parse(mlog, cols: list[str], src_system=None, src_component=None, link=None):
89
+ dfs_dicts = {}
90
+
91
+ while True:
92
+ m = mlog.recv_match(blocking=False, type=cols)
93
+ if m is None:
94
+ break
95
+ if src_system is not None and src_system != m.get_srcSystem():
96
+ continue
97
+ if src_component is not None and src_component != m.get_srcComponent():
98
+ continue
99
+ if link is not None and link != m._link:
100
+ continue
101
+
102
+ key=m.get_type()
103
+
104
+ if key not in dfs_dicts:
105
+ if key == 'BAD_DATA':
106
+ continue
107
+ dfs_dicts[key] = {}
108
+ dfs_dicts[key]['timestamp'] = []
109
+ for field in m.get_fieldnames():
110
+ dfs_dicts[key][field] = []
111
+
112
+ dfs_dicts[key]['timestamp'].append( getattr(m,'_timestamp', 0.0) )
113
+
114
+ for field in m.get_fieldnames():
115
+ dfs_dicts[key][field].append( getattr(m,field) )
116
+
117
+ return Ardupilot(mlog.filehandle.name, {k: pd.DataFrame(v) for k, v in dfs_dicts.items()})
118
+
119
+ def parameters(self) -> dict[str, pd.DataFrame]:
120
+ gb = self.PARM.groupby('Name')
121
+
122
+ parms = {}
123
+ for gn in gb.groups.keys():
124
+ gr = gb.get_group(gn)
125
+ parms[gn] = gr.loc[abs(gr.Value.diff().fillna(1)) > 0, ["timestamp", "TimeUS", "Value"]].set_index('timestamp')
126
+ return parms
127
+
128
+
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ardupilot_log_reader
3
- Version: 0.2.1
3
+ Version: 0.3.2
4
4
  Summary: module to read ardupilot binary logs to memory
5
- Home-page: https://github.com/PyFlightCoach/ardupilot_log_reader
6
- Author: Thomas David
7
- Author-email: thomasdavid0@gmail.com
5
+ Author-email: Thomas David <thomasdavid0@gmail.com>
6
+ License: GNU GPL v3
7
+ Classifier: Programming Language :: Python :: 3
8
+ Requires-Python: >=3.12
8
9
  Description-Content-Type: text/markdown
9
- Requires-Dist: future
10
10
  Requires-Dist: numpy
11
11
  Requires-Dist: pandas
12
12
  Requires-Dist: pymavlink
@@ -22,7 +22,6 @@ from ArdupilotLogReader import Ardupilot
22
22
  parser = Ardupilot(
23
23
  log_file, # the log file, .bin
24
24
  types = ['ARSP', 'ATT', 'BARO', 'GPS', 'IMU', 'RCIN', 'RCOU', 'BAT', 'MODE', 'NKF1', 'STAT', 'XKF1'], # fields to read from the log
25
- zero_time_base=True # arguments passed to pymavlink
26
25
  )
27
26
 
28
27
  parser.dfs # a dict containing a dataframes of log data for each field requested.
@@ -0,0 +1,25 @@
1
+ .gitignore
2
+ ReadMe.md
3
+ bld.bat
4
+ build.sh
5
+ meta.yaml
6
+ pyproject.toml
7
+ requirements.txt
8
+ .github/workflows/publish_pypi.yml
9
+ .vscode/launch.json
10
+ .vscode/settings.json
11
+ ardupilot_log_reader/__init__.py
12
+ ardupilot_log_reader/reader.py
13
+ ardupilot_log_reader.egg-info/PKG-INFO
14
+ ardupilot_log_reader.egg-info/SOURCES.txt
15
+ ardupilot_log_reader.egg-info/dependency_links.txt
16
+ ardupilot_log_reader.egg-info/requires.txt
17
+ ardupilot_log_reader.egg-info/top_level.txt
18
+ tests/__init__.py
19
+ tests/test_ardupilot.py
20
+ tests/test_inputs/00000002.BIN
21
+ tests/test_inputs/00000054.BIN
22
+ tests/test_inputs/00000129.BIN
23
+ tests/test_inputs/2023-07-20 17-52-06.bin
24
+ tests/test_inputs/manual_Generic_Generic_23_05_01_00000129.json
25
+ tests/test_inputs/test_log_00000052.BIN
@@ -0,0 +1,2 @@
1
+ "%PYTHON%" setup.py install
2
+ if errorlevel 1 exit 1
@@ -0,0 +1 @@
1
+ $PYTHON setup.py install
@@ -0,0 +1,28 @@
1
+ package:
2
+ name: ardupilot_log_reader
3
+ version: '0.1.0'
4
+
5
+ build:
6
+ noarch: generic
7
+ number: 0
8
+
9
+ source:
10
+ path: ./
11
+
12
+ requirements:
13
+ build:
14
+ - python
15
+ - setuptools
16
+ host:
17
+ - future
18
+ - numpy
19
+ - pandas
20
+ - pymavlink
21
+ run:
22
+ - future
23
+ - numpy
24
+ - pandas
25
+ - pymavlink
26
+ test:
27
+ imports:
28
+ - ardupilot_log_reader
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools>=60",
4
+ "setuptools-scm>=8.0"
5
+ ]
6
+ build-backend = "setuptools.build_meta"
7
+
8
+ [project]
9
+ name = "ardupilot_log_reader"
10
+ authors = [{name = "Thomas David", email = "thomasdavid0@gmail.com"}]
11
+ description = "module to read ardupilot binary logs to memory"
12
+ readme = "ReadMe.md"
13
+ requires-python = ">=3.12"
14
+ license = {text = "GNU GPL v3"}
15
+ classifiers = ["Programming Language :: Python :: 3",]
16
+ dynamic = ["version", "dependencies"]
17
+
18
+ [tool.setuptools.dynamic]
19
+ dependencies = {file = ["requirements.txt"]}
20
+
21
+ [tool.setuptools_scm]
@@ -0,0 +1,3 @@
1
+ numpy
2
+ pandas
3
+ pymavlink
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -10,8 +10,6 @@ You should have received a copy of the GNU General Public License along with
10
10
  this program. If not, see <http://www.gnu.org/licenses/>.
11
11
  """
12
12
  from ardupilot_log_reader.reader import Ardupilot
13
- import numpy as np
14
- import pandas as pd
15
13
 
16
14
  import pytest
17
15
 
@@ -22,30 +20,16 @@ def type_request():
22
20
 
23
21
  @pytest.fixture(scope="session")
24
22
  def log(type_request):
25
- return Ardupilot('tests/test_inputs/test_log_00000052.BIN', types=type_request, zero_time_base=True)
23
+ return Ardupilot.parse('tests/test_inputs/test_log_00000052.BIN', types=type_request, zero_time_base=True)
26
24
 
27
25
  @pytest.fixture(scope="session")
28
26
  def log2(type_request):
29
- return Ardupilot('tests/test_inputs/00000129.BIN', types=type_request, zero_time_base=True)
30
-
27
+ return Ardupilot.parse('tests/test_inputs/00000129.BIN', types=type_request, zero_time_base=True)
31
28
 
32
29
  def test_dfs(type_request, log):
33
30
  assert set(log.dfs.keys()) == set(type_request + ['PARM'])
34
31
 
35
32
 
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
33
 
50
34
 
51
35