transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.65k stars 426 forks source link

Speed shown in onLocation function is not the same than real speed #318

Closed gianpieroc closed 7 years ago

gianpieroc commented 7 years ago

Your Environment

Expected Behavior

Show the real speed when I take a Ride

Actual Behavior

It's not showing the real speed (always less than real speed)

Steps to Reproduce

  1. BackgroundGeolocation.un('location', this.onLocation);

  2. onLocation = location => { return this.addCoords(location); };

    addCoords = location => { this.setState({ coordinates: [ ...this.state.coordinates, { latitude: location.coords.latitude, accuracy: location.coords.accuracy, heading: location.coords.heading, longitude: location.coords.longitude, speed: location.coords.speed } ], currentSpeed: location.coords.speed }); };

  3. a simple console log of currentSpeed

christocracy commented 7 years ago

Logs please.

gianpieroc commented 7 years ago
2017-09-12 23:13:32.855 [info][tid:com.facebook.react.JavaScript] { coords: 
   { heading: 267.89,
     accuracy: 5,
     altitude_accuracy: -1,
     longitude: -122.03611286,
     altitude: 0,
     latitude: 37.33454847,
     speed: 24.59 },
  sample: true,
  battery: { is_charging: false, level: -1 },
  extras: {},
  is_moving: true,
  activity: { confidence: 100, type: 'unknown' },
  odometer: 826723.7,
  uuid: '3BDB2EA5-D033-48A3-9C3F-497769253A56',
  timestamp: '2017-09-13T03:13:32.854Z' }
2017-09-12 23:13:32.897 [info][tid:com.facebook.react.JavaScript] { coords: 
   { heading: 267.89,
     accuracy: 5,
     altitude_accuracy: -1,
     longitude: -122.03611286,
     altitude: 0,
     latitude: 37.33454847,
     speed: 24.59 },
  extras: {},
  is_moving: true,
  activity: { confidence: 100, type: 'unknown' },
  event: 'motionchange',
  odometer: 826971.4,
  uuid: '851A7C44-DFCF-429D-B70B-7DCA92CD6BD0',
  battery: { is_charging: false, level: -1 },
  timestamp: '2017-09-13T03:13:32.867Z' }
2017-09-12 23:13:33.788 [info][tid:com.facebook.react.JavaScript] { coords: 
   { heading: 268.95,
     accuracy: 5,
     altitude_accuracy: -1,
     longitude: -122.03638578,
     altitude: 0,
     latitude: 37.33454218,
     speed: 25.1 },
  extras: {},
  is_moving: true,
  activity: { confidence: 100, type: 'unknown' },
  odometer: 826995.6,
  uuid: '9AF6AE44-1E30-4576-9126-FDFF15687905',
  battery: { is_charging: false, level: -1 },
  timestamp: '2017-09-13T03:13:33.761Z' }
2017-09-12 23:13:34.150343-0400 RevdApp[20212:1387612] [] nw_connection_get_connected_socket_block_invoke 12 Connection has no connected handler
2017-09-12 23:13:34.773 [info][tid:com.facebook.react.JavaScript] { coords: 
   { heading: 269.3,
     accuracy: 5,
     altitude_accuracy: -1,
     longitude: -122.03666775,
     altitude: 0,
     latitude: 37.33454235,
     speed: 25.15 },
  extras: {},
  is_moving: true,
  activity: { confidence: 100, type: 'unknown' },
  odometer: 827020.6,
  uuid: '3D562CBF-4D04-4C95-9402-993D2ED819CB',
  battery: { is_charging: false, level: -1 },
  timestamp: '2017-09-13T03:13:34.764Z' }
2017-09-12 23:13:35.679 [info][tid:com.facebook.react.JavaScript] { id: '762fabff-1ae8-49b5-aaaa-a66ffd7b0acb', steps: {} }
2017-09-12 23:13:35.683 RevdApp[20212:1387608]
christocracy commented 7 years ago

When I say "Logs", I mean plugin logs.

See Debugging

The reported speed here is ~25 m/s (90 km/h). What was the real speed?

Anyway, there's nothing the plugin can do -- it's only the messenger.

It's like getting mail from the government saying you owe $5000 in taxes -- the mailman has no control over your tax bill.

gianpieroc commented 7 years ago
🎾-[TSLocationManager startUpdatingLocation] Location-services: ON
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
πŸ”΅-[Settings incrementOdometer:] 149187.6
ℹ️-[TSLocationManager locationManager:didUpdateLocations:] <IGNORED> Ξ”t since last: -0.0s
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: A3D7CBD9-05A1-4715-B50C-A56339407113
βœ…-[BackgroundTaskManager createBackgroundTask] 5
βœ…-[TSHttpService schedulePost:] LOCKED: 455DE922-43D2-4447-8D60-F93552D6DB55
⚠️-[TSHttpService doPost:] HTTP ERROR: 0
***
* The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
*
{
    NSErrorFailingURLKey = "http://server.com/locations";
    NSErrorFailingURLStringKey = "http://server.com/locations";
    NSLocalizedDescription = "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.";
    NSUnderlyingError = "Error Domain=kCFErrorDomainCFNetwork Code=-1022 \"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.\" UserInfo={NSErrorFailingURLStringKey=http://server.com/locations, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLKey=http://server.com/locations}";
}
βœ…-[TSHttpService post:error:] UNLOCKED: 455DE922-43D2-4447-8D60-F93552D6DB55
ℹ️+[LocationAuthorization run:] status: 3
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 4 OF (
    4,
    5
)
ℹ️-[TSLocationManager locationManager:didUpdateLocations:] <IGNORED> Ξ”t since last: 0.0s
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 5 OF (
    5
)
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
πŸ”΅-[Settings incrementOdometer:] 149218.0
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: 88D0F856-BDEC-4326-AA10-26FD20256D9F
βœ…-[BackgroundTaskManager createBackgroundTask] 6
βœ…-[TSHttpService schedulePost:] LOCKED: 455DE922-43D2-4447-8D60-F93552D6DB55
⚠️-[TSHttpService doPost:] HTTP ERROR: 0
***
* The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
*
{
    NSErrorFailingURLKey = "http://server.com/locations";
    NSErrorFailingURLStringKey = "http://server.com/locations";
    NSLocalizedDescription = "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.";
    NSUnderlyingError = "Error Domain=kCFErrorDomainCFNetwork Code=-1022 \"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.\" UserInfo={NSErrorFailingURLStringKey=http://server.com/locations, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLKey=http://server.com/locations}";
}
βœ…-[TSHttpService post:error:] UNLOCKED: 455DE922-43D2-4447-8D60-F93552D6DB55
2017-09-13 11:22:49.611492-0400 RevdApp[29529:1561746] [] nw_connection_get_connected_socket_block_invoke 13 Connection has no connected handler
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 6 OF (
    6
)
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
πŸ”΅-[Settings incrementOdometer:] 149249.4
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: 78397732-DB4B-422D-92B7-2C355AD0CC09
βœ…-[BackgroundTaskManager createBackgroundTask] 7
βœ…-[TSHttpService schedulePost:] LOCKED: 455DE922-43D2-4447-8D60-F93552D6DB55
christocracy commented 7 years ago

You've shown me about 10 seconds of logs. There's nothing interesting to see here.

christocracy commented 7 years ago

Please don't post long logs to the thread. Attach them as a file.

Are you not setting LOG_LEVEL_VERBOSE? You should see raw location being logged, which is primarily what I'm interested in, like this:

πŸ“<+37.33451917,-122.03813827> +/- 5.00m (speed 27.07 mps / course 268.95) @ 9/13/17, 11:25:29 AM GMT-04:00

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 50.0m | age: 0.0s
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0

I'm not concerned with these lines.

⚠️-[TSHttpService doPost:] HTTP ERROR: 0
gianpieroc commented 7 years ago

I will remove unnecessary logs commented before.

πŸ“<+37.33446146,-122.04380955> +/- 5.00m (speed 34.77 mps / course 270.35) @ 9/13/17, 12:06:02 PM Venezuela Time

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.1s
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
ℹ️-[TSLocationManager locationManager:didUpdateLocations:] <IGNORED> Ξ”t since last: 0.0s
ℹ️+[LocationAuthorization run:] status: 3
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 5 OF (
    5,
    6
)
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 6 OF (
    6
)
2017-09-13 12:06:03.680946-0400 RevdApp[29759:1578741] [] nw_connection_get_connected_socket_block_invoke 12 Connection has no connected handler

πŸ“<+37.33445832,-122.04420408> +/- 5.00m (speed 34.56 mps / course 270.35) @ 9/13/17, 12:06:03 PM Venezuela Time

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
πŸ”΅-[Settings incrementOdometer:] 153697.6
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: F402CA6D-D4B7-46C4-B5FD-2D7E77766E2D

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService flush:error:] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
βœ…-[BackgroundTaskManager createBackgroundTask] 7
βœ…-[TSHttpService schedulePost:] LOCKED: 6A622977-F57D-4D22-95CF-87C1BA302B79
βœ…-[TSHttpService post:error:] UNLOCKED: 6A622977-F57D-4D22-95CF-87C1BA302B79

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService finish:error:] Success: 0
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 7 OF (
    7
)

πŸ“<+37.33445442,-122.04458579> +/- 5.00m (speed 34.06 mps / course 269.65) @ 9/13/17, 12:06:04 PM Venezuela Time

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
πŸ”΅-[Settings incrementOdometer:] 153731.4
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: 06637788-3FB4-41CE-93A9-B2E6B6100CEB

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService flush:error:] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
βœ…-[BackgroundTaskManager createBackgroundTask] 8
βœ…-[TSHttpService schedulePost:] LOCKED: 6A622977-F57D-4D22-95CF-87C1BA302B79

βœ…-[TSHttpService post:error:] UNLOCKED: 6A622977-F57D-4D22-95CF-87C1BA302B79

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService finish:error:] Success: 0
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
βœ…-[BackgroundTaskManager stopBackgroundTask:]_block_invoke 8 OF (
    8
)

πŸ“<+37.33444763,-122.04496063> +/- 5.00m (speed 33.54 mps / course 269.65) @ 9/13/17, 12:06:05 PM Venezuela Time

╔═══════════════════════════════════════════════════════════
β•‘ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | df: 10.0m | age: 0.0s
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
πŸ”΅-[TSLocationManager calculateMedianLocationAccuracy:] Median location accuracy: 5.0
πŸ”΅-[Settings incrementOdometer:] 153764.6
βœ…-[TSLocationManager persistLocation:]_block_invoke INSERT: A472EBB8-7FA3-40CC-99F8-985026595889

╔═══════════════════════════════════════════════════════════
β•‘ -[TSHttpService flush:error:] 
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
βœ…-[BackgroundTaskManager createBackgroundTask] 9
βœ…-[TSHttpService schedulePost:] LOCKED: 6A622977-F57D-4D22-95CF-87C1BA302B79
christocracy commented 7 years ago

This is your speed as reported directly from the iOS location api CLLocationManager (whose data comes directly from GPS satellites): 34.77 meters/second (~122 km/h)

πŸ“<+37.33446146,-122.04380955> +/- 5.00m (speed 34.77 mps / course 270.35) @ 9/13/17, 12:06:02 PM Venezuela Time

gianpieroc commented 7 years ago

My bad converting distance/time units

androidexperts155 commented 4 years ago

can you please let me know your SI unit of speed

christocracy commented 4 years ago

What else could it possible be, but "meters / second"?