Skip to content

EV Trip Planner

EV Trip Planner

This feature plans routes based on the current electric quantity, and include charging stations if necessary. Before using this feature, you should set vehicle information.

Note: this feature only support offboard mode

Planner Request

Most parameters in an EvTripPlanningRequest are identical to those in a route request, including route preference, waypoints, heading, speed, origin, and destination. But there is an important parameter: ChargingPlanPreference in the EV trip planner request.

ChargingPlanPreference

ChargingPlanPreference is a data class that defines user preferences for route calculation.

Parameter description
enableChargingPlanning True: It will automatically enable charging station planning if the current battery level is insufficient for the vehicle to reach the destination.
False: Disable charge station planning automatically.
planningStrategy 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.
preferredConnectorTypes The types of connector preferred to be used for charging.
preferredChargerBrands The charger brands preferred to be used for charging.
preferredArrivalBatteryLevel The percentage of battery capacity preferred when arriving at final destination.
preferToChargeUponArrival Prefer to select charge at destination
preferredStartChargingBatteryLevel The percentage of battery capacity preferred to start charging at charging stations.
preferredStopChargingBatteryLevel The percentage of battery capacity preferred to stop charging at charging stations.
chargingStationBlocklist 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();
val chargingPlanPreference = ChargingPlanPreference.Builder().apply{
                setEnableChargingPlanning(false)
        }.build()

val evTripPlanRequest = EvTripPlanRequest.Builder(
           GeoLocation(LatLon(37.386300,-122.005090)),
           GeoLocation(LatLon(37.398760,-121.977360))
        )
          .setChargingPlanPreference(chargingPlanPreference)
          .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();
val chargingPlanPreference = ChargingPlanPreference.Builder().apply {
            setPreferredArrivalBatteryLevel(20) // set arrival battery level should be more than 20%.
        }.build()

val evTripPlanRequest = EvTripPlanRequest.Builder(
            GeoLocation(LatLon(37.386300,-122.005090)),
            GeoLocation(LatLon(37.398760,-121.977360))
        )
            .setChargingPlanPreference(chargingPlanPreference)
            .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();
val chargingPlanPreference = ChargingPlanPreference.Builder().apply {
            setPreferredArrivalBatteryLevel(20) // set arrival battery level should be more than 20%.
        }.build()

val evTripPlanRequest = EvTripPlanRequest.Builder(
            GeoLocation(LatLon(37.386300,-122.005090)),
            GeoLocation(LatLon(37.398760,-121.977360))
        )
            .setWaypoints(listOf(Waypoint(GeoLocation(LatLon(50.105011,8.677914)))))
            .setChargingPlanPreference(chargingPlanPreference)
            .build()

Calculate an EV route

A request is processed through a task, which will finally provide the results through a callback. The callback includes an error code 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;
    });
val navigationService = NavigationService.Factory.createInstance()
val evTripPlanTask = navigationService.createNavigableEvTripPlanTask(evTripPlanRequest)
evTripPlanTask.runAsync { response ->
                  if (response.response?.status == DirectionErrorCode.OK && response.response.result.isNotEmpty()) {
                        val routes = response.response.result
                        val route = routes[0]
                  }

                evTripPlanTask.dispose()
}