Skip to content

Commit c98ec84

Browse files
Merge pull request #749 from aminballoon/pr-update-ublox-rtk-example
Update Ublox RTK example
2 parents fdd820b + 1beb3a7 commit c98ec84

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/rtk_base_ublox.py

+8-7
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,15 @@ 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 to a base64,
140+
# In MAVSDK v3 the rtcm data is expected
141+
# to be base64 encoded string .
142+
base64_rtcm_data = base64.b64encode(
143+
rtcm_correction_data).decode('utf-8')
144144

145+
# Send RTCM
145146
await drone.rtk.send_rtcm_data(
146-
rtk.RtcmData(str(rtcm_correction_data)))
147+
rtk.RtcmData(base64_rtcm_data))
147148

148149
elif ord(preamble) == PREAMBLE_UBX:
149150
ubx = ubx_parser.read_packet(ublox, preamble)

0 commit comments

Comments
 (0)