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

Remove isar steps in flotilla #1753

Merged
merged 6 commits into from
Oct 17, 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
13 changes: 5 additions & 8 deletions backend/api.test/Client/AreaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,17 @@ public async Task MissionIsCreatedInArea()

string testMissionName = "testMissionInAreaTest";

var inspections = new List<CustomInspectionQuery>
var inspection = new CustomInspectionQuery
{
new()
{
AnalysisType = AnalysisType.CarSeal,
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
}
AnalysisType = AnalysisType.CarSeal,
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
};
var tasks = new List<CustomTaskQuery>
{
new()
{
Inspections = inspections,
Inspection = inspection,
TagId = "test",
RobotPose = new Pose(),
TaskOrder = 0
Expand Down
52 changes: 40 additions & 12 deletions backend/api.test/Client/MissionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
Port = 3000,
CurrentInstallationCode = installationCode,
CurrentAreaName = null,
RobotCapabilities = [],
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
Documentation = new List<CreateDocumentationQuery>(),
RobotCapabilities = [RobotCapabilitiesEnum.take_image]
};

string robotUrl = "/robots";
Expand All @@ -493,13 +493,21 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
new()
{
RobotPose = new Pose(new Position(23, 14, 4), new Orientation()),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 0
},
new()
{
RobotPose = new Pose(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 1
}
]
Expand Down Expand Up @@ -555,7 +563,7 @@ public async Task GetNextRun()
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = areaName,
RobotCapabilities = [],
RobotCapabilities = [RobotCapabilitiesEnum.take_image],
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};
Expand All @@ -578,7 +586,11 @@ public async Task GetNextRun()
new()
{
RobotPose = new Pose(),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 0
}
]
Expand Down Expand Up @@ -738,7 +750,7 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
Port = 3000,
CurrentInstallationCode = otherInstallation.InstallationCode,
CurrentAreaName = null,
RobotCapabilities = [],
RobotCapabilities = [RobotCapabilitiesEnum.take_image],
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};
Expand All @@ -760,13 +772,21 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
new()
{
RobotPose = new Pose(),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 0
},
new()
{
RobotPose = new Pose(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 1
}
]
Expand Down Expand Up @@ -810,7 +830,7 @@ public async Task MissionFailsIfRobotIsNotInSameDeckAsMission()
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
CurrentAreaName = area1.AreaName,
RobotCapabilities = [],
RobotCapabilities = [RobotCapabilitiesEnum.take_image],
VideoStreams = new List<CreateVideoStreamQuery>(),
Documentation = new List<CreateDocumentationQuery>()
};
Expand All @@ -832,13 +852,21 @@ public async Task MissionFailsIfRobotIsNotInSameDeckAsMission()
new()
{
RobotPose = new Pose(new Position(1, 9, 4), new Orientation()),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 0
},
new()
{
RobotPose = new Pose(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f),
Inspections = [],
Inspection = new CustomInspectionQuery
{
InspectionTarget = new Position(),
InspectionType = InspectionType.Image
},
TaskOrder = 1
}
]
Expand Down
2 changes: 1 addition & 1 deletion backend/api.test/Database/DatabaseUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task<Robot> NewRobot(RobotStatus status, Installation installation,
Host = "localhost",
Port = 3000,
Status = status,
RobotCapabilities = [RobotCapabilitiesEnum.drive_to_pose, RobotCapabilitiesEnum.take_image, RobotCapabilitiesEnum.return_to_home, RobotCapabilitiesEnum.localize]
RobotCapabilities = [RobotCapabilitiesEnum.take_image, RobotCapabilitiesEnum.return_to_home, RobotCapabilitiesEnum.localize]
};

var robotModel = await _robotModelService.ReadByRobotType(createRobotQuery.RobotType, readOnly: true);
Expand Down
4 changes: 2 additions & 2 deletions backend/api.test/Mocks/MissionLoaderMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MockMissionLoader() : IMissionLoader

private readonly List<MissionTask> _mockMissionTasks = [
new MissionTask(
inspections: [],
inspection: new Inspection(),
taskOrder: 0,
tagId: "1",
tagLink: new Uri("https://testurl.com"),
Expand All @@ -37,7 +37,7 @@ public class MockMissionLoader() : IMissionLoader
}
),
new MissionTask(
inspections: [],
inspection: new Inspection(),
taskOrder: 0,
tagId: "2",
tagLink: new Uri("https://testurl.com"),
Expand Down
18 changes: 9 additions & 9 deletions backend/api/Controllers/InspectionFindingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ IInspectionService inspectionService
) : ControllerBase
{
/// <summary>
/// Associate a new inspection finding with the inspection corresponding to isarStepId
/// Associate a new inspection finding with the inspection corresponding to isarTaskId
/// </summary>
/// <remarks>
/// </remarks>
[HttpPost]
[Authorize(Roles = Role.Admin)]
[Route("{isarStepId}")]
[Route("{isarTaskId}")]
[ProducesResponseType(typeof(InspectionFinding), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<InspectionFinding>> AddFinding([FromBody] InspectionFindingQuery inspectionFinding, [FromRoute] string isarStepId)
public async Task<ActionResult<InspectionFinding>> AddFinding([FromBody] InspectionFindingQuery inspectionFinding, [FromRoute] string isarTaskId)
{
logger.LogInformation("Add inspection finding for inspection with isarStepId '{Id}'", isarStepId);
logger.LogInformation("Add inspection finding for inspection with isarTaskId '{Id}'", isarTaskId);
try
{
var inspection = await inspectionService.AddFinding(inspectionFinding, isarStepId);
var inspection = await inspectionService.AddFinding(inspectionFinding, isarTaskId);

if (inspection != null)
{
Expand All @@ -42,14 +42,14 @@ public async Task<ActionResult<InspectionFinding>> AddFinding([FromBody] Inspect
}
catch (Exception e)
{
logger.LogError(e, "Error while adding inspection finding to inspection with IsarStepId '{Id}'", isarStepId);
logger.LogError(e, "Error while adding inspection finding to inspection with IsarTaskId '{Id}'", isarTaskId);
return StatusCode(StatusCodes.Status500InternalServerError);
}
return NotFound($"Could not find any inspection with the provided '{isarStepId}'");
return NotFound($"Could not find any inspection with the provided '{isarTaskId}'");
}

/// <summary>
/// Get the full inspection against an isarStepId
/// Get the full inspection against an isarTaskId
/// </summary>
/// <remarks>
/// </remarks>
Expand All @@ -67,7 +67,7 @@ public async Task<ActionResult<Inspection>> GetInspections([FromRoute] string id
logger.LogInformation("Get inspection by ID '{id}'", id);
try
{
var inspection = await inspectionService.ReadByIsarStepId(id, readOnly: true);
var inspection = await inspectionService.ReadByIsarTaskId(id, readOnly: true);
if (inspection != null)
{
return Ok(inspection);
Expand Down
5 changes: 1 addition & 4 deletions backend/api/Controllers/MissionSchedulingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ [FromBody] ScheduleMissionQuery scheduledMissionQuery
foreach (var task in missionTasks)
{
task.Id = Guid.NewGuid().ToString();
foreach (var inspection in task.Inspections)
{
inspection.Id = Guid.NewGuid().ToString();
}
if (task.Inspection != null) task.Inspection.Id = Guid.NewGuid().ToString();
}

var newMissionRun = new MissionRun
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Controllers/Models/CustomMissionQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct CustomTaskQuery

public Pose RobotPose { get; set; }

public List<CustomInspectionQuery> Inspections { get; set; }
public CustomInspectionQuery? Inspection { get; set; }
}

public struct CustomMissionQuery
Expand Down
18 changes: 8 additions & 10 deletions backend/api/Database/Context/InitDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,11 @@ private static List<MissionDefinition> GetMissionDefinitions()

private static List<MissionTask> GetMissionTasks()
{
var inspections = new List<Inspection> { new() };
var url = new Uri(
"https://stid.equinor.com/hua/tag?tagNo=ABCD"
);
var task1 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand All @@ -431,7 +430,7 @@ private static List<MissionTask> GetMissionTasks()
);

var task2 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand All @@ -441,7 +440,7 @@ private static List<MissionTask> GetMissionTasks()
);

var task3 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand All @@ -451,7 +450,7 @@ private static List<MissionTask> GetMissionTasks()
);

var task4 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand All @@ -461,7 +460,7 @@ private static List<MissionTask> GetMissionTasks()
);

var task5 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand All @@ -471,7 +470,7 @@ private static List<MissionTask> GetMissionTasks()
);

var task6 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand All @@ -481,7 +480,7 @@ private static List<MissionTask> GetMissionTasks()
);

var task7 = new MissionTask(
inspections: inspections,
inspection: new Inspection(),
robotPose: new Pose(300.0f, 50.0f, 200.0f, 0.0f, 0.0f, 0.0f, 1.0f),
taskOrder: 0,
tagLink: url,
Expand Down Expand Up @@ -668,8 +667,7 @@ public static void PopulateDb(FlotillaDbContext context)
var tasks = GetMissionTasks();
foreach (var task in tasks)
{
task.Inspections.Add(inspections[0]);
task.Inspections.Add(inspections[1]);
task.Inspection = inspections[0];
}
context.AddRange(tasks);
context.AddRange(missionDefinitions);
Expand Down
Loading
Loading