Trip management

Trip autostart

By default, the trip autostart feature is disabled.

To enable automatic trip detection, call the following method with parameter activate set to true.

fun activateAutoStart(activate: Boolean)

If a trip is running when automatic trip detection is disabled, the trip will not be canceled. If you want to cancel the trip, you should also call cancelTrip method.

Manually start a trip

You can start a trip by calling the following method:

fun startTrip()

If a trip is already started, calling this method will have no effect.

Stop a trip

You can stop a trip by calling the following method. The trip will be stopped instantly:

fun stopTrip()

If a vehicle stops longer than the configured, the trip will be stopped automatically.

If no trip is running, calling this method will have no effect.

Cancel a trip

If you want to cancel a trip, you can call this method:

fun cancelTrip()

Vehicle

To obtain a more precise analysis on driving behavior, it's recommended to configure the vehicle used by the driver. You can do this by calling the following method:

fun setVehicle(vehicle: TripVehicle)

A detailed description of vehicle parameter is available here.

If no vehicle is configured a default vehicle will be configured with following parameters:

  • carTypeIndex = 1

  • carEngineIndex = 1

  • carPower = 150

  • carMass = 1400

  • carGearboxIndex = 2

  • carConsumption = 4.5

  • engineDisplacement = 1200

  • frontTireSize = "205/55/16"

  • rearTireSize = "205/55/16"

  • length = 4.5

  • width = 1.8

  • height = 1.45

  • engineCylinderNb = 4

  • driveWheels = 0

SDK recorder state

Two methods are available to determine SDK state.

fun isTripRunning(): Boolean

This method returns false if the SDK is in INACTIVE state, and no trip is currently running.

If you want a more detailed state of the SDK, you can call the following method:

fun getRecorderState(): State

This method returns the state of the SDK:

  • INACTIVE: No trip is running.

  • STARTING: The auto start mode detects a movement of the user and checks if it's a trip in vehicle.

  • RUNNING: The trip has been confirmed by the speed of the movement.

  • STOPPING: The SDK is in this state when a potential trip end is detected. If the trip continues, the SDK goes back in RUNNING state. The duration of the stopping state can be configured.

  • SENDING: The trip is finished and is being sent to DriveQuant's server. When the SDK has the response from the server, the state becomes INACTIVE waiting for the next trip.

StartMode of the current trip

Trip Analysis offers a method to retrieve the StartMode of the current trip. The method returns null if no trip is running.

fun getCurrentStartMode(): StartMode?

Manual trip repost

Trip Analysis SDK have a repost mechanism. In most cases, when a trip is finished, it is sent to DriveQuant's server for analysis. Once it's done, the result of the analysis is sent back to the SDK.

In some case, the trip can't be sent to DriveQuant's server (for example, when there is no network). In this case, the SDK will save the trip data locally to send it later.

An automatic retry will be attempted later when you are connected to network.

You can manually check whether trips are to be sent to the DriveQuant servers using the following method:

fun checkTripToRepost()

If no trip is running or if the trip has been sent to the server and is currently being analyzed, calling this method will have no effect.

After a trip cancel, the automatic start function will not restart a new trip recording if the user has not walked. Without this mechanism, if the user cancels a trip recording because he is on public transport and not driving, the trip will restart immediately.

Custom stop timeout

A trip being analyzed is automatically terminated after a period of inactivity (which begins when the vehicle has stopped). The SDK allows to set the end-of-trip duration.

By default, the trip analysis is stopped after 240 seconds. This value can be tuned according to your need and you can choose any integer values between 120 and 480 seconds by calling the following method:

fun setStopTimeOut(timeOut: Int)

If a value greater than 480 is set, the value will be forced to 480.

If a value lower than 120 is set, the value will be forced to 120.

Sharing data during the trip

The Trip Analysis component records the trip locally while it is in progress. The data are recorded with a period of one point per second. At the end of the trip, the SDK requests the driving analysis service and then retrieves the driving indicators.

In addition to this feature, the SDK is also able to share data with the server before the trip is completed. The data is transmitted at a lower frequency with a time interval of one point per minute.

The system for sharing information during the trip can be used in a vehicle fleet management system. This feature requires access to specific APIs. For more information, contact DriveQuant.

Sharing information with the server allows you to store the trip data even if it has been interrupted, and if the data post at the end of the trip could not be performed. This can happen in very rare cases such as the destruction of the mobile phone.

By default, this setting is disabled but you can enable it by calling the following method with parameter enable to true:

fun enableSharePosition(enable: Boolean)

To disable this setting, call the same method with the parameter set to false

Here is the list of data shared every minute by the SDK:

  • Date of trip start.

  • Duration of the trip in seconds.

  • Distance traveled in km.

  • Longitude of the current location.

  • Latitude of the current location.

  • Smartphone battery level.

  • StartMode of the trip recording: manual, GPS-based or beacon-based.

  • Beacon parameters: uuid, major, minor.

If the crash detection is enabled and if a confirmed crash is detected by DriveKit, the data will be shared every 10 seconds instead of 1 minute until the trip finished.

Access the trip trigger events

Why use trip triggers?

DriveKit's automatic start mode detects a trip and launches its recording immediately. This operating mode may not be appropriate for all use cases.

Your application may require other information or business logic before enabling the trip recording. For example, it may be appropriate to check that:

  • A connected device is near to the smartphone.

  • The trip recording is acceptable in a given time slot.

In this case, you may want to subscribe to the events that are indicative of the trip start but not necessarily launch the GPS sensor and the trip analysis.

This is why DriveKit allows you to subscribe to trigger events that indicate that a trip has probably started.

How does it work?

By default, this feature is disabled.

To enable this feature, DriveKit Trip Analysis should not be configured in automatic mode but in manual mode.

If DriveKit Trip Analysis is set to automatic mode, the trip will be recorded.

If DriveKit Trip Analysis is set to manual mode and you follow the instructions below, you will be able to listen for trip start trigger events but the trip analysis will not be started automatically.

To listen to trigger events that indicate a start of trip, even if the autostart is disabled, you can check the following property:

var monitorPotentialTripStart: Boolean

Once the feature is enabled, events will be available in the TripListener potentialTripStart() callback.

The potentialTripStart() method can return all StartMode values ; except MANUAL. Indeed, a trip manually started is considered as confirmed.

Last updated