Skip to content

Commit 66f42ed

Browse files
committed
Take estimation delay into account also in outgoing GPS_INPUT message GPS time (this implementation accurate up to 1 second) and not just in the usec field.
1 parent 9c5825b commit 66f42ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gisnav/nodes/mock_gps_node.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,17 @@ def _generate_gps_input(self, fixed_camera: FixedCamera) -> dict:
117117
`GPS_INPUT_IGNORE_FLAGS <https://mavlink.io/en/messages/common.html#GPS_INPUT_IGNORE_FLAGS>`_
118118
"""
119119
position = fixed_camera.position
120-
gps_time = GPSTime.from_datetime(datetime.now()) # TODO: use usec here, not now
121120

122121
msg = {}
123122

124123
# Adjust UTC epoch timestamp for estimation delay
125124
msg['usec'] = int(time.time_ns() / 1e3) - (self._bridge.synchronized_time - fixed_camera.timestamp)
126125
msg['gps_id'] = 0
127126
msg['ignore_flags'] = 56 # vel_horiz + vel_vert + speed_accuracy
127+
128+
gps_time = GPSTime.from_datetime(datetime.utcfromtimestamp(msg['usec'] / 1e6))
128129
msg['time_week'] = gps_time.week_number
129-
msg['time_week_ms'] = int(gps_time.time_of_week * 1e3)
130+
msg['time_week_ms'] = int(gps_time.time_of_week * 1e3) # TODO this implementation accurate only up to 1 second
130131
msg['fix_type'] = 3 # 3D position
131132
msg['lat'] = int(position.lat * 1e7)
132133
msg['lon'] = int(position.lon * 1e7)

0 commit comments

Comments
 (0)