Location Sensor (Speed)

Welcome Xinzhi.

What did you try? Explain what is not working?

How speed works is explained here> How do we measure our speed with location.(speedometer) and did you read the posts in this post in comment #10 ?


This is my code. I was trying to run a speedometer with a graph,but it doesn't work

I just wanna make a speedometer app for a bike something

Here are two ways to make a gauge (speedometer); one uses the Canvas another uses GoogleCharts Make an Analog Gauge and use it to display something useful. The example shows an Altimeter gauge; you can instead plot km/hr or miles/hr by adapting the Blocks.

Here is how the LocationSensor measures speed https://groups.google.com/g/mitappinventortest/c/OxxRsUWzwpw/m/-JlxAS49AwAJ .

Try some Blocks, if you still have issues ask again and you will get specific advice.

Some time ago I wrote an app as you describe using the Canvas. I will see if I can find the code.

1 Like

Hi aia Can you share the extension?
Thanks

Extension? None is needed, see A Basic LocationSensor Speedometer

If you want to try an extension LocationSensor, try searching App Inventor Extensions | Pura Vida Apps ; there are several.

2 Likes

Thank you brother

1 Like

this is an interesting problem to detect 0 velocity and i have no good solution to offer and also would need it in my app.
but i think the implementation of SPEED calculation is not perfected in the location sensor n appinventor and here is why i think so.
i used the location sensor speed information in parallel with my old garmin hiking GPS ETREX Vista HCx
first on the side i found a disturbing fact. the phone gives an altitude of 250 ft and garmin reads like 330ft. 330 is also what the topo map indicates, so phone altitude is off. not only in the appinventor also in other GPS app. my phone is a motorola G stylus

back to speed.
the garmin takes about 2 seconds to recognize i stopped walking. i can walk as slowly as 0.8 mi/h and it is still recognized as moving.
in my app it takes about 10sec or more to come to a 0 velocity reading and sometimes it NEVER reads 0 because it does not get a new trigger. i use the location change as trigger and the timer interval is set to 10000ms.
so clearly the garmin does an excellent job in measuring the velocity to very low speed and can quickly differentiate the stopping condition.
and the garmin uses in the conditions mentioned 8 satellites and the phone says it uses 16 out of 24 visible.
therefor i would say garmin has the better algorithm to measure speed and therefor it is possible to have a better 0 speed condition threshold. i mean to tell me within 2 seconds i am not moving is great.
i assume the gramin uses higher sampling rate and more averaging to get a better position fix.
garmin says its accuracy was 3-6 ft and phone had like 6-10m inaccuracy.

any comments?

thanks
erhard

Hi Erhard.

You need to detect 0 velocity and say you don't have a good solution to offer in your app regarding speed. The algorithm App Inventor uses to determine speed is based on using two LocationSensor changed events and is provided by Google. The algorithm requires two LocationChanged events to occur to provide a 'speed'. You might find the speedometer tutorial below interesting.

You say your phone altitude is off and note that this is not only in the app inventor but also in other GPS apps. The Garmin has a barometric altimeter; the LocationSensor uses an algorithm to estimate altitude using satellite information. It is known that altitude precision is approximate at best based on satellite information alone. See GPS versus barometric altitude – the definitive answer

You might wish to read to read about Altitude and Accuracy in Using the Location Sensor

You have a Garmin GPS receiver GPS ETREX Vista HCx eTrex Vista® HCx | Garmin . The Garmin has a high-sensitivity, WAAS-enabled GPS receiver. WAAS uses multiple ground reference stations positioned across the U.S. that monitor GPS satellite data and are used to enhance gps information. The main benefit of the WAAS is a greatly improved accuracy. Traditional GPS is accurate to 15 meters (about 50 feet) (what you get with your cell phone using the LocationSensor). WAAS-enabled GPS is accurate to less than 3 meters 95 percent of the time so your Garmin is more precise than your cell without an extension. The literature reports various estimates of accuracy and ways to achieve greater accuracy. Most of the enhanced accuracy/reliability are beyond the capabilities of App Inventor and a cell phone.

The Motorola G stylus can use the following constellations: GPS, AGPS, LTEPP, SUPL,Glonass, Galileo. The LocationSensor provided with App Inventor can only read and process GPS. There are LocationSensor extensions that can use more constellations/satellites (search for them). This means greater Accuracy can be achieved with your hardware; but not with the present software App Inventor provides. Try an extension. Will an extension help with 'speed', I doubt it but perhaps; let us know if you try using one. The gps receivers in cell phones are not known for particularly great receiving sensitivity. It is near impossible to get information w.r.t. what gps chip any device has and its specifications.

Your LocationSensor is sampling (or attempting to sample) every 10 seconds. See the comments in

[quote="SteveJG, post:27, topic:1957"]
see A Basic LocationSensor Speedometer
[/quote] regarding sampling and /speed.

I doubt it, advertising is persuasive. You like to hike. Find a benchmark and check out the location coordinates and altitude. What do you find? Close but not precise? However I suspect your Garmin is better than the LocationSensor tool used with the gps. :cry:

0 'speed' ... best determined when your feet stop trekking. :slight_smile: Hope something here is useful.

1 Like

SteveJG agree with all you rare saying. in the garmin i only used the GPS elevation not the barometer. i also checked the readout against the topo map where i am and the phone is like 100 ft off as i said. actually i do have an older G4 phone which is also off and same as newer phone.
yes i will try another extension.

thanks
erhard

i implemented the KIO4 extension and it works very well - i think as good as the garmin. that again means with the GPS data delivered internally one can make a great GPS app