Skip to content

Latest commit

 

History

History
183 lines (148 loc) · 9.1 KB

cpp.md

File metadata and controls

183 lines (148 loc) · 9.1 KB

C++ SDK

A header-only C++17 wrapper over the .gtd C SDK, with RAII types and range-based iteration. MIT licensed. Headers: sdk/cpp/include/. Consuming via CMake requires CMake 3.21+. The released C library that these headers wrap is built with MSVC on Windows.

Install

The release archive and the Homebrew formula install the C++ headers and the GeoTraceCpp CMake package config alongside the C library they wrap. The released libraries are static.

Homebrew (Linux, macOS)

brew install CramBL/homebrew-tap/geotrace-c

Release archive (Linux, macOS, Windows)

Download the archive for your target from the releases page, extract it, and add the extracted root to CMAKE_PREFIX_PATH.

Target Archive
Linux x86-64 geotrace-sdk-x86_64-unknown-linux-gnu.tar.gz
Linux ARM64 geotrace-sdk-aarch64-unknown-linux-gnu.tar.gz
macOS x86-64 geotrace-sdk-x86_64-apple-darwin.tar.gz
macOS ARM64 geotrace-sdk-aarch64-apple-darwin.tar.gz
Windows x64 geotrace-sdk-x86_64-pc-windows-msvc.zip
Windows ARM64 geotrace-sdk-aarch64-pc-windows-msvc.zip

Consume

find_package(GeoTraceCpp REQUIRED)
target_link_libraries(my_target PRIVATE GeoTrace::Cpp)

On Windows, configure with -A x64 or -A ARM64.

Static linking

GeoTrace::Cpp links the C library transitively, so its linkage follows the C SDK: static in the released archives and the Homebrew formula, and always static on Windows. The static C library links the system libraries it needs (ntdll, userenv, ws2_32, advapi32, bcrypt) through the package config. For a source build, select static with -DGEOTRACE_C_STATIC=ON (see below).

Build from source

Requires a Rust toolchain. Install the C SDK, then the C++ SDK into the same prefix. -DGEOTRACE_C_STATIC=ON builds the static library (the default on Windows). Omit it for a shared library on Linux and macOS.

cargo build -p geotrace-c --release
cmake -S sdk/c -B build/c -DGEOTRACE_C_STATIC=ON -DCMAKE_INSTALL_PREFIX=prefix
cmake --install build/c
cmake -S sdk/cpp -B build/cpp -DCMAKE_PREFIX_PATH=prefix -DCMAKE_INSTALL_PREFIX=prefix
cmake --install build/cpp

Examples

In sdk/cpp/examples/. Configure the C++ SDK with -DGEOTRACE_CPP_BUILD_EXAMPLES=ON to build them.

  • navigation_only: record available navigation facts and fix loss without satellite reports.
  • write_basic: minimal write workflow: add fixes, finish, write to disk.
  • read_file: open a .gtd file and print a content summary.
  • with_satellites: pair each fix with a per-satellite signal report.
  • event_markers: write and read hierarchical event markers (variant_path).
  • channels: attach scalar and vector sensor channels and read them back.
  • typed_events: type-safe markers via enum class and EventEnum<> specialization.
  • from_csv: convert CSV rows into a .gtd file.
  • from_multiple_sources: merge fixes and events from separate sources, interpolating event positions.
  • gold_dataset: build the cross-SDK reference file from shared fixtures and verify the round-trip.

Basic navigation recording

Start with navigation_only for a complete runnable producer using pre-parsed navigation facts. It writes a positioned Fix with eight used satellites and HDOP 0.9, a status-only NoFix two seconds later, and a positioned Fix at five seconds. No satellite identities, report builders, scopes or coverage flags are required. Set explicit Fix or NoFix from the source's validity indication. Omitted state is unreported: coordinates alone do not establish a GNSS fix. When explicit state is unavailable, a genuinely global used count establishes Fix when positive and NoFix when zero. An omitted count remains absent. Use heading for direction of travel when course over ground is appropriate. Course over ground is distinct from physical compass or antenna heading at rest. Ground speed uses metres per second: convert km/h or knots before assigning the basic numeric speed field. HDOP is dimensionless, while eph_m is independently reported horizontal accuracy in metres. GeoTrace displays the used count independently of an unavailable seen count. The navigation symbol shows resolved state, and reported methods such as RTK fixed remain visible in the point summary. Count colours describe satellite counts independently of positional accuracy. The viewer labels a display location for a status-only epoch as derived when position anchors are available.

builder.add(NavFix::status_only(time, SolutionState::NoFix));

Set optional counts and DOP on the returned NavFix when reported. The ordinary builder error policy also applies to status-only inputs.

Boot-clock readings

Set NavFix::boot_time to a checked BootTime in integer microseconds. NavPointView::boot_time returns the optional reading after decoding.

NavFix fix{FixTime::host(Timestamp::from_seconds(1700000000)),
           Angle::degrees(55.67), Angle::degrees(12.56)};
fix.boot_time = BootTime::from_micros(12000000);
builder.add(fix);

This example assumes the producer obtained the boot reading from Linux CLOCK_BOOTTIME, which includes suspend, alongside the system reading. CLOCK_MONOTONIC excludes suspend. Choose and document the clock at the producer. std::nullopt means absent, zero is valid and UINT64_MAX is rejected. BootTime::try_from_micros() returns a Result for callers with exceptions disabled. BootTime::as_micros() returns the exact integer value. A receiver-only fix can store boot time, but a system/boot comparison requires a system reading.

For the first complete system/boot pair (S0, B0) in stored order, the delta is (S - S0) - (B - B0) in microseconds. Positive values mean system time has advanced farther than boot time. Divide the signed integer result by 1,000 for milliseconds. The delta can include suspend behavior, clock adjustments and resets. The optional column extends GTD v3. Older SDKs that decode and rewrite a recording may drop it.

Navigation and independent polling

These examples use the unreleased SDK APIs. A position without heading can report Fix, eight used satellites and HDOP 0.9 without an observation list. Add usage identities when membership is available, then independent observations when geometry or signal measurements are available. The same API accepts facts from text protocols, binary protocols and asynchronous polling. Counts and DOP remain independent of identity lists and horizontal accuracy. The following example records host-clock positions and a later poll at its own timestamp.

#include <geotrace/geotrace.hpp>

int main() {
    using namespace geotrace;
    FileBuilder builder;
    for (const auto second : {0, 10}) {
        NavFix fix{FixTime::host(Timestamp::from_seconds(1700000000 + second)),
                   Angle::degrees(0), Angle::degrees(second)};
        fix.state = SolutionState::Fix;
        fix.used_count = 8;
        fix.hdop = 0.9;
        builder.add(fix);
    }
    builder.add(SatelliteObservationReport{
        FixTime::host(Timestamp::from_seconds(1700000002)),
        SatelliteScope::global(), SatelliteCoverage::Partial, 12,
        {{{Constellation::Gps, 1}, std::nullopt, std::nullopt, 40.0F}}});
    builder.finish().write_to_file("navigation_polling.gtd");
}

Explicit state, including Unknown, takes precedence over counts and membership. An absent state permits fallback from eligible used aggregates or known membership. A known-used identity can establish Fix in a partial report. Only global evidence can establish NoFix from zero usage. An omitted aggregate remains unreported. A present aggregate, including zero, is exact for its declared scope. Complete coverage describes the identity list within that scope. A partial list retains omitted identities as unknown. Each report preserves its original clocks and normalized placement time. The poll at second 2 becomes a synthesized carrier at longitude 2° between these host-clock positions.

Legacy combined-report accessors return a report only when the independent evidence can be represented without losing membership, scope or timestamps. Observation-only and partial independent reports remain available through the new report collections. See the Rust model and format reference for the complete coverage and projection rules.

New writers use GTD v3. The compatible application reader is currently in the Unreleased app. App 0.19.0 and earlier require GTD v1/v2 files. Publish the compatible app reader before the synchronized SDK releases, and record its release version in the release handoff.