New Extension: AdvancedLocationSensor (GPS+) v1.2 UPDATE 19.10.17

3520 views
Skip to first unread message

Niclas Team

unread,
Oct 6, 2017, 6:49:34 AM10/6/17
to mitappinv...@googlegroups.com
Hi everyone,

i have expand the location sensor component, named "AdvancedLocationSensor".
My AdvancedLocationSensor-Extension has in addition to the functions of the standard LocationSensor other events:

these events are triggered when location sensor is activated or deactivated (via system settings or appsettings).



these events are triggered when location sensor finds the first position.

int TimeToFirstFix: contains time in ms



these events are triggered when the position changes.

float bearing: contains the direction of movement

long time: contains time in ms (Unix time format) <-- Satellite Time!



these events are triggered when the satellite status changes.

int cntSatView: contains the number of satellites in view

int cntSatFix: contains the number of satellites in fix

string listSatellites: contains a list of satellites [GpsSatellite

long time: contains time in ms (Unix time format) <-- Satellite Time!



these events are triggered when an nmea message has been received.

long timestamp: contains time in ms (Unix time format) <-- Phone Time!

string nmea: contains the NMEA-Message [info]




I make the extension available for free.

Greetings

Niclas



Changelog:
06.10.17 First release ("AdvancedLocation.aia", "com.ginsnic.AdvancedLocationSensor.aix")
07.10.17 updated "AdvancedLocation.aia" --> wrong event names solved
18.10.17 v1.1 event LocationSatelliteStatus got a new parameter named "time" --> see description
               (new "AdvancedLocation.aia", new "com.ginsnic.AdvancedLocationSensor.aix", new pictures in description
19.10.17 v1.2 crash of the app fixed
               (new "AdvancedLocation.aia", new "com.ginsnic.AdvancedLocationSensor.aix")
AdvancedLocation.aia
com.ginsnic.AdvancedLocationSensor.aix

Shivendra Kr. Sahu

unread,
Oct 6, 2017, 1:57:14 PM10/6/17
to MIT App Inventor Forum
Is there  1 demo version extension?

Niclas Team

unread,
Oct 6, 2017, 2:03:10 PM10/6/17
to MIT App Inventor Forum
how do you mean?

Peter Mathijssen

unread,
Oct 6, 2017, 2:20:36 PM10/6/17
to MIT App Inventor Forum
Great work!!!!

Shivendra Kr. Sahu

unread,
Oct 6, 2017, 2:22:24 PM10/6/17
to MIT App Inventor Forum
original aia file images 



but when save it as copy after  10 min 



Niclas Team

unread,
Oct 6, 2017, 5:07:11 PM10/6/17
to MIT App Inventor Forum
these event names came from a previous version.
no idea why these are now displayed. It is best to start a new project.

Taifun

unread,
Oct 6, 2017, 5:21:56 PM10/6/17
to MIT App Inventor Forum
thank you for your contribution!

these event names came from a previous version.
no idea why these are now displayed. It is best to start a new project.
you might want to check for these names in your extension source code...

Taifun

Niclas Team

unread,
Oct 6, 2017, 5:59:45 PM10/6/17
to MIT App Inventor Forum
I have just rechecked my source code. Here are no longer the old event names.
Why are they displayed after a few minutes on appInventor?

Taifun

unread,
Oct 6, 2017, 6:11:25 PM10/6/17
to MIT App Inventor Forum
you might want to ask in the Open Source Group
Taifun

Niclas Gins

unread,
Oct 7, 2017, 1:16:38 PM10/7/17
to MIT App Inventor Forum
hello I have analyzed the project more precisely.
in the project was still the old packet (com.ginsnic), the new packet is called com.ginsnic.AdvancedLocationSensor
See Screenshot in Attachment, if you use the old project delete com.ginsnic!
I updated the old project in the first entry
package.png

dorf

unread,
Sep 3, 2019, 7:29:44 AM9/3/19
to MIT App Inventor Forum
Hello.

How can I use Distance Interval?

Only Time interval works for me

SteveJG

unread,
Sep 3, 2019, 9:13:18 AM9/3/19
to mitappinv...@googlegroups.com
Are you really using the AdvancedLocationSensor extension or the native LocationSensor?   

 Niclas' extension was last updated in late 2017, you attached your question to an OLD Forum discussion. ALS is a fine extension, bu unless you need to use the satellite information contained in the satellite broadcast NEMA sentences, the LocationSensor should work fine for you. 
  • How can I use Distance Interval?  The ALS DistanceInterval works the same way as the Property does in the native LocationSensor.

    You said 'Only Time interval works for me'   What are you trying to do with the DistanceInterval using the AdvancedLocationSensor extension?  The DistanceInterval works the same way the DistanceInterval works in the native LocationSensor.   Notice that the default interval is 0 meters.  Be aware, this property cannot be used to determine if the Android has only moved small distances.  What distance are you trying to resolve? 

DistanceInterval

Determines the minimum distance interval, in meters, that the sensor will try to use for sending out location updates. For example, if this is set to 50, then the sensor will fire a LocationChanged event only after 50 meters have been traversed. However, the sensor does not guarantee that an update will be received at exactly the distance interval. It may take more than 5 meters to fire an event, for instance.

It is also useful to check against Accuracy when using this property. When your device is moving, the accuracy of the detected location is constantly changing.

This graphic shows how to set DistanceInterval with Blocks

GPSsettings.png



A discussion of Accuracy  is discussed in Using the Location Sensor  A developer has to understand that concept in order to effectively use the DistanceInterval property.

You might post an image of how you are trying to use the DistanceInterval property and finding that it apparently fails to do what you want it to do.

Regards,
Steve


dorf

unread,
Sep 6, 2019, 7:54:23 AM9/6/19
to MIT App Inventor Forum
Thanks for the answer.

I will try to explain: if I set both distance interval and time interval at the same time, then what property will be in priority? I want the sensor to fire after a given distance (for example, every 5 meters). How can I turn off time interval and use only distance interval?

SteveJG

unread,
Sep 6, 2019, 11:06:30 AM9/6/19
to mitappinv...@googlegroups.com
The answers to your questions are not simple. Here are some comments that might help you develop your app.

I set both distance interval and time interval at the same time, then what property will be in priority? The LocationChanged event will 
only fire at a set interval if the DistanceInterval is non-zero, the new location value that will post will probably not be accurate. Most Android devices 
cannot consistently resolve 5 meters. When you experimented with your device and tried to use both the DistanceInterval and the TimeInterval what happened? 

I want the sensor to fire after a given distance (for example, every 5 meters).  Set the DistanceInterval to 5. Set TimeInterval to 0.    If you are lucky the LocationChanged event will only fire if the change determined by the most recent satellite fix is about 5 meters or more. The LS will then post the new location (if you provide appropriate Blocks within the LocationChanged event). There is a problem; your Android GPS is not as accurate as you think (see the links below)
The LocationChanged event will only attempt to fire at a set interval if the DistanceInterval is non-zero, the new location value that will post will probably not be accurate. Most Android devices cannot consistently resolve 5 meters with any reliability

Why do you want the LocationSensor event to fire every five meters?  What are you trying to do? Do you intend to post these '5 meter apart' locations on a Map?  Are you trying to plot 5 meter intervals (survey a property perhaps)?  Your ultimate goal determines what you must do.

Be aware 0.00001 degrees of latitude change is a change of of about 1 meter (exactly how much distance is represented by 0.00001 degrees of latitude depends on your Latitude north or south of the equator.  At the equator latitude is 1.11 meter/ 0.00001 deg, at 45 deg. latitude the distance is about 0.79 meter ).  Your Android cannot accurately resolve 1 meter or even 5 meters reliably.  A change in 5 meters displacement depends on both the change in latitude and longitude.

To resolve a change in location of five meters reliably there must be a new satellite fix completed and Accuracy must be 5 or less.  Some devices will never provide an Accuracy that precise.  My tablet can, but my cell cannot.  The resolution possible with your GPS hardware depends on how many receive channels are present in your GPS receiver.

How can I turn off time interval and use only distance interval?  You can set TimeInterval to 0 .  That might elicit the behavior you want  You need to test this to see if it will work for you by perhaps walking outside a few hundred meters and posting the results on your Android screen or locations posted as you walk.  You can also un-enable the LS but then you will never display/elicit a LocationChanged event. Setting TimeInterval to 0 while setting DistanceInterval to a reasonable value works well with my Android 8.1 tablet; my 4.4 cell phone gets flustered. 5 meters is certainlya  border line reasonable interval to trap.


Re-read the description about what the the DistanceInterval does again. "the sensor does not guarantee that an update will be received at exactly the distance interval. It may take more than 5 meters to fire an event, for instance."

You expect to engage the LocationSensor every five meters (exactly ?) of movement?  You can't do that with any reliability.  Why?  Read about Accuracy in the Using the Location Sensor and this  https://stackoverflow.com/questions/1567443/how-accurate-is-android-gps .  To improve reliability to ensure a posting only after a 5 meter shift, check the Accuracy of the satellite fix; if the fix is less than the DistanceInterval (in your example 5 meters) , the change is probably a valid point (close to 5 meters).  When you filter using the Accuracy to eliminate suspect points, youmight miss a 5 meter interval.  Only you can decide how to handle that.

Not sure?   Post your location changes that are triggered as potentially being a 5 meter change in position on a MIT Map component as the supposedly 5 meter points  'arrive'.  Calculate the distance from the previous posting Marker to the most recent posting Marker using  perhaps  call Marker.DistanceToFeature  or saving the latitude/longitude of the immediately previous location with the posted location and calculating the distance between them  The DistanceToFeature Block will tell you what the separation actually is after you compare the previous with the current point.   If you do this 'check', do you get the results you want?

Regards,
Steve
Reply all
Reply to author
Forward
0 new messages