Skip to content

Commit

Permalink
Add configurability for return to home missions
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonsf committed Apr 22, 2024
1 parent 9d167d1 commit afc4033
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions backend/api/Database/Models/MissionTask.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
using Api.Controllers.Models;
using Api.Services.Models;
using Api.Utilities;
Expand Down Expand Up @@ -175,8 +174,14 @@ public void UpdateStatus(IsarTaskStatus isarStatus)

public static string ConvertMissionTaskTypeToIsarTaskType(MissionTaskType missionTaskType)
{
if (missionTaskType == MissionTaskType.ReturnHome) { return "drive_to"; }
else { return missionTaskType.ToString().ToLower(CultureInfo.CurrentCulture); }
return missionTaskType switch
{
MissionTaskType.ReturnHome => "return_to_home",
MissionTaskType.Localization => "localization",
MissionTaskType.Inspection => "inspection",
_ => throw new ArgumentException($"ISAR Mission task type '{missionTaskType}' not supported"),
};
;
}
}

Expand Down
4 changes: 2 additions & 2 deletions backend/api/EventHandlers/MqttEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ private async void OnIsarStepUpdate(object? sender, MqttReceivedArgs mqttArgs)

var step = (IsarStepMessage)mqttArgs.Message;

// Flotilla does not care about DriveTo, Localization or MoveArm steps
// Flotilla does not care about DriveTo, Localization, MoveArm or ReturnToHome steps
var stepType = IsarStep.StepTypeFromString(step.StepType);
if (stepType is IsarStepType.DriveToPose or IsarStepType.Localize or IsarStepType.MoveArm) return;
if (stepType is IsarStepType.DriveToPose or IsarStepType.Localize or IsarStepType.MoveArm or IsarStepType.ReturnToHome) return;

IsarStepStatus status;
try { status = IsarStep.StatusFromString(step.Status); }
Expand Down
2 changes: 2 additions & 0 deletions backend/api/Services/Models/IsarStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static IsarStepType StepTypeFromString(string isarClassName)
"TakeThermalImage" => IsarStepType.TakeThermalImage,
"TakeThermalVideo" => IsarStepType.TakeThermalVideo,
"Localize" => IsarStepType.Localize,
"ReturnToHome" => IsarStepType.ReturnToHome,
"MoveArm" => IsarStepType.MoveArm,
_
=> throw new ArgumentException(
Expand All @@ -58,6 +59,7 @@ public enum IsarStepType
{
DriveToPose,
Localize,
ReturnToHome,
TakeImage,
TakeVideo,
TakeThermalImage,
Expand Down

0 comments on commit afc4033

Please sign in to comment.