Skip to content

EV Trip Planner

EV Trip Planner

This feature will plan the best route with or without a charge station based on the current electric quantity. Before using this feature, you should set vehicle information, for details please refer to Set electric information.

Note: this feature only support offboard mode

Planner Request

Most of the parameters in an EvTripPlanningRequest are the same as those in a route request, like route preference,waypoints, heading,speed, origin, and destination. But there is an import parameter: tn::direction::models::v2::ChargingPlanPreference in the EV trip planner request.

ChargingPlanPreference
Parameter description
enable_charging_planning True: It will enable automatically charging station planning if current electricity can't arrive at the destination.
False: Disable charge station planning automatically.
strategy HigherPowerChargerStrategy:Prefer to select higher power chargers with less charging time. It is a default setting.
LessDetourStrategy: Perfer to use chargers along the route.
AlternativeRouteStrategy:Prefer to supply an alternative route.
preferred_connector_types The types of connector preferred to be used for charging.
preferred_charger_brands The charger brands preferred to be used for charging.
preferred_arrival_battery_level The percentage of battery capacity preferred when arriving at final destination.
prefer_to_charge_upon_arrival Prefer to select charge at destination
preferred_start_charging_battery_level The percentage of battery capacity preferred to start charging at charging stations.
preferred_stop_charging_battery_level The percentage of battery capacity preferred to stop charging at charging stations.
charging_station_blocklist A list of charging station entity IDs that will be avoided when selecting charging stations.

Create a request

***Request a ev trip route and disable charge station automatical selection ***

A route request is created through the route request builder, by providing at least the origin and destination, as shown in the example below.

1
2
3
4
5
6
7
8
tn::direction::models::v2::ChargingPlanPreference preference;
preference.enable_charging_planning = false;

auto request = direction_Service->createEvTripPlanningRequestBuilder()
                ->setOrigin(tn::direction::models::v2::GeoLocation(37.386300,-122.005090))
                .setDestination(tn::direction::models::v2::GeoLocation(37.398760,-121.977360))
                .setChargingPlanPreference(preference)
                .build();

***Request a ev trip route and select charge station automatically ***

A route request is created through ev trip planner request builder, by providing at least the origin and destination and ChargingPlanPreference, as shown in the example below.

1
2
3
4
5
6
7
8
tn::direction::models::v2::ChargingPlanPreference preference;
preference.preferred_arrival_battery_level = 20; // set arrival battery level should be more than 20%.

auto request = direction_Service->createEvTripPlanningRequestBuilder()
                ->setOrigin(tn::direction::models::v2::GeoLocation(37.386300,-122.005090))
                .setDestination(tn::direction::models::v2::GeoLocation(37.398760,-121.977360))
                .setChargingPlanPreference(preference)
                .build();

Request an EV route with multiple stops
tn::direction::models::v2::ChargingPlanPreference preference;
preference.preferred_arrival_battery_level = 20; // set arrival battery level should be more than 20%.

auto request = direction_Service->createEvTripPlanningRequestBuilder()
                ->setOrigin(tn::direction::models::v2::GeoLocation(37.386300,-122.005090))
                .setDestination(tn::direction::models::v2::GeoLocation(37.398760,-121.977360))
                .setWaypoints({tn::direction::models::v2::Waypoint(37.398160,-121.977160),
                               tn::direction::models::v2::Waypoint(37.328760,-121.927360)})
                .setChargingPlanPreference(preference)
                .build();

Calculate an EV route

A request is processed through a task, which will finally provide the results through a callback. In the callback, an error code will be provided to indicate the general processing result. Also, a response will be provided with detailed routes if the calculation can be done properly. For more details, please refer to the corresponding section.

A sample of trigger an ev route.

1
2
3
4
5
6
7
8
tn::shared_ptr<tn::direction::api::RouteResponse> route_response;
tn::foundation::ErrorCode error_code;

direction_Service->createEvTripPlanningTask(request)
    ->runSync([&](tn::foundation::ErrorCode c, tn::shared_ptr<tn::direction::api::RouteResponse> r) {
        route_response = r;
        error_code = c;
    });