google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

Sceneform Objects when resolved from Cloud Anchors are not placed on the surface. #170

Closed rohitagarwal3011 closed 4 years ago

rohitagarwal3011 commented 6 years ago

I am hosting multiple nodes using Cloud Anchors and I am able to resolve them too. But the problem is that when we resolve the nodes they are not perfectly placed on the surface. They keep floating in the air and the position of the nodes are slightly shifted up to 2-3 meters.

dsternfeld7 commented 6 years ago

Are you setting the position of the nodes by setting the world position, or the local position relative to the cloud anchor?

rohitagarwal3011 commented 6 years ago

Local position relative to cloud anchor.

claywilkinson commented 6 years ago

Can you share a screenshot of the problem?

To confirm what you are doing:

On the hosting side, you are placing an anchor (is it on a plane or an oriented point or image)? Capturing the local positions of the children of the anchorNode.

Then on the resolving side you resolve the anchor successfully, retrieve the local positions from the hosting side, and position the child nodes of the anchorNode based on the resolved anchor by calling setLocalPosition().

rohitagarwal3011 commented 6 years ago

@claywilkinson Yes this is exactly what i am doing. The problem is that when i resolve the anchorNode and the child nodes, they don't land up on the surface. They are all placed few inches above the surface and are floating. Their position are fetched from firebase and am using setLocalPosition() to place them correctly but there are always a few issues with their position.

rohitagarwal3011 commented 6 years ago

I will try to send a proper screenshot in which the problem can be understood easily.

dsternfeld7 commented 6 years ago

Closing due to inactivity.

luislukas commented 5 years ago

@dsternfeld7 I would like to follow up this issue since I'm experiencing the same. These are the steps I follow: To save in Firebase

` val frame = mArFragment.arSceneView.arFrame

val anchor = hitResult.createAnchor()

val imageNode = Node()

imageNode.renderable = myRenderable

val anchorNode = AnchorNode(anchor)

imageNode.setParent(anchorNode)

fragment.arSceneView.scene.addChild(anchorNode)

val cloudAnchor = mSession?.hostCloudAnchor(anchor)

mCloudAnchor?.let { //if cloudAnchor.cloudAnchorState is Anchor.CloudAnchorState.SUCCESS //Then store cloudId AND the local position storeInTheCloud(cloudAnchor.cloudAnchorId, anchorNode.localPosition) }`

Retrieving from Firebase `val vector3 = // it's stored in Firebase with the given cloudId

val anchorFromCloud = mSession?.resolveCloudAnchor(key)

val imageNode = Node()

imageNode.renderable = myCustomRenderable

val anchorNode = AnchorNode(anchorFromCloud)

imageNode.setParent(anchorNode)

anchorNode.localPosition = vector3

fragment.arSceneView.scene.addChild(anchorNode) `

If I resolve from the cloud the anchor just holding the phone at the same position as I stored it, it pretty much looks like the original, just a slight hovering over the ground. If I go somewhere else in the room, the resolved object it's either floating in the room or looking really small and in a different place other than the original. In either case I apply any scaling or re-sizing etc.

Let me know if you need more info.

luislukas commented 5 years ago

Attached here are the images, original and resolved (from another point in the room). original resolved

malik-at-work commented 5 years ago

Reopening this to look at it.

abramyan commented 5 years ago

In either case I apply any scaling or re-sizing etc.

@luislukas just to clarify, you do or don't apply any scaling or resizing?

luislukas commented 5 years ago

Hi @abramyan, answering your question, I do not apply any scaling or resizing. I just resolve the cloud anchor and add the Renderable there.

luislukas commented 5 years ago

Just reading the ArCore documentation on cloud anchors, seems that the following recommendations might be the cause of the behaviour I experience:

Hosting Before hosting an anchor:

Try to look at the anchor from different angles. Move around the anchor for at least a few seconds. Make sure you are not too far away from the anchor. Resolving When resolving an anchor:

Make sure you are close to where the anchor was hosted. If you are too far away from a cloud anchor’s position, it might resolve incorrectly. A Cloud Anchor might resolve incorrectly if your device camera is pointed at a space that is different from but visually identical to where the Cloud Anchors were hosted.

abramyan commented 5 years ago

@luislukas Did the recommendation from the documentation solve the issue?

luislukas commented 5 years ago

@abramyan following the recommendations does solve the issue, ie. if you create and store a cloud anchor and resolve it in the same position it is displayed well. However, If you move, let's say, 3 or 4 metres away from where you created the anchor including a change in the camera position, it keeps behaving wrongly. My use case involves creating and storing cloud anchors within a room and then resolving them from people entering the room for example, without knowing exactly where the anchors were created. I would expect that people coming into the room would see the resolved objects in the same position at least, so that they could walk in and explore the area, come closer to the object and see it.

praveenbbhati commented 5 years ago

Hi everyone, any update in 2019?

malik-at-work commented 4 years ago

The ArCore team has been paying attention to this and has been incrementally improving it. Current versions of ArCore resolve cloud anchors much closer now. This may continue to improve but we are not tracking it as a bug. Closing this for now since they have marked it resolved internally.