Skip to content

Commit 8b94d7a

Browse files
PanapatCPanapatC
authored andcommitted
Update rtcm type base64
1 parent fdd820b commit 8b94d7a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

examples/rtk_base_ublox.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import serial
55
from mavsdk import System, rtk
6+
import base64
67

78
PREAMBLE_RTCM = 0xD3
89
PREAMBLE_UBX = 0xB5
@@ -135,15 +136,13 @@ async def send_rtcm(drone):
135136
if rtcm_correction_data is None:
136137
continue
137138

138-
# We convert the data to a string here as the API wants it even
139-
# though it should be raw bytes.
140-
# This creates an odd Python string that gets decoded on the
141-
# C++ server side.
142-
# With MAVSDK v2, the API will change to a vector of bytes
143-
# instead of this clunky string.
139+
# Convert the rtcm data from a bytearray to a base64.
140+
# In MAVSDK v3 the rtcm data is expected to be base64 encoded string .
141+
base64_rtcm_data = base64.b64encode(rtcm_correction_data).decode('utf-8')
144142

143+
# Send RTCM
145144
await drone.rtk.send_rtcm_data(
146-
rtk.RtcmData(str(rtcm_correction_data)))
145+
rtk.RtcmData(base64_rtcm_data))
147146

148147
elif ord(preamble) == PREAMBLE_UBX:
149148
ubx = ubx_parser.read_packet(ublox, preamble)

0 commit comments

Comments
 (0)