Skip to content

Commit

Permalink
Remove localization dialog for anymal
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Nov 26, 2024
1 parent 6f5caee commit 7d9f220
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Robot } from 'models/Robot'
import { Robot, RobotCapabilitiesEnum } from 'models/Robot'
import { useEffect, useState } from 'react'
import { useRobotContext } from 'components/Contexts/RobotContext'
import {
Expand All @@ -22,6 +22,7 @@ export const ScheduleMissionWithConfirmDialogs = ({
}: ConfirmScheduleDialogProps) => {
const { enabledRobots } = useRobotContext()
const [robot, setRobot] = useState<Robot>()
const [shouldScheduleWithoutLocalization, setShouldScheduleWithoutLocalization] = useState<boolean>()

const isBatteryInsufficient = (currentRobot: Robot) => {
const hasBatteryValue = currentRobot.batteryLevel !== null && currentRobot.batteryLevel !== undefined
Expand All @@ -47,13 +48,29 @@ export const ScheduleMissionWithConfirmDialogs = ({
setRobot(enabledRobots.find((robot) => robot.id === robotId))
}, [robotId, enabledRobots])

useEffect(() => {
if (shouldScheduleWithoutLocalization) {
scheduleMissions()
closeDialog()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [shouldScheduleWithoutLocalization])

if (!robot) {
return <></>
} else if (isBatteryInsufficient(robot)) {
return <InsufficientBatteryDialog robot={robot} cancel={closeDialog} />
} else if (isPressureInsufficient(robot)) {
return <InsufficientPressureDialog robot={robot} cancel={closeDialog} />
} else {
// Auto-localizing robots don't need to confirmation localization. Localization dialog can be skipped
if (
robot.robotCapabilities?.includes(RobotCapabilitiesEnum.auto_localize) &&
!shouldScheduleWithoutLocalization
) {
setShouldScheduleWithoutLocalization(true)
return <></>
}
return (
<ScheduleMissionWithLocalizationVerificationDialog
scheduleMissions={scheduleMissions}
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/models/Robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface Robot {
pressureLevel?: number
pose?: Pose
status: RobotStatus
robotCapabilities?: RobotCapabilitiesEnum[]
isarConnected: boolean
deprecated: boolean
host?: string
Expand All @@ -50,3 +51,16 @@ export const placeholderRobot: Robot = {
isarConnected: true,
deprecated: false,
}

export enum RobotCapabilitiesEnum {
take_thermal_image = 'take_thermal_image',
take_image = 'take_image',
take_video = 'take_video',
take_thermal_video = 'take_thermal_video',
record_audio = 'record_audio',
localize = 'localize',
auto_localize = 'auto_localize',
auto_return_to_home = 'auto_return_to_home',
docking_procedure = 'docking_procedure',
return_to_home = 'return_to_home',
}

0 comments on commit 7d9f220

Please sign in to comment.