Skip to content

Commit

Permalink
Include baseline distance in corrected attitude message.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Dec 3, 2024
1 parent aebbc45 commit d17e1bf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
25 changes: 20 additions & 5 deletions python/fusion_engine_client/messages/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ class GNSSAttitudeOutput(MessagePayload):
MESSAGE_TYPE = MessageType.GNSS_ATTITUDE_OUTPUT
MESSAGE_VERSION = 0

_STRUCT = struct.Struct('<B3xI3f3f')
_STRUCT = struct.Struct('<B3xI3f3f2f')

def __init__(self):
## Measurement timestamps, if available. See @ref measurement_messages.
Expand All @@ -1198,6 +1198,14 @@ def __init__(self):
# The standard deviation of the orientation measurement (in degrees).
self.ypr_std_deg = np.full((3,), np.nan)

##
# The estimated distance between primary and secondary antennas (in meters).
self.baseline_distance_m = np.nan

##
# The standard deviation of the baseline distance estimate (in meters).
self.baseline_distance_std_m = np.nan

def pack(self, buffer: bytes = None, offset: int = 0, return_buffer: bool = True) -> (bytes, int):
if buffer is None:
buffer = bytearray(self.calcsize())
Expand All @@ -1216,7 +1224,9 @@ def pack(self, buffer: bytes = None, offset: int = 0, return_buffer: bool = True
self.ypr_deg[2],
self.ypr_std_deg[0],
self.ypr_std_deg[1],
self.ypr_std_deg[2])
self.ypr_std_deg[2],
self.baseline_distance_m,
self.baseline_distance_std_m)
offset += self._STRUCT.size

if return_buffer:
Expand All @@ -1236,7 +1246,9 @@ def unpack(self, buffer: bytes, offset: int = 0, message_version: int = MessageP
self.ypr_deg[2],
self.ypr_std_deg[0],
self.ypr_std_deg[1],
self.ypr_std_deg[2]) = \
self.ypr_std_deg[2],
self.baseline_distance_m,
self.baseline_distance_std_m) = \
self._STRUCT.unpack_from(buffer, offset)
offset += self._STRUCT.size

Expand All @@ -1247,15 +1259,18 @@ def unpack(self, buffer: bytes, offset: int = 0, message_version: int = MessageP
def __repr__(self):
result = super().__repr__()[:-1]
ypr_str = '(%.1f, %.1f, %.1f)' % tuple(self.ypr_deg)
result += f', solution_type={self.solution_type}, ypr={ypr_str} deg]'
result += f', solution_type={self.solution_type}, ypr={ypr_str} deg, ' \
f'baseline={self.baseline_distance_m} m]'
return result

def __str__(self):
return f"""\
GNSS Attitude Output @ {str(self.details.p1_time)}
Solution Type: {self.solution_type}
YPR (deg): {self.ypr_deg[0]:.2f}, {self.ypr_deg[1]:.2f}, {self.ypr_deg[2]:.2f}
YPR std (deg): {self.ypr_std_deg[0]:.2f}, {self.ypr_std_deg[1]:.2f}, {self.ypr_std_deg[2]:.2f}"""
YPR std (deg): {self.ypr_std_deg[0]:.2f}, {self.ypr_std_deg[1]:.2f}, {self.ypr_std_deg[2]:.2f}
Baseline distance (m): {self.baseline_distance_m:.2f}
Baseline std (m): {self.baseline_distance_std_m:.2f}"""

@classmethod
def calcsize(cls) -> int:
Expand Down
10 changes: 10 additions & 0 deletions src/point_one/fusion_engine/messages/measurements.h
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,16 @@ struct P1_ALIGNAS(4) GNSSAttitudeOutput : public MessagePayload {
* The standard deviation of the orientation measurement (in degrees).
*/
float ypr_std_deg[3] = {NAN, NAN, NAN};

/**
* The estimated distance between primary and secondary antennas (in meters).
*/
float baseline_distance_m = NAN;

/**
* The standard deviation of the baseline distance estimate (in meters).
*/
float baseline_distance_std_m = NAN;
};

/**
Expand Down

0 comments on commit d17e1bf

Please sign in to comment.