diff --git a/backend/api.test/Client/AreaTests.cs b/backend/api.test/Client/AreaTests.cs index 078c67c07..f28e00a2c 100644 --- a/backend/api.test/Client/AreaTests.cs +++ b/backend/api.test/Client/AreaTests.cs @@ -287,20 +287,23 @@ public async Task UpdateDefaultLocalizationPoseOnDeck() string deckId = deck.Id; string url = $"/decks/{deckId}/update-default-localization-pose"; - var query = new Pose + var query = new CreateDefaultLocalizationPose { - Position = new Position + Pose = new Pose { - X = 1, - Y = 2, - Z = 3 - }, - Orientation = new Orientation - { - X = 0, - Y = 0, - Z = 0, - W = 1 + Position = new Position + { + X = 1, + Y = 2, + Z = 3 + }, + Orientation = new Orientation + { + X = 0, + Y = 0, + Z = 0, + W = 1 + } } }; var content = new StringContent( @@ -313,8 +316,8 @@ public async Task UpdateDefaultLocalizationPoseOnDeck() var putDeck = await putResponse.Content.ReadFromJsonAsync(_serializerOptions); Assert.True(putDeck != null); Assert.True(putDeck.DefaultLocalizationPose != null); - Assert.True(putDeck.DefaultLocalizationPose.Position.Z.Equals(query.Position.Z)); - Assert.True(putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Orientation.W)); + Assert.True(putDeck.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z)); + Assert.True(putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W)); } } } diff --git a/backend/api.test/Client/MissionTests.cs b/backend/api.test/Client/MissionTests.cs index 07ae0f99b..c509a4211 100644 --- a/backend/api.test/Client/MissionTests.cs +++ b/backend/api.test/Client/MissionTests.cs @@ -165,7 +165,11 @@ private static (StringContent installationContent, StringContent plantContent, S InstallationCode = installationCode, PlantCode = plantCode, Name = deckName, - DefaultLocalizationPose = testPose + DefaultLocalizationPose = new CreateDefaultLocalizationPose() + { + Pose = testPose, + IsDockingStation = false + } }; var areaQuery = new CreateAreaQuery diff --git a/backend/api.test/Database/DatabaseUtilities.cs b/backend/api.test/Database/DatabaseUtilities.cs index a410d4f6c..8a84dc220 100644 --- a/backend/api.test/Database/DatabaseUtilities.cs +++ b/backend/api.test/Database/DatabaseUtilities.cs @@ -110,7 +110,10 @@ public async Task NewDeck(string installationCode, string plantCode, strin InstallationCode = installationCode, PlantCode = plantCode, Name = deckName, - DefaultLocalizationPose = new Pose() + DefaultLocalizationPose = new CreateDefaultLocalizationPose() + { + Pose = new Pose() + } }; return await _deckService.Create(createDeckQuery); diff --git a/backend/api/Controllers/DeckController.cs b/backend/api/Controllers/DeckController.cs index 2656b16c0..2fa11cecc 100644 --- a/backend/api/Controllers/DeckController.cs +++ b/backend/api/Controllers/DeckController.cs @@ -199,7 +199,7 @@ public async Task> Create([FromBody] CreateDeckQuery [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> UpdateDefaultLocalizationPose([FromRoute] string deckId, [FromBody] Pose newDefaultLocalizationPose) + public async Task> UpdateDefaultLocalizationPose([FromRoute] string deckId, [FromBody] CreateDefaultLocalizationPose newDefaultLocalizationPose) { logger.LogInformation("Updating default localization pose on deck '{deckId}'", deckId); try @@ -213,16 +213,16 @@ public async Task> UpdateDefaultLocalizationPose([Fro if (deck.DefaultLocalizationPose != null) { - deck.DefaultLocalizationPose.Pose = newDefaultLocalizationPose; + deck.DefaultLocalizationPose.Pose = newDefaultLocalizationPose.Pose; + deck.DefaultLocalizationPose.DockingEnabled = newDefaultLocalizationPose.IsDockingStation; _ = await defaultLocalizationPoseService.Update(deck.DefaultLocalizationPose); } else { - deck.DefaultLocalizationPose = new DefaultLocalizationPose(newDefaultLocalizationPose); + deck.DefaultLocalizationPose = new DefaultLocalizationPose(newDefaultLocalizationPose.Pose, newDefaultLocalizationPose.IsDockingStation); deck = await deckService.Update(deck); } - return Ok(new DeckResponse(deck)); } catch (Exception e) diff --git a/backend/api/Controllers/Models/CreateDeckQuery.cs b/backend/api/Controllers/Models/CreateDeckQuery.cs index 3cb3093b2..1b3d67dff 100644 --- a/backend/api/Controllers/Models/CreateDeckQuery.cs +++ b/backend/api/Controllers/Models/CreateDeckQuery.cs @@ -1,6 +1,4 @@ -using Api.Database.Models; - -namespace Api.Controllers.Models +namespace Api.Controllers.Models { public struct CreateDeckQuery { @@ -8,6 +6,6 @@ public struct CreateDeckQuery public string PlantCode { get; set; } public string Name { get; set; } - public Pose? DefaultLocalizationPose { get; set; } + public CreateDefaultLocalizationPose? DefaultLocalizationPose { get; set; } } } diff --git a/backend/api/Controllers/Models/CreateDefaultLocalizationPose.cs b/backend/api/Controllers/Models/CreateDefaultLocalizationPose.cs new file mode 100644 index 000000000..090a24bb3 --- /dev/null +++ b/backend/api/Controllers/Models/CreateDefaultLocalizationPose.cs @@ -0,0 +1,15 @@ +using Api.Database.Models; + +namespace Api.Controllers.Models +{ + public struct CreateDefaultLocalizationPose + { + public CreateDefaultLocalizationPose() + { + Pose = new Pose(); + } + + public Pose Pose { get; set; } + public bool IsDockingStation { get; set; } = false; + } +} diff --git a/backend/api/Database/Models/DefaultLocalizationPose.cs b/backend/api/Database/Models/DefaultLocalizationPose.cs index ea2f81cd5..22d401b05 100644 --- a/backend/api/Database/Models/DefaultLocalizationPose.cs +++ b/backend/api/Database/Models/DefaultLocalizationPose.cs @@ -13,6 +13,9 @@ public class DefaultLocalizationPose [Required] public Pose Pose { get; set; } + [Required] + public bool DockingEnabled { get; set; } = false; + public DefaultLocalizationPose() { Pose = new Pose(); @@ -22,5 +25,11 @@ public DefaultLocalizationPose(Pose pose) { Pose = pose; } + + public DefaultLocalizationPose(Pose pose, bool dockingEnabled) + { + Pose = pose; + DockingEnabled = dockingEnabled; + } } } diff --git a/backend/api/Services/DeckService.cs b/backend/api/Services/DeckService.cs index 184642607..84d32fac9 100644 --- a/backend/api/Services/DeckService.cs +++ b/backend/api/Services/DeckService.cs @@ -96,7 +96,7 @@ public async Task Create(CreateDeckQuery newDeckQuery) DefaultLocalizationPose? defaultLocalizationPose = null; if (newDeckQuery.DefaultLocalizationPose != null) { - defaultLocalizationPose = await defaultLocalizationPoseService.Create(new DefaultLocalizationPose(newDeckQuery.DefaultLocalizationPose)); + defaultLocalizationPose = await defaultLocalizationPoseService.Create(new DefaultLocalizationPose(newDeckQuery.DefaultLocalizationPose.Value.Pose, newDeckQuery.DefaultLocalizationPose.Value.IsDockingStation)); } var deck = new Deck diff --git a/backend/api/Services/Models/IsarMissionDefinition.cs b/backend/api/Services/Models/IsarMissionDefinition.cs index 5f8653191..2bce74876 100644 --- a/backend/api/Services/Models/IsarMissionDefinition.cs +++ b/backend/api/Services/Models/IsarMissionDefinition.cs @@ -20,6 +20,12 @@ public struct IsarMissionDefinition [JsonPropertyName("start_pose")] public IsarPose? StartPose { get; set; } = null; + [JsonPropertyName("dock")] + public bool? Dock { get; set; } = null; + + [JsonPropertyName("undock")] + public bool? Undock { get; set; } = null; + public IsarMissionDefinition(List tasks) { Id = null; @@ -33,6 +39,8 @@ public IsarMissionDefinition(MissionRun missionRun, bool includeStartPose = fals Name = missionRun.Name; Tasks = missionRun.Tasks.Select(task => new IsarTaskDefinition(task, missionRun)).ToList(); StartPose = includeStartPose && missionRun.Area.Deck.DefaultLocalizationPose != null ? new IsarPose(missionRun.Area.Deck.DefaultLocalizationPose.Pose) : null; + Undock = includeStartPose && missionRun.Area.Deck.DefaultLocalizationPose != null && missionRun.Area.Deck.DefaultLocalizationPose.DockingEnabled; + Dock = missionRun.Area.Deck.DefaultLocalizationPose != null && missionRun.Area.Deck.DefaultLocalizationPose.DockingEnabled && missionRun.IsReturnHomeMission(); } }