appoly / ARCore-Location

Allows items to be placed within the AR world with real-world GPS coordinates using ARCore.
https://www.appoly.co.uk/arcore-location/
MIT License
478 stars 154 forks source link

Unable to see location marker #60

Closed jayvardhanc closed 5 years ago

jayvardhanc commented 6 years ago

The application runs without any errors. But I cannot see the marker placed at the desired location. The Logcat repeatedly display this message: 10-11 12:52:48.177 10853-10853/com.google.ar.sceneform.samples.hellosceneform I/LocationScene: Refreshing anchors... 10-11 12:52:48.178 10853-10853/com.google.ar.sceneform.samples.hellosceneform I/LocationScene: Location not yet established.

Is there any mistake in code?

Code:

public class HelloSceneformActivity extends AppCompatActivity { private static final String TAG = HelloSceneformActivity.class.getSimpleName(); private static final double MIN_OPENGL_VERSION = 3.0;

private ArFragment arFragment; private ModelRenderable andyRenderable; private LocationScene locationScene;

@Override @SuppressWarnings({"AndroidApiChecker", "FutureReturnValueIgnored"}) // CompletableFuture requires api level 24 // FutureReturnValueIgnored is not valid protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

if (!checkIsSupportedDeviceOrFinish(this)) {
  return;
}

setContentView(R.layout.activity_ux);
arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment);

ArSceneView arView = arFragment.getArSceneView();
//Scene scene = arView.getScene();
Frame frame = arView.getArFrame();

// When you build a Renderable, Sceneform loads its resources in the background while returning
// a CompletableFuture. Call thenAccept(), handle(), or check isDone() before calling get().
ModelRenderable.builder()
    .setSource(this, R.raw.andy)
    .build()
    .thenAccept(renderable -> andyRenderable = renderable)
    .exceptionally(
        throwable -> {
          Toast toast =
              Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
          toast.setGravity(Gravity.CENTER, 0, 0);
          toast.show();
          return null;
        });

arView
       .getScene()
       .addOnUpdateListener(
               frameTime -> {
                 if (locationScene == null) {
                   locationScene = new LocationScene(this, this, arView);
                   locationScene.mLocationMarkers.add(
                           new LocationMarker(
                                   -97.113505,
                                   32.719180,
                                   getAndy()));
                   System.out.println("Marker placed");
                 }

                 if (locationScene != null) {
                   locationScene.processFrame(frame);
                 }
               }
       );

}

private Node getAndy(){ Node base = new Node(); base.setRenderable(andyRenderable); Context c =this; base.setOnTapListener((v, event) -> { Toast.makeText( c, "Andy touched.", Toast.LENGTH_LONG) .show(); }); return base; }

public static boolean checkIsSupportedDeviceOrFinish(final Activity activity) { if (Build.VERSION.SDK_INT < VERSION_CODES.N) { Log.e(TAG, "Sceneform requires Android N or later"); Toast.makeText(activity, "Sceneform requires Android N or later", Toast.LENGTH_LONG).show(); activity.finish(); return false; } String openGlVersionString = ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)) .getDeviceConfigurationInfo() .getGlEsVersion(); if (Double.parseDouble(openGlVersionString) < MIN_OPENGL_VERSION) { Log.e(TAG, "Sceneform requires OpenGL ES 3.0 later"); Toast.makeText(activity, "Sceneform requires OpenGL ES 3.0 or later", Toast.LENGTH_LONG) .show(); activity.finish(); return false; } return true; } }

ziadagh commented 6 years ago

Could be as simple as turning on the GPS on your phone, since it says "Location not yet established". I know I've done that mistake a couple times.

jayvardhanc commented 6 years ago

I made sure that the GPS is on and also gave it enough time to get an accurate location reading. Now logcat displays 10-22 15:34:37.809 28680-28818/com.google.ar.sceneform.samples.hellosceneform W/native: localization_manager.cc:388 Map tracking detected failure condition that despite good tracking metrics gravity check failed. Reporting corrupted state.

ashif-ismail commented 6 years ago

looks to me that the cordinate you have given for andy is wrong and google maps failed to locate that position..

verify that cordinates

jayvardhanc commented 6 years ago

Co-ordinates are fine. Checked the co-ordinates on google maps. Do I need to write separate code to get the device location?

maciek-s commented 4 years ago

I have same problem on version 1.0.5 everything working but when i upragde to never i have repeated "LocationScene: Location not yet established." Edit: It only happends on Android 10 on Android 9.0 working fine