diff --git a/feedingwebapp/src/Pages/GlobalState.jsx b/feedingwebapp/src/Pages/GlobalState.jsx index 7c7359ae..76de930d 100644 --- a/feedingwebapp/src/Pages/GlobalState.jsx +++ b/feedingwebapp/src/Pages/GlobalState.jsx @@ -121,6 +121,8 @@ export const useGlobalState = create( paused: false, // Flag to indicate robot motion trough teleoperation interface teleopIsMoving: false, + // Flag to indicate whether to auto-continue after face detection + faceDetectionAutoContinue: false, // Settings values stagingPosition: SETTINGS.stagingPosition[0], biteInitiation: SETTINGS.biteInitiation[0], @@ -152,6 +154,10 @@ export const useGlobalState = create( set(() => ({ teleopIsMoving: teleopIsMoving })), + setFaceDetectionAutoContinue: (faceDetectionAutoContinue) => + set(() => ({ + faceDetectionAutoContinue: faceDetectionAutoContinue + })), setStagingPosition: (stagingPosition) => set(() => ({ stagingPosition: stagingPosition diff --git a/feedingwebapp/src/Pages/Home/MealStates/DetectingFace.jsx b/feedingwebapp/src/Pages/Home/MealStates/DetectingFace.jsx index 5cc84b33..8ec85dc6 100644 --- a/feedingwebapp/src/Pages/Home/MealStates/DetectingFace.jsx +++ b/feedingwebapp/src/Pages/Home/MealStates/DetectingFace.jsx @@ -32,6 +32,8 @@ const DetectingFace = (props) => { // Get the relevant global variables const setMealState = useGlobalState((state) => state.setMealState) const setMoveToMouthActionGoal = useGlobalState((state) => state.setMoveToMouthActionGoal) + const faceDetectionAutoContinue = useGlobalState((state) => state.faceDetectionAutoContinue) + const setFaceDetectionAutoContinue = useGlobalState((state) => state.setFaceDetectionAutoContinue) // Get icon image for move to mouth let moveToMouthImage = MOVING_STATE_ICON_DICT[MEAL_STATE.R_MovingToMouth] // Flag to check if the current orientation is portrait @@ -90,11 +92,13 @@ const DetectingFace = (props) => { face_detection: message }) // Automatically move on to the next stage if a face is detected - moveToMouthCallback() + if (faceDetectionAutoContinue) { + moveToMouthCallback() + } } } }, - [setMouthDetected, setMoveToMouthActionGoal, moveToMouthCallback] + [faceDetectionAutoContinue, moveToMouthCallback, setMoveToMouthActionGoal] ) useEffect(() => { let topic = subscribeToROSTopic(ros.current, FACE_DETECTION_TOPIC, FACE_DETECTION_TOPIC_MSG, faceDetectionCallback) @@ -146,58 +150,87 @@ const DetectingFace = (props) => { */ const fullPageView = useCallback(() => { return ( - - - + <> + +

+ setFaceDetectionAutoContinue(e.target.checked)} + style={{ transform: 'scale(2.0)', verticalAlign: 'middle', marginRight: '15px' }} + /> + Auto-continue +

+
+ + + +

+ {mouthDetected ? 'Mouth detected!' : 'Waiting to detect mouth...'} +

+
+ + + +
+

- {mouthDetected ? 'Mouth detected!' : 'Waiting to detect mouth...'} + {mouthDetected ? 'Continue' : 'Continue without detecting mouth'}

+ {/* Icon to move to mouth position */} +
- - - -
- -

- {mouthDetected ? 'Continue' : 'Continue without detecting mouth (may fail)'} -

- {/* Icon to move to mouth position */} -
-
+ ) }, [ dimension, @@ -210,7 +243,9 @@ const DetectingFace = (props) => { buttonHeight, buttonWidth, iconHeight, - iconWidth + iconWidth, + faceDetectionAutoContinue, + setFaceDetectionAutoContinue ]) // Render the component