Skip to content

Commit 34b5d0d

Browse files
authored
Added Odometer and Warning Lights tasks to network package (#913)
1 parent ce8fde1 commit 34b5d0d

File tree

8 files changed

+160
-15
lines changed

8 files changed

+160
-15
lines changed

packages/network/src/api/image/mappers.ts

+2
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,7 @@ export function mapApiImage(
217217
additionalData: image.additional_data,
218218
renderedOutputs: [],
219219
views: [],
220+
odometer: image.odometer?.value,
221+
warningLights: image.warning_lights?.activated_warning_lights,
220222
};
221223
}

packages/network/src/api/image/requests.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,13 @@ function createBeautyShotImageData(
285285
const filename = `${options.sightId}-${options.inspectionId}-${Date.now()}.${filetype}`;
286286
const tasks = options.tasks.filter(
287287
(task) =>
288-
![TaskName.COMPLIANCES, TaskName.HUMAN_IN_THE_LOOP, TaskName.IMAGES_OCR].includes(task),
288+
![
289+
TaskName.COMPLIANCES,
290+
TaskName.HUMAN_IN_THE_LOOP,
291+
TaskName.IMAGES_OCR,
292+
TaskName.ODOMETER,
293+
TaskName.WARNING_LIGHTS,
294+
].includes(task),
289295
) as ApiImagePostTask[];
290296
tasks.push({
291297
name: TaskName.COMPLIANCES,
@@ -305,6 +311,18 @@ function createBeautyShotImageData(
305311
image_details: { image_type: 'VIN' },
306312
});
307313
}
314+
if (options.tasks.includes(TaskName.ODOMETER)) {
315+
tasks.push({
316+
name: TaskName.ODOMETER,
317+
wait_for_result: true,
318+
});
319+
}
320+
if (options.tasks.includes(TaskName.WARNING_LIGHTS)) {
321+
tasks.push({
322+
name: TaskName.WARNING_LIGHTS,
323+
wait_for_result: true,
324+
});
325+
}
308326

309327
const body: ApiImagePost = {
310328
acquisition: {

packages/network/src/api/inspection/mappers.ts

+24
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
ApiImagesOCRTaskPostComponent,
4444
ApiInspectionGet,
4545
ApiInspectionPost,
46+
ApiOdometerTaskPostComponent,
4647
ApiPartSeverityValue,
4748
ApiPricingTaskPostComponent,
4849
ApiPricingV2,
@@ -54,6 +55,7 @@ import {
5455
ApiTasksComponent,
5556
ApiView,
5657
type ApiViews,
58+
ApiWarningLightsTaskPostComponent,
5759
ApiWheelAnalysisTaskPostComponent,
5860
} from '../models';
5961
import { mapApiImage } from '../image/mappers';
@@ -601,13 +603,35 @@ function getPricingOptions(
601603
: undefined;
602604
}
603605

606+
function getOdometerOptions(
607+
options: CreateInspectionOptions,
608+
): ApiOdometerTaskPostComponent | undefined {
609+
return options.tasks.includes(TaskName.ODOMETER)
610+
? {
611+
status: ProgressStatus.NOT_STARTED,
612+
}
613+
: undefined;
614+
}
615+
616+
function getWarningLightsOptions(
617+
options: CreateInspectionOptions,
618+
): ApiWarningLightsTaskPostComponent | undefined {
619+
return options.tasks.includes(TaskName.WARNING_LIGHTS)
620+
? {
621+
status: ProgressStatus.NOT_STARTED,
622+
}
623+
: undefined;
624+
}
625+
604626
function getTasksOptions(options: CreateInspectionOptions): ApiTasksComponent {
605627
return {
606628
damage_detection: getDamageDetectionOptions(options),
607629
wheel_analysis: getWheelAnalysisOptions(options),
608630
images_ocr: getImagesOCROptions(options),
609631
human_in_the_loop: getHumanInTheLoopOptions(options),
610632
pricing: getPricingOptions(options),
633+
odometer: getOdometerOptions(options),
634+
warning_lights: getWarningLightsOptions(options),
611635
};
612636
}
613637

packages/network/src/api/models/image.ts

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TranslationObject } from '@monkvision/types';
1+
import { MileageUnit, TranslationObject, WarningLights } from '@monkvision/types';
22
import type { ApiAdditionalData, ApiCenterOnElement, ApiLabelPrediction } from './common';
33
import type { ApiRenderedOutputs } from './renderedOutput';
44
import type { ApiImageComplianceResults } from './compliance';
@@ -8,6 +8,8 @@ import {
88
ApiHinlTaskPost,
99
ApiImageCompliancesTaskPost,
1010
ApiImagesOCRTaskPost,
11+
ApiImagesOdometerTaskPost,
12+
ApiImagesWarningLightsTaskPost,
1113
} from './task';
1214

1315
export type ApiImageType = 'unknown' | 'beauty_shot' | 'close_up';
@@ -35,6 +37,20 @@ export interface ApiImageAdditionalData extends ApiAdditionalData {
3537
label?: TranslationObject;
3638
}
3739

40+
export interface ApiImageOdometer {
41+
unit?: MileageUnit;
42+
value?: number;
43+
confidence_score?: number;
44+
error?: string;
45+
rotation?: string;
46+
visualization_url?: string;
47+
}
48+
49+
export interface ApiImageWarningLights {
50+
activated_warning_lights: WarningLights[];
51+
light_to_score: Record<WarningLights, number>;
52+
}
53+
3854
export interface ApiImage {
3955
additional_data?: ApiImageAdditionalData;
4056
binary_size: number;
@@ -51,6 +67,8 @@ export interface ApiImage {
5167
name?: string;
5268
path: string;
5369
viewpoint?: ApiLabelPrediction;
70+
odometer?: ApiImageOdometer;
71+
warning_lights?: ApiImageWarningLights;
5472
}
5573

5674
export interface ApiImageWithViews extends ApiImage {
@@ -85,21 +103,15 @@ export interface ApiCompliance {
85103
}
86104

87105
export type ApiImagePostTask =
88-
| Omit<
106+
| Extract<
89107
ApiBusinessTaskName,
90-
| 'repair_estimate'
91-
| 'images_ocr'
92-
| 'image_editing'
93-
| 'inspection_pdf'
94-
| 'pricing'
95-
| 'zoom_level'
96-
| 'coverage_360'
97-
| 'iqa_compliance'
98-
| 'human_in_the_loop'
108+
'damage_detection' | 'wheel_analysis' | 'dashboard_ocr' | 'compliances'
99109
>
100110
| ApiImageCompliancesTaskPost
101111
| ApiHinlTaskPost
102-
| ApiImagesOCRTaskPost;
112+
| ApiImagesOCRTaskPost
113+
| ApiImagesOdometerTaskPost
114+
| ApiImagesWarningLightsTaskPost;
103115

104116
export interface ApiImagePost {
105117
acquisition: ApiAcquisition;

packages/network/src/api/models/task.ts

+20
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ export interface ApiImagesOCRTaskPost {
4747
image_details: ApiImagesOCRImageDetails;
4848
}
4949

50+
export interface ApiImagesOdometerTaskPost {
51+
name: 'odometer';
52+
wait_for_result?: boolean;
53+
}
54+
55+
export interface ApiImagesWarningLightsTaskPost {
56+
name: 'warning_lights';
57+
wait_for_result?: boolean;
58+
}
59+
5060
export type ApiTaskProgressStatus =
5161
| 'NOT_STARTED'
5262
| 'TODO'
@@ -127,10 +137,20 @@ export interface ApiPricingTaskPostComponent {
127137
methodology?: ApiPricingMethodology;
128138
}
129139

140+
export interface ApiOdometerTaskPostComponent {
141+
status?: ApiTaskPostProgressStatus;
142+
}
143+
144+
export interface ApiWarningLightsTaskPostComponent {
145+
status?: ApiTaskPostProgressStatus;
146+
}
147+
130148
export interface ApiTasksComponent {
131149
damage_detection?: ApiDamageDetectionTaskPostComponent;
132150
wheel_analysis?: ApiWheelAnalysisTaskPostComponent;
133151
images_ocr?: ApiImagesOCRTaskPostComponent;
134152
human_in_the_loop?: ApiHinlTaskPostComponent;
135153
pricing?: ApiPricingTaskPostComponent;
154+
odometer?: ApiOdometerTaskPostComponent;
155+
warning_lights?: ApiWarningLightsTaskPostComponent;
136156
}

packages/network/test/api/image/requests.test.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ function createBeautyShotImageOptions(): AddBeautyShotImageOptions {
5050
},
5151
inspectionId: 'test-inspection-id',
5252
sightId: 'test-sight-1',
53-
tasks: [TaskName.DAMAGE_DETECTION, TaskName.WHEEL_ANALYSIS, TaskName.HUMAN_IN_THE_LOOP],
53+
tasks: [
54+
TaskName.DAMAGE_DETECTION,
55+
TaskName.WHEEL_ANALYSIS,
56+
TaskName.HUMAN_IN_THE_LOOP,
57+
TaskName.IMAGES_OCR,
58+
TaskName.ODOMETER,
59+
TaskName.WARNING_LIGHTS,
60+
],
5461
compliance: {
5562
enableCompliance: true,
5663
complianceIssues: [ComplianceIssue.INTERIOR_NOT_SUPPORTED],
@@ -292,7 +299,15 @@ describe('Image requests', () => {
292299
},
293300
image_type: ImageType.BEAUTY_SHOT,
294301
tasks: [
295-
...options.tasks.filter((task) => task !== TaskName.HUMAN_IN_THE_LOOP),
302+
...options.tasks.filter(
303+
(task) =>
304+
![
305+
TaskName.HUMAN_IN_THE_LOOP,
306+
TaskName.IMAGES_OCR,
307+
TaskName.ODOMETER,
308+
TaskName.WARNING_LIGHTS,
309+
].includes(task),
310+
),
296311
{
297312
name: TaskName.COMPLIANCES,
298313
image_details: { sight_id: options.sightId },
@@ -301,6 +316,18 @@ describe('Image requests', () => {
301316
name: TaskName.HUMAN_IN_THE_LOOP,
302317
image_details: { sight_label: sights[options.sightId].label },
303318
},
319+
{
320+
name: TaskName.IMAGES_OCR,
321+
image_details: { image_type: 'VIN' },
322+
},
323+
{
324+
name: TaskName.ODOMETER,
325+
wait_for_result: true,
326+
},
327+
{
328+
name: TaskName.WARNING_LIGHTS,
329+
wait_for_result: true,
330+
},
304331
],
305332
additional_data: {
306333
sight_id: options.sightId,

packages/types/src/state/image.ts

+34
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ export interface Viewpoint {
103103
centersOn?: (VehiclePart | CentersOnElement)[];
104104
}
105105

106+
export const WARNING_LIGHTS = {
107+
CEL: 'CEL',
108+
AIRBAGS: 'Airbags',
109+
ABS: 'ABS',
110+
TCS: 'TCS',
111+
BATTERY: 'Battery',
112+
TPMS: 'TPMS',
113+
MAINT: 'Maint',
114+
INFO: 'Info',
115+
BRAKE: 'brake',
116+
OTHER: 'Other',
117+
DRIVETRAIN: 'DriveTrain',
118+
LIGHTS: 'Lights',
119+
STEERING: 'Steering',
120+
OIL: 'oil',
121+
COOLANT: 'Coolant',
122+
SECONDARY: 'Secondary',
123+
SUSPENSION: 'Suspension',
124+
TRANSMISSION: 'Transmission',
125+
} as const;
126+
127+
/**
128+
* Enumeration of the warning lights that can be detected in an image.
129+
*/
130+
export type WarningLights = (typeof WARNING_LIGHTS)[keyof typeof WARNING_LIGHTS];
131+
106132
/**
107133
* Enumeration of the possible statuses of an inspection image.
108134
*/
@@ -513,4 +539,12 @@ export interface Image extends MonkEntity {
513539
* Additional data added during the upload of the image.
514540
*/
515541
additionalData?: ImageAdditionalData;
542+
/**
543+
* The odometer value of the vehicle in the image.
544+
*/
545+
odometer?: number;
546+
/**
547+
* The warning lights detected in the image.
548+
*/
549+
warningLights?: WarningLights[];
516550
}

packages/types/src/state/task.ts

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export enum TaskName {
5050
* damages are detected they are sent to an annotator that will review them and edit them if needed.
5151
*/
5252
HUMAN_IN_THE_LOOP = 'human_in_the_loop',
53+
/**
54+
* The odometer task is used to estimate the mileage of the vehicle.
55+
*/
56+
ODOMETER = 'odometer',
57+
/**
58+
* The warning lights task is used to detect the presence of warning lights on the vehicle.
59+
*/
60+
WARNING_LIGHTS = 'warning_lights',
5361
}
5462

5563
/**

0 commit comments

Comments
 (0)