Skip to content

Update Ublox RTK example #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions examples/rtk_base_ublox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import serial
from mavsdk import System, rtk
import base64

PREAMBLE_RTCM = 0xD3
PREAMBLE_UBX = 0xB5
Expand Down Expand Up @@ -135,15 +136,15 @@ async def send_rtcm(drone):
if rtcm_correction_data is None:
continue

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

# Send RTCM
await drone.rtk.send_rtcm_data(
rtk.RtcmData(str(rtcm_correction_data)))
rtk.RtcmData(base64_rtcm_data))

elif ord(preamble) == PREAMBLE_UBX:
ubx = ubx_parser.read_packet(ublox, preamble)
Expand Down