Get speed

Former Member
Former Member
Hello,

i'm writing a Watch App and i want to read the speed.

I have a function where i read the infos

var info = Sensor.getInfo();

if (info has :speed && info.speed != null) {
velocita=info.speed;
}

When i run the app in the simulator (menu Simulation -> FIT data -> Simulate data) the speed change correctly.

I have uploaded the app e load on the watch, but the speed is alway 0.

What i need to do before, to read the speed?

thanks in advance,

Federico
community.garmin.com/.../1405822.png
  • Former Member
    Former Member over 6 years ago
    thnk you !

    Federico

    See the API documentation in the SDK. You see the speed in meters per second.

    35x60x60=126000 meters/hour=126km/h


  • One other thing to keep in mind is that not everyone uses metric, and in Sys.DeviceSettings, you can see what's set for various "units" on the watch. So for example, you could use something like paceUnits or distanceUnits to go between metric and statute. On devices, my apps calculates pace from speed, so I use paceUnits for this, but it's up to you.
  • Former Member
    Former Member over 6 years ago
    I have done a few tests and there is a subtle difference between info.speed and the calculation of the displacement from GPS points.

    it seems that info.speed updates more slowly.

    Federico

    See the API documentation in the SDK. You see the speed in meters per second.

    35x60x60=126000 meters/hour=126km/h


  • Maybe a bit more slowly, but how accurate is your distance? A delay of a second or two? How are you timing you access to Sensor? onPosition is about every second in many cases.
  • Former Member
    Former Member over 6 years ago
    I have a delay of one second.

    The formula is this one

    velocita = 3600 * (6372.795477598 *
    Math.acos(
    Math.sin(ALat) * Math.sin(BLat) +
    Math.cos(ALat) * Math.cos(BLat) *
    Math.cos(ALon-BLon)));

    Federico

    Maybe a bit more slowly, but how accurate is your distance? A delay of a second or two? How are you timing you access to Sensor? onPosition is about every second in many cases.


  • But how about when you use info.speed? Maybe display that and what you are calculating at the same time to see how long/how much they differ.
  • Former Member
    Former Member over 6 years ago
    yes, i have the two calues.

    the difference seems to be in the frequence of update: info.speed seems to refresh slowly.

    Federico

    But how about when you use info.speed? Maybe display that and what you are calculating at the same time to see how long/how much they differ.


  • Are you grabbing info.speed at the same time you are calculating speed on your own?
  • Former Member
    Former Member over 6 years ago
    yes, i have 2 measures on the dial: one calculated with GPS; another one with info.speed.

    i'm studying results...


    Are you grabbing info.speed at the same time you are calculating speed on your own?