From 9ad0cba6026cd3dd8d511f472a5f98145f324356 Mon Sep 17 00:00:00 2001 From: Hugues de Valon Date: Wed, 5 Jun 2024 11:36:29 +0200 Subject: [PATCH] fix batch B parsing This commit fixes the parsing of Batch B for position, orientation and velocity outputs. There were two errors: - the checksum1 byte was missing causing the unpacking to parse the wrong bytes - the type of lat, long and altitude should be float instead of uint --- pyNCOM/NCOMmsg.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pyNCOM/NCOMmsg.py b/pyNCOM/NCOMmsg.py index 3b3487b..69126ef 100644 --- a/pyNCOM/NCOMmsg.py +++ b/pyNCOM/NCOMmsg.py @@ -1,5 +1,6 @@ from collections import OrderedDict from bitstring import BitArray +import math ACC_FACTOR = 1e-4 ANG_FACTOR = 1e-5 @@ -14,7 +15,8 @@ def __init__(self, ncom_byte): self._names = ('Sync', 'Time', 'AccX', 'AccY', 'AccZ', 'AngX', 'AngY', 'AngZ', - 'NavStat', 'Lat', 'Long', 'Alti', + 'NavStat', 'Checksum1', + 'Lat', 'Long', 'Alti', 'Vel_North', 'Vel_East', 'Vel_Down', 'Heading', 'Pitch', 'Roll') self._navstat = { @@ -39,7 +41,8 @@ def _get_value(self, ncom_byte): self._data = b.unpack(('uintle:8, uintle:16,' # Sync, Time 'intle:24, intle:24, intle:24,' # AccX, AccY, AccZ 'intle:24, intle:24, intle:24,' # AngX, AngY, AngZ - 'uintle:8, uintle:64, uintle:64, uintle:32,' # NavStat, Lat, Long, Alti + 'uintle:8, uintle:8,' # NavStat, Checksum1 + 'floatle:64, floatle:64, floatle:32,' # Lat, Long, Alti 'uintle:24, uintle:24, uintle:24,' # Vel North, Vel East, Vel Down 'uintle:24, uintle:24, uintle:24' # Heading, Pitch, Roll )) @@ -51,10 +54,12 @@ def _get_value(self, ncom_byte): self.d['AngX'] *= ANG_FACTOR self.d['AngY'] *= ANG_FACTOR self.d['AngZ'] *= ANG_FACTOR + self.d['NavStat'] = self._navstat.get(self.d['NavStat'], 'Reserved') + self.d['Lat'] = math.degrees(self.d['Lat']) + self.d['Long'] = math.degrees(self.d['Long']) self.d['Vel_North'] *= VEL_FACTOR self.d['Vel_East'] *= VEL_FACTOR self.d['Vel_Down'] *= VEL_FACTOR self.d['Heading'] *= IMU_FACTOR self.d['Pitch'] *= IMU_FACTOR self.d['Roll'] *= IMU_FACTOR - self.d['NavStat'] = self._navstat.get(self.d['NavStat'], 'Reserved')