Print Navigation
Basic example — continuously read and display position, speed, time, and fix information.
Source: examples/CPP/PrintNavigation/, examples/C/PrintNavigation/, examples/Python/print_navigation.py
from jimmypaputto import gnsshat
hat = gnsshat.GnssHat()
hat.soft_reset_hot_start()
config = {
'measurement_rate_hz': 1,
'dynamic_model': gnsshat.DynamicModel.PORTABLE,
'timepulse_pin_config': {
'active': True,
'fixed_pulse': { 'frequency': 1, 'pulse_width': 0.1 },
'polarity': gnsshat.TimepulsePolarity.RISING_EDGE
},
'geofencing': None
}
if not hat.start(config):
print("Failed to start GNSS HAT, exiting...")
exit(1)
while True:
try:
nav = hat.wait_and_get_fresh_navigation()
print("\033[2J\033[H") # clear terminal
print(nav.pvt)
except KeyboardInterrupt:
break
#include <cstdio>
#include <jimmypaputto/GnssHat.hpp>
using namespace JimmyPaputto;
auto main() -> int
{
auto* hat = IGnssHat::create();
hat->softResetUbloxSom_HotStart();
GnssConfig config {
.measurementRate_Hz = 1,
.dynamicModel = EDynamicModel::Stationary,
.timepulsePinConfig = TimepulsePinConfig {
.active = true,
.fixedPulse = { .frequency = 1, .pulseWidth = 0.1f },
.pulseWhenNoFix = std::nullopt,
.polarity = ETimepulsePinPolarity::RisingEdgeAtTopOfSecond
},
.geofencing = std::nullopt,
.rtk = std::nullopt,
.timing = std::nullopt
};
if (!hat->start(config)) return -1;
while (true)
{
const auto nav = hat->waitAndGetFreshNavigation();
printf("%.6f, %.6f alt=%.1fm sats=%d fix=%s\n",
nav.pvt.latitude, nav.pvt.longitude,
nav.pvt.altitude, nav.pvt.visibleSatellites,
Utils::eFixType2string(nav.pvt.fixType).c_str());
}
}
#include <stdio.h>
#include <jimmypaputto/GnssHat.h>
int main(void)
{
jp_gnss_hat_t* hat = jp_gnss_hat_create();
jp_gnss_hat_soft_reset_hot_start(hat);
jp_gnss_gnss_config_t config;
jp_gnss_gnss_config_init(&config);
config.measurement_rate_hz = 1;
config.dynamic_model = JP_GNSS_DYNAMIC_MODEL_STATIONARY;
config.timepulse_pin_config.active = true;
config.timepulse_pin_config.fixed_pulse.frequency = 1;
config.timepulse_pin_config.fixed_pulse.pulse_width = 0.1f;
config.timepulse_pin_config.polarity = JP_GNSS_TIMEPULSE_POLARITY_RISING_EDGE;
if (!jp_gnss_hat_start(hat, &config)) return -1;
jp_gnss_navigation_t nav;
while (jp_gnss_hat_wait_and_get_fresh_navigation(hat, &nav))
{
printf("%.6f, %.6f alt=%.1fm sats=%d\n",
nav.pvt.latitude, nav.pvt.longitude,
nav.pvt.altitude, nav.pvt.visible_satellites);
}
jp_gnss_hat_destroy(hat);
return 0;
}
python3 examples/Python/print_navigation.py
sudo examples/BinariesSymlinks/PrintNavigation
NoteThe Python version uses ANSI escape codes to clear the terminal on each update. Press Ctrl+C to exit.