Skip to content
Snippets Groups Projects
Commit 35d29c13 authored by Stephane LOUIS DIT PICARD's avatar Stephane LOUIS DIT PICARD
Browse files

feat: add support for requesting relocalization information with a trackable UUID

parent a8be8987
No related branches found
Tags 1.1.0
2 merge requests!8New API generated code using abstract class instead of virtual.,!7Milestone B version (relocalization information, last openapi)
...@@ -55,6 +55,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers ...@@ -55,6 +55,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers
public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<GetRelocalizationInformationUuidsParameterInner> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token) public override IActionResult GetRelocalizationInformation([FromQuery(Name = "uuids")][Required()] List<GetRelocalizationInformationUuidsParameterInner> uuids, [FromQuery(Name = "capabilities")][Required()] List<Capability> capabilities, [FromHeader(Name = "token")] string token)
{ {
WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService; WorldAnchorService _worldAnchorService = WorldAnchorService.Singleton as WorldAnchorService;
TrackableService _trackableService = TrackableService.Singleton as TrackableService;
var history = new List<Guid>(); var history = new List<Guid>();
var result = new GetRelocalizationInformation200Response(); var result = new GetRelocalizationInformation200Response();
...@@ -63,6 +64,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers ...@@ -63,6 +64,13 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers
foreach (var request in uuids) foreach (var request in uuids)
{ {
var anchor = _worldAnchorService.Get(request.Uuid); var anchor = _worldAnchorService.Get(request.Uuid);
Trackable trackable = null;
if (anchor == null)
{
// anchor not found, try to find uuid as a trackable
trackable = _trackableService.Get(request.Uuid);
}
if (anchor != null) if (anchor != null)
{ {
...@@ -77,6 +85,37 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers ...@@ -77,6 +85,37 @@ namespace ETSI.ARF.OpenAPI.WorldStorage.Controllers
result.RelocInfo.Add(relocalizationInformation); result.RelocInfo.Add(relocalizationInformation);
} }
else if (trackable != null)
{
history.Add(trackable.UUID);
Matrix4x4 matrix = Matrix4x4.Identity;
var relocalizationInformation = new RelocalizationInformation();
relocalizationInformation.RequestUUID = trackable.UUID;
relocalizationInformation.RequestType = TypeWorldStorage.TRACKABLEEnum;
relocalizationInformation.RelocObjects = new List<RelocalizationInformationRelocObjectsInner>();
if (trackable.Match(capabilities))
{
// add itself with matrix identity as Transform3D
var itself = new RelocalizationInformationRelocObjectsInner();
itself.Trackable = trackable;
itself.Mode = request.Mode;
itself.Transform3D = new List<float>()
{
matrix.M11, matrix.M12, matrix.M13, matrix.M14,
matrix.M21, matrix.M22, matrix.M23, matrix.M24,
matrix.M31, matrix.M32, matrix.M33, matrix.M34,
matrix.M41, matrix.M42, matrix.M43, matrix.M44,
};
relocalizationInformation.RelocObjects.Add(itself);
}
relocalizationInformation.RelocObjects.AddRange(FindRelocInfo(trackable.UUID, request.Mode, matrix, capabilities, ref history));
result.RelocInfo.Add(relocalizationInformation);
}
else else
{ {
Console.WriteLine($"WorldAnchor with UUID {request.Uuid} does not exist in database"); Console.WriteLine($"WorldAnchor with UUID {request.Uuid} does not exist in database");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment