react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Questions around truck tracking

Open Pierre-Marie-Shippeo opened this issue 1 year ago • 4 comments

Your Environment

  • Plugin version: 4.16.2]
  • Platform: iOS and Android
  • OS version: Android : 13 & iOS : 17.5.1
  • Device manufacturer / model: All
  • React Native version (react-native -v): 0.74.2
  • Plugin config Android
{
  "activityRecognitionInterval": 10000,
  "allowIdenticalLocations": false,
  "authorization": {},
  "autoSync": true,
  "autoSyncThreshold": 0,
  "backgroundPermissionRationale": {
    "title": "Allow {applicationName} to access this device's location even when closed or not in use?",
    "message": "[CHANGEME] This app collects location data for FEATURE X and FEATURE Y.",
    "positiveAction": "Change to \"{backgroundPermissionOptionLabel}\"",
    "negativeAction": ""
  },
  "batchSync": true,
  "configUrl": "",
  "debug": false,
  "deferTime": 0,
  "desiredAccuracy": -1,
  "desiredOdometerAccuracy": 100,
  "disableAutoSyncOnCellular": false,
  "disableElasticity": false,
  "disableLocationAuthorizationAlert": true,
  "disableMotionActivityUpdates": true,
  "disableProviderChangeRecord": false,
  "disableStopDetection": false,
  "distanceFilter": 20,
  "elasticityMultiplier": 3,
  "enableHeadless": false,
  "enableTimestampMeta": false,
  "extras": {},
  "fastestLocationUpdateInterval": 120000,
  "foregroundService": true,
  "geofenceInitialTriggerEntry": true,
  "geofenceModeHighAccuracy": false,
  "geofenceProximityRadius": 1000,
  "geofenceTemplate": "",
  "headers": {},
  "headlessJobService": "com.transistorsoft.rnbackgroundgeolocation.HeadlessTask",
  "heartbeatInterval": 120,
  "httpRootProperty": "location",
  "httpTimeout": 60000,
  "isMoving": false,
  "locationAuthorizationRequest": "Always",
  "locationTemplate": "",
  "locationTimeout": 60,
  "locationUpdateInterval": 120000,
  "locationsOrderDirection": "ASC",
  "logLevel": 5,
  "logMaxDays": 3,
  "maxBatchSize": 1,
  "maxDaysToPersist": 1,
  "maxMonitoredGeofences": 97,
  "maxRecordsToPersist": -1,
  "method": "POST",
  "minimumActivityRecognitionConfidence": 75,
  "motionTriggerDelay": 0,
  "notification": {
    "layout": "",
    "title": "",
    "text": "Location Service activated",
    "color": "",
    "channelName": "TSLocationManager",
    "channelId": "",
    "smallIcon": "",
    "largeIcon": "",
    "priority": -1,
    "sticky": true,
    "strings": {},
    "actions": []
  },
  "params": {
    "deviceId": "8ae758117f73f7dc"
  },
  "persist": true,
  "persistMode": 2,
  "schedule": [],
  "scheduleUseAlarmManager": false,
  "speedJumpFilter": 300,
  "startOnBoot": true,
  "stationaryRadius": 25,
  "stopAfterElapsedMinutes": 0,
  "stopOnStationary": true,
  "stopOnTerminate": true,
  "stopTimeout": 5,
  "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking",
  "url": "https:\/\/[mobile-middleware.core.dev.shippeo.com](http://mobile-middleware.core.dev.shippeo.com/)\/api\/positions",
  "useSignificantChangesOnly": false,
  "enabled": true,
  "schedulerEnabled": false,
  "trackingMode": 1,
  "odometer": 0,
  "isFirstBoot": true,
  "didLaunchInBackground": false,
  "didDeviceReboot": false
}

iOS

activityRecognitionInterval = 10000;
activityType = 1;
authorization = {
};
autoSync = 1;
autoSyncThreshold = 0;
batchSync = 1;
debug = 0;
desiredAccuracy = "-1";
desiredOdometerAccuracy = 100;
didDeviceReboot = 0;
didLaunchInBackground = 0;
didRequestUpgradeLocationAuthorization = 1;
disableAutoSyncOnCellular = 0;
disableElasticity = 0;
disableLocationAuthorizationAlert = 1;
disableMotionActivityUpdates = 1;
disableStopDetection = 0;
distanceFilter = 20;
elasticityMultiplier = 3;
enableTimestampMeta = 0;
enabled = 1;
extras = {
};
geofenceInitialTriggerEntry = 1;
geofenceProximityRadius = 2000;
geofenceTemplate = "";
headers = {
};
heartbeatInterval = 120;
httpRootProperty = location;
httpTimeout = 60000;
iOSHasWarnedLocationServicesOff = 0;
isFirstBoot = 1;
isMoving = 0;
lastLocationAuthorizationStatus = 3;
locationAuthorizationAlert = {
cancelButton = Cancel;
instructions = "To use background location, you must enable 'Always' in the Location Services settings";
settingsButton = Settings;
titleWhenNotEnabled = "Background location is not enabled";
titleWhenOff = "Location services are off";
};
locationAuthorizationRequest = Always;
locationTemplate = "";
locationTimeout = 60;
locationsOrderDirection = ASC;
logLevel = 5;
logMaxDays = 3;
maxBatchSize = 1;
maxDaysToPersist = 1;
maxRecordsToPersist = "-1";
method = POST;
minimumActivityRecognitionConfidence = 70;
odometer = 0;
params = {
deviceId = "4EA40DCF-0595-401B-98DD-7ECFF39E2303";
};
pausesLocationUpdatesAutomatically = 1;
persistMode = 2;
preventSuspend = 1;
schedule = (
);
schedulerEnabled = 0;
showsBackgroundLocationIndicator = 1;
startOnBoot = 1;
stationaryRadius = 25;
stopAfterElapsedMinutes = 0;
stopDetectionDelay = 2;
stopOnStationary = 1;
stopOnTerminate = 1;
stopTimeout = 5;
trackingMode = 1;
url = "https://mobile-middleware.core.dev.shippeo.com/api/positions";
useSignificantChangesOnly = 0;
}

Context

We recently acquired the react-native-background-geolocation license.

We are trying to fine-tune the parameters of the library to optimize as much as possible battery consumption for our use case. In short, our use case is truck tracking and we expect to upload positions at a frequency of around 2 minutes so we can trigger geofencing events on our back-end.

Questions

  1. Any advice on recommended settings for our use case (truck tracking)?
  2. Regarding iOS, since frequency cannot be defined, what would be a recommended setup to avoid having positions every few seconds (in case the truck is on a highway), but still identifying a truck slowly arriving at a geofence location?
  3. We are not sure how elasticityMultiplier affects the tracking. We came up with this formula: adjusted_distanceFilter = distanceFilter * (1 + floor(speed / 5) * elasticityMultiplier). Is that correct?
  4. Motion & Fitness" (ios) or "Physical Activity" (android) can be seen as very invasive by some users. Do you have some feedback and/or figures on how it impacts battery performance (are we talking about a 1- 15% increase or it could more than double it?)

Many thanks for you help !

Pierre-Marie-Shippeo avatar Jun 13 '24 08:06 Pierre-Marie-Shippeo

Any advice on recommended settings for our use case (truck tracking)?

This plugin was designed for vehicle-tracking. The default values are sufficient. Your only question is what distanceFilter to choose.

Regarding iOS, since frequency cannot be defined, what would be a recommended setup to avoid having positions every few seconds (in case the truck is on a highway), but still identifying a truck slowly arriving at a geofence location?

Read the API docs Config.distanceFilter. By default, the plugin adjusts the distanceFilter based upon speed. You'll have to experiment with real field-testing to choose a distanceFilter that's right for you.

We are not sure how elasticityMultiplier affects the tracking. We came up with this formula: adjusted_distanceFilter = distanceFilter * (1 + floor(speed / 5) * elasticityMultiplier). Is that correct?

The default elasticity should be fine. You only need to be concerned with elasticityMultiplier if the default is insufficient.

Motion & Fitness" (ios) or "Physical Activity" (android) can be seen as very invasive by some users

Do you know what the plugin uses the Motion API for? You can disable it with Config.disableMotionActivityUpdates. Android will require movement of at least 200 meters before location-tracking triggers. With the Motion API, Android can trigger with just a few meters of movement.

No, there's no battery-performance stats.

christocracy avatar Jun 13 '24 13:06 christocracy

Hi Pierre, I'm developing for the same goal as yours. If you want, we can help each other.... what do you think?

souzadeveloper avatar Jun 14 '24 19:06 souzadeveloper

HI @christocracy thanks for your quick response, we have additional questions if you can help us:

  • the app sends recurrently positions that are EXACTLY the same, except the UUID that is different. Is that a bug in the library? This affect both IOS and Android
  • In iOS, the app sends burst of position that are in a short interval of like 5 seconds. We see that the accuracy is improving. How to send only the last one?

Pierre-Marie-Shippeo avatar Jun 27 '24 08:06 Pierre-Marie-Shippeo

the app sends recurrently positions that are EXACTLY the same, except the UUID that is different. Is that a bug in the library?

No, it’s not a bug. You’ve not shown any code what you’re doing with the plug-in.

In iOS, the app sends burst of position

see api docs Location.sample.

christocracy avatar Jun 27 '24 09:06 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jul 28 '24 01:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 11 '24 02:08 github-actions[bot]