Start a new topic

Display a 3D Object anchored on the ground via Geolocation

Hello there,

I am facing an issue in the Android application I am currently developing with Wikitude. I cannot display 3d objects anchored to the ground, while using Geolocation to position them within the AR Scene. Instead I am getting the 3d objects floating regardless of the change of the translate{x,y,z} values or the change of the alititude itself.

At this point, I also have to mention that I test the application while being on the first floor of a building (~4 meters above the sea level). I don't know if this is the cause of my issue, but I would like someone to see through this matter since there is not a single piece of documentation or post in the Wikitude forums that can be of assistance. 

I am building an indoor navigation application with access to the AR scene so that the user can navigate towards PoIs.

Here is a code sample of my JavaScript class in which I define these 3d objects based on AR.Geolocation:

loadPath: function loadPathFn(poiData){

 

                        this.poiData = poiData;

 

                        var pathLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude);

 

                        var myModel = new AR.Model(

                                    "assets/desole.wt3", {

                                        translate: {

                                            x: 0.7,

                                            y: -4,

                                            z: -1

                                        },

                                        scale: {

                                            x: 0.01,

                                            y: 0.01,

                                            z: 0.01

                                        },

 

                        });

 

                        this.diceObject = new AR.GeoObject(pathLocation, {

                                        drawables: {

                                            cam: myModel

                                        }

                        });

            World.updateStatusMessage('1 place loaded');

    },


The values of poiData.latitude, poiData.longitude, poiData.altitude contain information about a location close to the user, as they are an array of LatLngs originally that construct a path from the user's location to the PoI.

Please help me, I've been looking for a solution for the past two months and it's frustrating!!!!

Thank you very much in advance


Hi,


Altitude accuracy is a crucial thing. Although "good" GPS may mean acceptable horizontal accuracy, the altitude value is usually way more inaccurate.
Just log the altitude values via AR.context.onLocationChanges JS callback function.


If you want to display an AR.Model 100 meters below the user either use AR.RelativeLocations or go for your current approach but ensure to always pass over harmonic altitude values when calling "architectView.setLocation" - e.g. use lat/lon from your LocationService, but always use 0 or adjusted previously known altitude (note that architectView.setLocation in native iOS/Android code, cause execution of AR.context.onLocationChanged function in JS environment).


Please ensure to manually set the altitude of the user to a fixed value because otherwise it will e.g. be "undefined" in case the user has poor GPS or is in WiFi or make big jumps due to poor vertical GPS accuracy. (Note: Whenever user's altitude is not reported to the architectView objects are shown at user's altitude).


In general changing location values, that are reported to the SDK might result in the model moving, as the models values are fixed.


Thx and greetings

Nicola


1 person likes this

Hello Nicola,

Thank you very much for all this valuable information. 

Yes, I have been using standard manual values for altitude all this time and not the location.getAltitude() parameter because it is indeed inaccurate and I am testing the app in the first floor (getAltitude takes the altitude of the sea level as value).

The only value of altitude that has been working for me is -32768f which I found in one segment of your documentation regarding GeoLocations. I do not know why this value works, if I increase or decrease it by a small margin, the 3d objects don't even appear on the screen.

Anyways, I am now using both location.getAltitude() from the Google Location API and a manual value to find the optimal calibration for me. For example this is what my architectView.setLocation looks like now:

this.architectView.setLocation(latLng.latitude, latLng.longitude, location.getAltitude()-1040, accuracy);


Gets called in JS and gives my 3d objects this altitude.


It seems a little bit better right now.



Hi,


Good to hear that it works better for you and for providing the details on what solution helped you.


Thx and greetings

Nicola

Login or Signup to post a comment