Skip to content

Commit

Permalink
Change to robot.Id
Browse files Browse the repository at this point in the history
  • Loading branch information
oysand committed Mar 4, 2024
1 parent 9e44fc9 commit 083456a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions backend/api/Services/MissionSchedulingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,33 @@ public async Task StartNextMissionRunIfSystemIsAvailable(string robotId)
if (missionRun == null) { return; } // The robot is already home
}

if (!await TheSystemIsAvailableToRunAMission(robotId, missionRun.Id))
if (!await TheSystemIsAvailableToRunAMission(robot.Id, missionRun.Id))
{
logger.LogInformation("Mission {MissionRunId} was put on the queue as the system may not start a mission now", missionRun.Id);
return;
}


// Verify that localization is fine
if (!await localizationService.RobotIsLocalized(robotId) && !missionRun.IsLocalizationMission())
if (!await localizationService.RobotIsLocalized(robot.Id) && !missionRun.IsLocalizationMission())
{
logger.LogError("Tried to schedule mission {MissionRunId} on robot {RobotId} before the robot was localized, scheduled missions will be canceled", missionRun.Id, missionRun.Robot.Id);
logger.LogError("Tried to schedule mission {MissionRunId} on robot {RobotId} before the robot was localized, scheduled missions will be canceled", missionRun.Id, robot.Id);
try { await CancelAllScheduledMissions(robot.Id); }
catch (RobotNotFoundException) { logger.LogError("Failed to cancel scheduled missions for robot {RobotId}", robot.Id); }
return;
}

if (!missionRun.IsLocalizationMission() && !await localizationService.RobotIsOnSameDeckAsMission(robot.Id, missionRun.Area.Id))
{
logger.LogError("Robot {RobotId} is not on the same deck as the mission run {MissionRunId}. Cancelling all mission runs", missionRun.Robot.Id, missionRun.Id);
try { await CancelAllScheduledMissions(missionRun.Robot.Id); }
catch (RobotNotFoundException) { logger.LogError("Failed to cancel scheduled missions for robot {RobotId}", missionRun.Robot.Id); }
logger.LogError("Robot {RobotId} is not on the same deck as the mission run {MissionRunId}. Cancelling all mission runs", robot.Id, missionRun.Id);
try { await CancelAllScheduledMissions(robot.Id); }
catch (RobotNotFoundException) { logger.LogError("Failed to cancel scheduled missions for robot {RobotId}", robot.Id); }

try { await returnToHomeService.ScheduleReturnToHomeMissionRunIfNotAlreadyScheduledOrRobotIsHome(missionRun.Robot.Id); }
try { await returnToHomeService.ScheduleReturnToHomeMissionRunIfNotAlreadyScheduledOrRobotIsHome(robot.Id); }
catch (ReturnToHomeMissionFailedToScheduleException)
{
logger.LogError("Failed to schedule a return to home mission for robot {RobotId}", missionRun.Robot.Id);
await robotService.UpdateCurrentArea(missionRun.Robot.Id, null);
logger.LogError("Failed to schedule a return to home mission for robot {RobotId}", robot.Id);
await robotService.UpdateCurrentArea(robot.Id, null);
}
return;
}
Expand Down

0 comments on commit 083456a

Please sign in to comment.