Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Localization bug #1418

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/api/Database/Models/MissionRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public enum MissionRunPriority
{
Normal,
Response,
Emergency
Emergency,
Localization
}
}
10 changes: 7 additions & 3 deletions backend/api/EventHandlers/MissionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,13 @@ private async void OnRobotAvailable(object? sender, RobotAvailableEventArgs e)
return;
}

MissionRun? missionRun;
if (robot.MissionQueueFrozen) { missionRun = await MissionService.ReadNextScheduledEmergencyMissionRun(robot.Id); }
else { missionRun = await MissionService.ReadNextScheduledMissionRun(robot.Id); }
var missionRun = await MissionService.ReadNextScheduledLocalizationMissionRun(robot.Id);

if (missionRun == null)
{
if (robot.MissionQueueFrozen) { missionRun = await MissionService.ReadNextScheduledEmergencyMissionRun(robot.Id); }
else { missionRun = await MissionService.ReadNextScheduledMissionRun(robot.Id); }
}

if (missionRun == null)
{
Expand Down
1 change: 1 addition & 0 deletions backend/api/Services/LocalizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private async Task<MissionRun> CreateLocalizationMissionInArea(string robotId, s
{
Name = "Localization mission",
Robot = robot,
MissionRunPriority = MissionRunPriority.Localization,
InstallationCode = area.Installation.InstallationCode,
Area = area,
Status = MissionStatus.Pending,
Expand Down
11 changes: 11 additions & 0 deletions backend/api/Services/MissionRunService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public interface IMissionRunService

public Task<MissionRun?> ReadNextScheduledEmergencyMissionRun(string robotId);

public Task<MissionRun?> ReadNextScheduledLocalizationMissionRun(string robotId);

public Task<MissionRun?> ReadLastExecutedMissionRunByRobot(string robotId);

public Task<MissionRun> Update(MissionRun mission);
Expand Down Expand Up @@ -127,6 +129,15 @@ public async Task<IList<MissionRun>> ReadMissionRunQueue(string robotId)
missionRun.Robot.Id == robotId && missionRun.MissionRunPriority == MissionRunPriority.Emergency && missionRun.Status == MissionStatus.Pending);
}

public async Task<MissionRun?> ReadNextScheduledLocalizationMissionRun(string robotId)
{
var nextScheduledMissionRun = await GetMissionRunsWithSubModels()
.OrderBy(missionRun => missionRun.DesiredStartTime)
.FirstOrDefaultAsync(missionRun => missionRun.Robot.Id == robotId && missionRun.Status == MissionStatus.Pending && missionRun.MissionRunPriority == MissionRunPriority.Localization);

return nextScheduledMissionRun;
}

public async Task<MissionRun?> ReadNextScheduledRunByMissionId(string missionId)
{
var test = GetMissionRunsWithSubModels().OrderBy(m => m.DesiredStartTime).ToList();
Expand Down
Loading