Reputation: 99
I implement an app with ARCore and Sceneform,which places AR markers at the specific gps location in real world.To keep the marker static in the real world,I use the anchor created in the "air"(not associated with the trackable object such as the plane):
mAnchor=session.createAnchor(
frame.getCamera().getPose()
.compose(Pose.makeTranslation(xrotated,y,zrotated))
.extractTranslation()
);
where xrotated, y, zrotated are the relative distance between the camera's gps location and the destination gps location.
But I find the anchors created in this way are not static,That is to say,when I move my phone,the markers move parallel with the phone and can drift even up to 10 meters and more.
I try to create the anchor by tapping on the screen,the rendering node attched to the anchor works fine.when the phone moves,it keep static like it is a real marker in the real world.
I find the description like this
placing an anchor that is not associated with a Trackable object is usually not a good experience. The trackable object (planes, augmented images, oriented points) are update by ARCore to represent the connections between the real world image and the augmented, virtual images. If you place an anchor in the "air", it will drift and move relative to the real world.
in the https://github.com/google-ar/sceneform-android-sdk/issues/185.
I want to know whether the reason is just the anchor created in the air and not associated with the trackable object or it is other factors which cause the marker moving parallel with the camera but I have not found.In ARKit,I have not found such issues,so it is because the ARCore has not dealt with GeoAR?
Upvotes: 2
Views: 517
Reputation: 58103
First of all, you need a certified magnetometer hardware in your device that meets the Geospatial API requirements, for working with Geospatial anchors in ARCore. Note that some magnetometers don't meet the specification; alas, devices with those off-spec magnetometers aren't supported.
There are three types of geospatial anchors in ARCore 1.46.0 now: World Geodetic System 1984, Terrain and Rooftop. WGS84
anchors needn't to be server-resolved (WGS84 is a reference system used by the GPS for mapping apps), but Terrain
and Rooftop
anchors need to be resolved by Google Maps server. It should be said that the positioning accuracy of your anchor may be too low if Visual Positioning System's info is unavailable (this also results in some kind of drifting that you are seemingly experiencing). Also, the ARCore app must be connected to the internet, and the location must be known to the VPS. Don't run the app indoors, use it outdoors during daylight.
Below is a code snippet where you can see an Earth trackable object. Trackables are stable in ARCore. Here's what Google official documentation says about trackables:
You can anchor virtual objects to specific trackables to ensure that the relationship between your virtual object and the trackable remains stable even as the device moves around.
val session = Session(this)
val config = Config(session)
config.geospatialMode = Config.GeospatialMode.ENABLED
val earth = session?.earth ?: return // Earth object is nullable
if (earth.trackingState == TrackingState.TRACKING) {
val anchor = earth.createAnchor(
latitude,
longitude,
altitude,
quaternionX,
quaternionY,
quaternionZ,
quaternionW
)
}
The good news is that you can create a Geospatial anchor (any of the three types of anchor described earlier) from a hit-test result. For that, you have to use the Pose from the hit-test and convert it to a GeospatialPose.
Upvotes: 0
Reputation: 1
Anchors should be attached to an existing Trackable to ensure a consistent quality of tracking for the reasons you've mentioned. Anchors that aren't attached to anything are difficult to keep in a fixed position in the world's understanding, and will exhibit drift and unstable locations.
Upvotes: 0