I trying to build augmented reality navigation using arcore in android. Is AR navigation direction is available in india? I just followed this link to develop ar navigation with core loaction using arcore. https://github.com/appoly/ARCore-Location/tree/legacy.
Is it possible to do ar navigation using ARCore in android? Any help much appreciated pls....
I also worked on this and According to me, it is possible. I haven't finished it yet due to some other works but I can tell you the steps you can follow to achieve this.
Initially, you need to find out how to place an object without tapping on the screen as ARCore sample won't allow this. I asked this question on StackOverflow and finally getting a satisfactory answer which actually worked. How to place a object without tapping on the screen. You can refer this to achieve that.
After this, you need to find out the direction to which you need to place your ar object showing as the direction. for this, find out the heading using this formula
let lat1:Double = latSource/180 * .pi
let lng1:Double = lngSource/180 * .pi
let lat2:Double = latDestination/180 * .pi
let lng2:Double = lngDestination/180 * .pi
let y = sin(lng2 - lng1)*cos(lat2)
let x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lng2 - lng1)
let tan2 = atan2(y, x)
let degre = tan2 * 180 / .pi
if degre < 0 { return degre+360 }
else { return degre }
You need to pass the latitude and longitude of source and destination then this will return you the angle from TrueNorth of your destination. This is written is Swift, I hope you can convert it into your desired language. Java or Kotlin
Then you need to match this angle with your device compass angle and when it both matches use the method of without placing an object. I already shared the link. This will give you the object towards your destination.
After that, make a loop and place object at different z-axis. This is the code which I wrote the do this
@Override
public void onUpdate(FrameTime frameTime) {
frame = fragment.getArSceneView().getArFrame();
if (frame != null) {
for (Object o : frame.getUpdatedTrackables(Plane.class)) {
plane = (Plane) o;
if (plane.getTrackingState() == TrackingState.TRACKING) {
fragment.getPlaneDiscoveryController().hide();
Iterator iterableAnchor = frame.getUpdatedAnchors().iterator();
if (!iterableAnchor.hasNext()) {
method(plane, frame);
}
}
}
}
}
public void makeAr(Plane plane, Frame frame ) {
for (int k = 0; k <10 ; k ++) {
if (this.degree >= 160 && this.degree <= 170) {
Toast.makeText(this, "walk", Toast.LENGTH_SHORT).show();
List<HitResult> hitTest = frame.hitTest(screenCenter().x, screenCenter().y);
Iterator hitTestIterator = hitTest.iterator();
while (hitTestIterator.hasNext()) {
HitResult hitResult = (HitResult) hitTestIterator.next();
modelAnchor = null;
modelAnchor = plane.createAnchor(hitResult.getHitPose());
AnchorNode anchorNode = new AnchorNode(modelAnchor);
anchorNode.setParent(fragment.getArSceneView().getScene());
TransformableNode transformableNode = new TransformableNode(fragment.getTransformationSystem());
transformableNode.setParent(anchorNode);
transformableNode.setRenderable(MainActivity.this.andyRenderable);
float x = modelAnchor.getPose().tx();
float y = modelAnchor.getPose().compose(Pose.makeTranslation(0f, 0f, 0)).ty();
transformableNode.setWorldPosition(new Vector3(x, y, -k));
}
}
}
}
private Vector3 screenCenter() {
View vw = findViewById(android.R.id.content);
return new Vector3(vw.getWidth() / 2f, vw.getHeight() / 2f, 0f);
}
This OnUpdate method draw the Ar towards the destination. After getting this, you need to arrange everything with the Google Map Api data.
According to me, this is the best possible way to do navigation in AR using ARCore because there are very limitation in ARCore may be in future there will be some other libraries which will available to make it easy.
I also tried the ArCore Location but this won't help you beacuse it places the 2D image not the 3D as well as it is not stable when you are walking on the road.
Good Luck, Hope you'll finish this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With