Skip to content

Simulation Navigation

Simulation navigation

This tutorial shows how to start a simulation navigation.

Get started

Simulation navigation can be used for debugging purposes. It can also be used for the user to try running the trip to see if there will be any alerts detected along the route and hear the audio guidance prompted before actually starting the trip.

1
2
3
4
5
6
7
8
9
// set initial vehicle speed in m/s
double speed = 10;

// start a simulation navigation session
auto* navigationSession = navigationService->startSimulationNavigation(route, speed);

// adjust simulation speed after navigation started
speed = 20;
navigationSession->setSimulationSpeed(speed);

tn::foundation::LocationProvider::updateLocation() will not affect the map matched location before simulation navigation session stopped. Vehicle location will be mocked along the route automatically in navigation session.

void LocationObserver::onPositionIndicatorUpdated(const tn::drive::models::v1::Indicator& indicator)
{
    // mode is simulation during simulation navigation period
    const auto mode = indicator.mode;

    // cause is simulation update during simulation navigation period
    const auto cause = indicator.cause;

    if (mode == tn::drive::models::v1::Indicator::Mode::Simulation &&
        cause == tn::drive::models::v1::Indicator::Cause::SimulationUpdate)
    {
        // location information is always available
        const auto location = indicator.location.matched_location;
        showVehicleLocationOnMap(location);
    }
}