Skip to content

Added close ups in wheel analysis task #917

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion documentation/src/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,18 @@ export const CreatePricingTaskOptionsSchema = z.object({
methodology: z.string().optional(),
});

export const CreateWheelAnalysisTaskOptionsSchema = z.object({
name: z.literal(TaskName.WHEEL_ANALYSIS),
useLongShots: z.boolean(),
callbacks: z.array(TaskCallbackOptionsSchema).optional(),
});

export const InspectionCreateTaskSchema = z
.nativeEnum(TaskName)
.or(CreateDamageDetectionTaskOptionsSchema)
.or(CreateHinlTaskOptionsSchema)
.or(CreatePricingTaskOptionsSchema);
.or(CreatePricingTaskOptionsSchema)
.or(CreateWheelAnalysisTaskOptionsSchema);

export const AdditionalDataSchema = z.record(z.string(), z.unknown());

Expand Down
9 changes: 8 additions & 1 deletion documentation/src/utils/schemas/createInspection.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ export const CreatePricingTaskOptionsSchema = z.object({
methodology: z.string().optional(),
});

export const CreateWheelAnalysisTaskOptionsSchema = z.object({
name: z.literal(TaskName.WHEEL_ANALYSIS),
useLongShots: z.boolean(),
callbacks: z.array(TaskCallbackOptionsSchema).optional(),
});

export const InspectionCreateTaskSchema = z
.nativeEnum(TaskName)
.or(CreateDamageDetectionTaskOptionsSchema)
.or(CreateHinlTaskOptionsSchema)
.or(CreatePricingTaskOptionsSchema);
.or(CreatePricingTaskOptionsSchema)
.or(CreateWheelAnalysisTaskOptionsSchema);

export const AdditionalDataSchema = z.record(z.string(), z.unknown());

Expand Down
10 changes: 9 additions & 1 deletion packages/inspection-capture-web/src/hooks/useUploadQueue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Queue, uniq, useQueue } from '@monkvision/common';
import { Queue, uniq, useMonkState, useQueue } from '@monkvision/common';
import { AddImageOptions, ImageUploadType, MonkApiConfig, useMonkApi } from '@monkvision/network';
import {
PhotoCaptureAppConfig,
Expand Down Expand Up @@ -133,6 +133,7 @@ function createAddImageOptions(
enableThumbnail: boolean,
additionalTasks?: PhotoCaptureAppConfig['additionalTasks'],
compliance?: ComplianceOptions,
wheelAnalysisCloseUp?: boolean,
): AddImageOptions {
if (upload.mode === CaptureMode.SIGHT) {
return {
Expand All @@ -143,6 +144,7 @@ function createAddImageOptions(
inspectionId,
compliance,
useThumbnailCaching: enableThumbnail,
wheelAnalysisCloseUp,
};
}
if (upload.mode === CaptureMode.ADD_DAMAGE_PART_SELECT_SHOT) {
Expand Down Expand Up @@ -179,6 +181,11 @@ export function useUploadQueue({
const { handleError } = useMonitoring();
const siblingIdRef = useRef(0);
const { addImage } = useMonkApi(apiConfig);
const { state } = useMonkState();

const wheelAnalysisCloseUp = state.tasks.find(
(task) => task.name === TaskName.WHEEL_ANALYSIS && task.wheelAnalysisCloseUp,
)?.wheelAnalysisCloseUp;

return useQueue<PictureUpload>(async (upload: PictureUpload) => {
if (upload.mode === CaptureMode.ADD_DAMAGE_1ST_SHOT) {
Expand All @@ -194,6 +201,7 @@ export function useUploadQueue({
true,
additionalTasks,
complianceOptions,
wheelAnalysisCloseUp,
),
);
const uploadDurationMs = Date.now() - startTs;
Expand Down
22 changes: 22 additions & 0 deletions packages/network/src/api/image/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ export interface AddBeautyShotImageOptions {
* Additional options used to configure the compliance locally.
*/
compliance?: ComplianceOptions;

wheelAnalysisCloseUp?: boolean;
}

/**
Expand Down Expand Up @@ -291,6 +293,7 @@ function createBeautyShotImageData(
TaskName.IMAGES_OCR,
TaskName.ODOMETER,
TaskName.WARNING_LIGHTS,
TaskName.WHEEL_ANALYSIS,
].includes(task),
) as ApiImagePostTask[];
tasks.push({
Expand Down Expand Up @@ -323,6 +326,25 @@ function createBeautyShotImageData(
wait_for_result: true,
});
}
if (options.tasks.includes(TaskName.WHEEL_ANALYSIS)) {
const sightName = sights[options.sightId].wheelName;
if (options.wheelAnalysisCloseUp && !sightName) {
throw new Error('Wheel analysis task close-up requires a sight name.');
}
if (!options.wheelAnalysisCloseUp && sightName) {
throw new Error(
"Wheel analysis task long shoot can't be run on sight that contains sightName.",
);
}
if (options.wheelAnalysisCloseUp && sightName) {
tasks.push({
name: TaskName.WHEEL_ANALYSIS,
image_details: { wheel_name: sightName },
});
} else {
tasks.push(TaskName.WHEEL_ANALYSIS);
}
}

const body: ApiImagePost = {
acquisition: {
Expand Down
20 changes: 18 additions & 2 deletions packages/network/src/api/inspection/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CreateHinlTaskOptions,
CreateInspectionOptions,
CreatePricingTaskOptions,
CreateWheelAnalysisTaskOptions,
CurrencyCode,
CustomSeverityValue,
Damage,
Expand Down Expand Up @@ -326,6 +327,11 @@ function mapTasks(response: ApiInspectionGet): { tasks: Task[]; taskIds: string[
name: task.name as TaskName,
status: task.status as ProgressStatus,
images: task.images?.map((image) => image.image_id) ?? [],
...(task.arguments?.['use_longshots'] !== undefined
? {
wheelAnalysisCloseUp: !task.arguments['use_longshots'] as boolean,
}
: {}),
});
});

Expand Down Expand Up @@ -563,10 +569,20 @@ function getDamageDetectionOptions(
function getWheelAnalysisOptions(
options: CreateInspectionOptions,
): ApiWheelAnalysisTaskPostComponent | undefined {
return options.tasks.includes(TaskName.WHEEL_ANALYSIS)
if (options.tasks.includes(TaskName.WHEEL_ANALYSIS)) {
return {
status: ProgressStatus.NOT_STARTED,
use_longshots: true,
};
}
const taskOptions = options.tasks.find(
(task) => typeof task === 'object' && task.name === TaskName.WHEEL_ANALYSIS,
) as CreateWheelAnalysisTaskOptions | undefined;
return taskOptions
? {
status: ProgressStatus.NOT_STARTED,
use_longshots: true,
use_longshots: taskOptions.useLongShots,
callbacks: taskOptions.callbacks,
}
: undefined;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/network/src/api/models/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ApiImagesOCRTaskPost,
ApiImagesOdometerTaskPost,
ApiImagesWarningLightsTaskPost,
ApiImagesWheelAnalysisTaskPost,
} from './task';

export type ApiImageType = 'unknown' | 'beauty_shot' | 'close_up';
Expand Down Expand Up @@ -111,7 +112,8 @@ export type ApiImagePostTask =
| ApiHinlTaskPost
| ApiImagesOCRTaskPost
| ApiImagesOdometerTaskPost
| ApiImagesWarningLightsTaskPost;
| ApiImagesWarningLightsTaskPost
| ApiImagesWheelAnalysisTaskPost;

export interface ApiImagePost {
acquisition: ApiAcquisition;
Expand Down
11 changes: 11 additions & 0 deletions packages/network/src/api/models/task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiPricingMethodology } from './pricingV2';
import { ApiWheelType } from './wheelAnalysis';

export interface ApiImageInTask {
image_id: string;
Expand Down Expand Up @@ -57,6 +58,15 @@ export interface ApiImagesWarningLightsTaskPost {
wait_for_result?: boolean;
}

export interface ApiWheelAnalysisImageDetails {
wheel_name: ApiWheelType;
}

export interface ApiImagesWheelAnalysisTaskPost {
name: 'wheel_analysis';
image_details: ApiWheelAnalysisImageDetails;
}

export type ApiTaskProgressStatus =
| 'NOT_STARTED'
| 'TODO'
Expand All @@ -71,6 +81,7 @@ export interface ApiTaskGet {
images: ApiImageInTask[];
name: ApiBusinessTaskName;
status: ApiTaskProgressStatus;
arguments?: Record<string, unknown>;
}

export type ApiTasks = ApiTaskGet[];
Expand Down
2 changes: 2 additions & 0 deletions packages/network/test/api/image/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ describe('Image requests', () => {
TaskName.IMAGES_OCR,
TaskName.ODOMETER,
TaskName.WARNING_LIGHTS,
TaskName.WHEEL_ANALYSIS,
].includes(task),
),
{
Expand All @@ -328,6 +329,7 @@ describe('Image requests', () => {
name: TaskName.WARNING_LIGHTS,
wait_for_result: true,
},
TaskName.WHEEL_ANALYSIS,
],
additional_data: {
sight_id: options.sightId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ export default {
name: 'wheel_analysis',
status: 'DONE',
images: ['6a5e9a4c-8752-c1e6-6a34-38338074eda1'],
wheelAnalysisCloseUp: false,
},
],
vehicles: [
Expand Down
4 changes: 4 additions & 0 deletions packages/sights/research/data/fesc20/fesc20.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"vehicle": "fesc20",
"mirror_sight": "fesc20-raHPDUNm",
"dev": true,
"wheel_name": "wheel_back_left",
"tasks": ["wheel_analysis"]
},
"fesc20-5Ts1UkPT": {
Expand All @@ -96,6 +97,7 @@
"vehicle": "fesc20",
"mirror_sight": "fesc20-Tlu3sz8A",
"dev": true,
"wheel_name": "wheel_back_right",
"tasks": ["wheel_analysis"]
},
"fesc20-6GPUkfYn": {
Expand Down Expand Up @@ -335,6 +337,7 @@
"vehicle": "fesc20",
"mirror_sight": "fesc20-W6XrryMO",
"dev": true,
"wheel_name": "wheel_front_left",
"tasks": ["wheel_analysis"]
},
"fesc20-WMUaKDp1": {
Expand Down Expand Up @@ -419,6 +422,7 @@
"vehicle": "fesc20",
"mirror_sight": "fesc20-YPcJPAZE",
"dev": true,
"wheel_name": "wheel_front_right",
"tasks": ["wheel_analysis"]
},
"fesc20-dfICsfSV": {
Expand Down
4 changes: 4 additions & 0 deletions packages/sights/research/data/ff150/ff150.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"vehicle": "ff150",
"mirror_sight": "ff150-7vyfzrVQ",
"dev": true,
"wheel_name": "wheel_back_right",
"tasks": ["wheel_analysis"]
},
"ff150-7UI3m9B3": {
Expand Down Expand Up @@ -155,6 +156,7 @@
"vehicle": "ff150",
"mirror_sight": "ff150-pNO26q4D",
"dev": true,
"wheel_name": "wheel_front_right",
"tasks": ["wheel_analysis"]
},
"ff150-BmXfb-qD": {
Expand Down Expand Up @@ -197,6 +199,7 @@
"vehicle": "ff150",
"mirror_sight": "ff150-jUBEKij0",
"dev": true,
"wheel_name": "wheel_front_left",
"tasks": ["wheel_analysis"]
},
"ff150-GOx2s_9L": {
Expand Down Expand Up @@ -419,6 +422,7 @@
"vehicle": "ff150",
"mirror_sight": "ff150-H3MCPESJ",
"dev": true,
"wheel_name": "wheel_back_right",
"tasks": ["wheel_analysis"]
},
"ff150-phbX7Bef": {
Expand Down
4 changes: 4 additions & 0 deletions packages/sights/research/data/ffocus18/ffocus18.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"vehicle": "ffocus18",
"mirror_sight": "ffocus18-Eo0jqD_a",
"dev": true,
"wheel_name": "wheel_front_right",
"tasks": ["wheel_analysis"]
},
"ffocus18-L2UM_68Q": {
Expand Down Expand Up @@ -230,6 +231,7 @@
"vehicle": "ffocus18",
"mirror_sight": "ffocus18-JFX8WF9P",
"dev": true,
"wheel_name": "wheel_back_right",
"tasks": ["wheel_analysis"]
},
"ffocus18-QKfhXU7o": {
Expand Down Expand Up @@ -272,6 +274,7 @@
"vehicle": "ffocus18",
"mirror_sight": "ffocus18-tufa4FoL",
"dev": true,
"wheel_name": "wheel_back_left",
"tasks": ["wheel_analysis"]
},
"ffocus18-U3Bcfc2Q": {
Expand Down Expand Up @@ -543,6 +546,7 @@
"vehicle": "ffocus18",
"mirror_sight": "ffocus18-jkSlWpql",
"dev": true,
"wheel_name": "wheel_front_left",
"tasks": ["wheel_analysis"]
},
"ffocus18-yo9eBDW6": {
Expand Down
4 changes: 4 additions & 0 deletions packages/sights/research/data/ftransit18/ftransit18.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"vehicle": "ftransit18",
"mirror_sight": "ftransit18-AuCXxG5o",
"dev": true,
"wheel_name": "wheel_back_left",
"tasks": ["wheel_analysis"]
},
"ftransit18-3dkU10af": {
Expand Down Expand Up @@ -96,6 +97,7 @@
"vehicle": "ftransit18",
"mirror_sight": "ftransit18-mGSvkRHz",
"dev": true,
"wheel_name": "wheel_front_right",
"tasks": ["wheel_analysis"]
},
"ftransit18-5SiNC94w": {
Expand Down Expand Up @@ -243,6 +245,7 @@
"vehicle": "ftransit18",
"mirror_sight": "ftransit18-yxw9gmyL",
"dev": true,
"wheel_name": "wheel_back_right",
"tasks": ["wheel_analysis"]
},
"ftransit18-TkXihCj4": {
Expand Down Expand Up @@ -299,6 +302,7 @@
"vehicle": "ftransit18",
"mirror_sight": "ftransit18-7qLSCnFP",
"dev": true,
"wheel_name": "wheel_front_left",
"tasks": ["wheel_analysis"]
},
"ftransit18-aA2K898S": {
Expand Down
4 changes: 4 additions & 0 deletions packages/sights/research/data/haccord/haccord.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"vehicle": "haccord",
"mirror_sight": "haccord-boMeNVsC",
"dev": true,
"wheel_name": "wheel_front_left",
"tasks": ["wheel_analysis"]
},
"haccord-GdWvsqrm": {
Expand Down Expand Up @@ -184,6 +185,7 @@
"vehicle": "haccord",
"mirror_sight": "haccord-2v-2_QD5",
"dev": true,
"wheel_name": "wheel_front_right",
"tasks": ["wheel_analysis"]
},
"haccord-KvP-pm8L": {
Expand Down Expand Up @@ -226,6 +228,7 @@
"vehicle": "haccord",
"mirror_sight": "haccord-H_eRrLBl",
"dev": true,
"wheel_name": "wheel_back_right",
"tasks": ["wheel_analysis"]
},
"haccord-PGr3RzzP": {
Expand Down Expand Up @@ -299,6 +302,7 @@
"vehicle": "haccord",
"mirror_sight": "haccord-9fxMGSs6",
"dev": true,
"wheel_name": "wheel_back_left",
"tasks": ["wheel_analysis"]
},
"haccord-Z84erkMb": {
Expand Down
Loading