Azure Spatial Anchors - How to save and get anchors - unity3d

I tried the azure-spatial-anchor-demo-package and it worked fine for me. Now I wanted to use azure in my project. In my current understanding, the coordinates of the anchor are stored. More precise information about whether it is a 3D object, and what it looks like, is not stored. If I'm wrong about this, please correct me.
Lets say I have 3 different objects: a car, house and tree.
All of them are anchors, which I instantiate in my scene. My current procedure is as follows:
_anchorModul.StartAzureSession();
I instantiate a car, house and tree and call for each of them CreateAzureAnchor();:
InstantiatedGo = Instantiate(GoToInstantiate, GetCurrentHitPosition(), Quaternion.FromToRotation(Vector3.back, _gazeProvider.HitInfo.normal)) as GameObject;
_anchorModul.CreateAzureAnchor(InstantiatedGo);
In the method CreateAzureAnchor() I set the type of my object via localCloudAnchor.AppProperties.Add("type", theObject.GetComponent<SomeClass>().Type);.
After that I save the anchors to disk via _anchorModul.SaveAzureAnchorIdToDisk();
But now I want to restart my application and get the objects at the right position. The right order should be:
Restart the application.
Get Azure Anchor from Disk
Start Azure Session
Find Azure Anchor
My Question: How do I get the found anchors, so I can access the properties I set and instantiate the related properties on my three objects?
My Specs:
Unity 2019.2.15
MRTK 2.2
AzureSpatialAnchors.unitypackage
MRTK.HoloLens2.Unity.Tutorials.Assets.AzureSpatialAnchors.2.2.0.0.unitypackage
MRTK.HoloLens2.Unity.Tutorials.Assets.GettingStarted.2.2.0.1.unitypackage

You need to make a request to the Azure service to locate an anchor using at least one of the ids saved. You can either send an array of ids or send one and ask for the nearby anchors.

Related

Store pedestrian agents position in a txt

I'm new on AnyLogic, I'm a universitary student, I'm working in my title project and I still can't get to save the coordinates of my agents in time. I've been working with this tool for near 3 months and just started to seek for help.
I tried with traceln(getX and getY), propperly written, but it only shows me the entrance position, how could I create a function to store this information onto a txt file? Or how could I create a new agent type to apply the steps above described
Please your help
Here is a simple example to show you how to do this.
I have a custom pedestrian agent that gets created in the ped source block and a population, which starts of empty where all the pedestrians that gets created get added to.
This is just so that I can have the event to record the location inside the agent and the file object to write to is on main. So we need to access main from inside the agent.
In the file object, I just set it to write and selected a blank .txt file that I created.
You can read more about using the text file from the help - https://anylogic.help/anylogic/connectivity/text-file.html
Inside the pedestrian agent, I have an event that simply saves the location to the file in a new line.
I make use of the "\t" so that the txt file is tab-separated. You can use whatever separator you prefer.
You must remember to call the close command on the text file when you have finished writing to it. I simply called it on the destroy code of main. So it only "writes" the data to the text file when you close the model.
Here is the output from this very simple example
Calling getX() and getY() on agents does definitely give their current coordinates (assuming they are in a continuous space and not GIS/discrete space) so it's likely you're calling this on the wrong agents (e.g., calling it for your instance of Main instead of for some agents living in a population inside it).
Or you're not actually calling it at different simulation times (via, say, a cyclic event), so you're only getting the initial values.

Selecting object in WorldScaleARexample

I am working on an AR app in Unity and want to display information of an object. To display said information, the user has to be able to click/select that object.
I cannot find the line of code that creates the objects.
I have tried to use a snippet of the ARTabletopKit that handles the user's input to select an object.
If I am correct, the problem is that I cannot use the DebugCanvas-GameObject of the WorldScaleAR example as it does not contain any of the actual game objects.
As far as I can see the objects are created and placed here:
unityTile.Initialize(_map, tileId, _map.WorldRelativeScale, _map.AbsoluteZoom, _map.LoadingTexture);
PlaceTile(tileId, unityTile, _map);
At last I expect the method EventSystem.current.IsPointerOverGameObject() to return true.
Cheers!
You'll need to add a [GameObjectModifier][1] to handle the onClick. You can configure the modifiers to be added at runtime on the game objects in the Map Features area of the AbstractMap.cs script.
I would take a look at how it's implemented on the Data Explorer example.

Determining highway direction

I was wondering if there is a way to get the highway direction of the route.
To be more specific, I am interested in routes on interstate highways in the United States only.
I'll give an example:
Interstate I45 is a north-south highway. When the route is returned, is there a way to know which "direction lane" the route is on?
The problem I'm trying to solve is accessing the rest ares like the one shown on the image here. As you can see, these are two rest areas, each accessible from one direction of the highway.
I would like to display only those accessible from the direction the user is on. I have all the data needed, including if the rest area is on the North/South/East/West direction and I only need the highway direction the route is on.
For obvious reasons, I would like to avoid manually checking if the route just appears to be going northwards.
I checked if this is possible via graphhopper, but it only gives the highway name, without direction. Is it possible to achieve this via Skobbler?
If you are using the TTS instructions (text-to-speech) then in the advice instructions & audio advices you will also receive the "orientation" (coded as a $orientation in the audio config files) - indicating the direction you are driving on a particular highway (south/north, etc.).
The trickier part is that you would have to parse the text instruction to get this information as it's not returned in a separate field (let me know in a comment if this was helpful).
I do not fully understand the original problem but as GraphHopper also returns the geometry for every instruction you should be able to calculate the orientation roughly but easily.
Another more complex approach would be to have a predefined name set associated with the geometry and use the map matching component to find out which highway parts are used in a route.
For obvious reasons,
which obvious reasons? That it is not really going norht south?
Or if something is not possible you always can modify in the code as it is open source or provide a pull request to merge it into the public release (if useful for others) and make it available for the Directions API too.
According to the OSM wiki page Highway Directions In The United States, directions of ways are supposed to be modeled as relation membership roles.
For example, I 75 way 173483918 is a member of the relation 332618 named "I 75 (TN northbound)" with role=north, so it's direction is "north".
The opposite way 173483897 is a member of the relation 332624 named "I 75 (TN southbound)" as role "south".
See more details on the wiki page. Don't know how well established that tagging scheme is, also don't know about router support (Telenav (Scout) seem to be involved in this who now own Skobbler).

Show orion context broker poi in map viewer

For learning porpoises I am trying to run the default map viewer set up and show the POIs stored in the orion public instance (orion.lab.fi-ware.org:1026).. but it does not work at all.
Following screenshots with the default provided configurations. It should show a bunch of Santander POIs if I understood well.
1.-Wired mashups schema:
2.- NGSI Source default settings:
3.- NGSI entity to POI default settings:
4.- Map viewer default settings:
5.- Map viewer result (No results at all :(( ):
Everything looks pretty straight forward but nothing is shown. Without understanding why it is not working I can not moving forward and work in my own implementation.
thanks in advance.
It looks to me like you have not obtained an authorization token (or you are not showing it in your question?). Without one you are not able to retrieve information from orion.lab.fi-ware.org.
One way to get a token is running this python script:
https://github.com/telefonicaid/fiware-figway/blob/master/python/get_token.py
Of course, you do need a FIWARE Lab account to get it.
The problem seems to be in the configuration of the "NGSI entity to POI". The Node, AMMS and Regulators entities provide their coordinates using the Latitud (latitude) and Longitud (longitude) attributes.
The final value for the "Coordinate attribute" setting should be: Latitud, Longitud

Getting distance between 2 markers

I would like to get the distance between 2 markers but not as a direct line, more as a real path like it goes in this plugin -
https://github.com/perliedman/leaflet-routing-machine
I didn't find anything about using this plugin in the directive: angular-leaflet-directive,
if someone can guide how to make it done, it would be very appreciated.
thanks!
I am not sure if you specifically want to use leaflet routing machine to get distances... but if you do, maybe this info can get you started:
Set up a route on your map based on this example by the leaflet routing machine author:
https://www.liedman.net/leaflet-routing-machine/tutorials/interaction/
If you look at that example, there is an array called routes. Each route has some basic statistics associated with it, generated by OSRM. You can pull them by calling for example:
routes[0].summary.totalDistance
or
routes[0].summary.totalTime
Then you can do whatever you want with them. If you dig through the code on GitHub you can see more about how the data are moved around within the plugin and why the array is arranged that way:
https://unpkg.com/leaflet-routing-machine#3.2.12/dist/leaflet-routing-machine.js