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

Bite Selection UI revamp #44

Merged
merged 9 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 6 additions & 2 deletions feedingwebapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The overall user flow for this robot can be seen below.
4. Source the directory: `source install/setup.bash`
5. Navigate to the web app folder: `cd feeding_web_interface/feedingwebapp`
6. Install web app dependencies: `npm install --legacy-peer-deps`
* Consider checking out the [Troubleshooting](## Troubleshooting) section if there are errors in this process.

### Usage (Web App)
1. Navigate to the web app folder: `cd {path/to/feeding_web_interface}/feedingwebapp`
Expand Down Expand Up @@ -86,6 +87,9 @@ Note that we use `npm`, not `yarn`, to manage dependencies for this project.
- Thoroughly test your feature, including all edge cases, to ensure it works as expected. This includes trying every combination of buttons/actions, even ones we don't expect users to use, to ensure there are no unaccounted for edge cases.
- Ensure the [console](https://developer.chrome.com/docs/devtools/console/) has no errors.
- Thoroughly test responsivity by changing browser/device size to ensure it renders as expected.
- Before creating a Pull Request, run `npm format` and address any warnings or errors.
- Before creating a Pull Request, run `npm run format` and address any warnings or errors.
- Create a Pull Request to merge your branch into `main`. You need at least one approving review to merge.
- Squash all commits on your branch before merging into `main` to ensure a straightforward commit history.
- Squash all commits on your branch before merging into `main` to ensure a straightforward commit history.

## Troubleshooting
* While installing, if you run into an error about `PUPPETEER`, the
atharva-kashyap marked this conversation as resolved.
Show resolved Hide resolved
34 changes: 34 additions & 0 deletions feedingwebapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions feedingwebapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"react-script-tag": "^1.1.2",
"react-scripts": "5.0.1",
"react-split-pane": "^0.1.92",
"react-svg-path": "^1.14.0",
"react-toastify": "^9.0.7",
"roslib": "github:personalrobotics/roslibjs",
"routes": "^2.1.0",
Expand Down
33 changes: 33 additions & 0 deletions feedingwebapp/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import Header from './Pages/Header/Header'
import Home from './Pages/Home/Home'
import Settings from './Pages/Settings/Settings'
import TestROS from './ros/TestROS'
import BiteSelectionButtonOverlay from './Pages/Home/BiteSelectionUIStates/BiteSelectionButtonOverlay'
import BiteSelectionName from './Pages/Home/BiteSelectionUIStates/BiteSelectionName'
import BiteSelectionPointMask from './Pages/Home/BiteSelectionUIStates/BiteSelectionPointMask'

// Flag for whether to run the app in debug mode or not. When running in debug
// mode, the app does not connect to ROS. Anytime where it would wait for the
Expand Down Expand Up @@ -69,6 +72,36 @@ function App() {
</ROS>
}
/>
<Route
exact
path='/test_bite-selection-ui/button_overlay_selection'
element={
<ROS>
<Header />
<BiteSelectionButtonOverlay debug={debug} />
</ROS>
}
/>
<Route
exact
path='/test_bite-selection-ui/point_mask_selection'
element={
<ROS>
<Header />
<BiteSelectionPointMask debug={debug} />
</ROS>
}
/>
<Route
exact
path='/test_bite-selection-ui/food_name_selection'
element={
<ROS>
<Header />
<BiteSelectionName debug={debug} />
</ROS>
}
/>
</Routes>
</Router>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// React Imports
import React from 'react'
import Button from 'react-bootstrap/Button'

// Local Imports
import '../Home.css'
import ImageWithButton from './ImageWithButtonOverlay'
import { useGlobalState, MEAL_STATE } from '../../GlobalState'

/**
* The BiteSelection component appears after the robot has moved above the plate,
* plate. It enables users to select their desired food item.
*/
const BiteSelectionButtonOverlay = () => {
// Get the relevant global variables
const setMealState = useGlobalState((state) => state.setMealState)

/**
* Callback function for when the user indicates that they want to move the
* robot to locate the plate.
*/
function locatePlateClicked() {
atharva-kashyap marked this conversation as resolved.
Show resolved Hide resolved
console.log('locatePlateClicked')
setMealState(MEAL_STATE.U_PlateLocator)
}

/**
* Callback function for when the user indicates that they are done with their
* meal.
*/
function doneEatingClicked() {
console.log('doneEatingClicked')
setMealState(MEAL_STATE.R_StowingArm)
}

// Render the component
return (
<>
{/**
* In addition to selecting their desired food item, the user has two
* other options on this page:
* - If their desired food item is not visible on the plate, they can
* decide to teleoperate the robot until it is visible.
* - Instead of selecting their next bite, the user can indicate that
* they are done eating.
*/}
<div style={{ display: 'block' }}>
<Button
className='doneButton'
style={{ fontSize: '24px', marginTop: '0px', marginRight: '10px', marginLeft: 'auto', display: 'block' }}
onClick={locatePlateClicked}
disabled={true}
>
🍽️ Locate Plate
</Button>
<Button
className='doneButton'
style={{ fontSize: '24px', marginTop: '0px', marginRight: '10px', marginLeft: 'auto', display: 'block' }}
onClick={doneEatingClicked}
disabled={true}
>
✅ Done Eating
</Button>
</div>
<div>
<ImageWithButton
imgSrc={require('./images/food.jpg')}
imgWidth={1021}
atharva-kashyap marked this conversation as resolved.
Show resolved Hide resolved
imgHeight={779}
buttonCenters={[
{ name: 'Salad', x: 330, y: 115, rectWidth: 130, rectHeight: 100 },
{ name: 'Salad', x: 490, y: 210, rectWidth: 180, rectHeight: 100 },
{ name: 'Salad', x: 540, y: 170, rectWidth: 130, rectHeight: 100 },
{ name: 'Chicken', x: 250, y: 340, rectWidth: 290, rectHeight: 250 },
{ name: 'Chicken', x: 360, y: 520, rectWidth: 250, rectHeight: 170 },
{ name: 'Chicken', x: 450, y: 620, rectWidth: 200, rectHeight: 140 },
{ name: 'Fries', x: 520, y: 350, rectWidth: 250, rectHeight: 185 },
{ name: 'Fries', x: 750, y: 330, rectWidth: 120, rectHeight: 170 },
{ name: 'Fries', x: 650, y: 640, rectWidth: 150, rectHeight: 100 }
]}
/>
</div>
</>
)
}

export default BiteSelectionButtonOverlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// React Imports
import React from 'react'
import Button from 'react-bootstrap/Button'

// Local Imports
import '../Home.css'
import ImageWithButton from './ImageWithButtonName'
import { useGlobalState, MEAL_STATE } from '../../GlobalState'

/**
* The BiteSelection component appears after the robot has moved above the plate,
* plate. It enables users to select their desired food item.
*/
const BiteSelectionName = () => {
// Get the relevant global variables
const setMealState = useGlobalState((state) => state.setMealState)

/**
* Callback function for when the user indicates that they want to move the
* robot to locate the plate.
*/
function locatePlateClicked() {
console.log('locatePlateClicked')
setMealState(MEAL_STATE.U_PlateLocator)
}

/**
* Callback function for when the user indicates that they are done with their
* meal.
*/
function doneEatingClicked() {
console.log('doneEatingClicked')
setMealState(MEAL_STATE.R_StowingArm)
}

// Render the component
return (
<>
{/**
* In addition to selecting their desired food item, the user has two
* other options on this page:
* - If their desired food item is not visible on the plate, they can
* decide to teleoperate the robot until it is visible.
* - Instead of selecting their next bite, the user can indicate that
* they are done eating.
*/}
<div style={{ display: 'block' }}>
<Button
className='doneButton'
style={{ fontSize: '24px', marginTop: '0px', marginRight: '10px', marginLeft: 'auto', display: 'block' }}
onClick={locatePlateClicked}
disabled={true}
>
🍽️ Locate Plate
</Button>
<Button
className='doneButton'
style={{ fontSize: '24px', marginTop: '0px', marginRight: '10px', marginLeft: 'auto', display: 'block' }}
onClick={doneEatingClicked}
disabled={true}
>
✅ Done Eating
</Button>
</div>
<div>
<ImageWithButton imgSrc={require('./images/food.jpg')} imgWidth={1021} imgHeight={779} foodItems={['Chicken', 'Salad', 'Fries']} />
</div>
</>
)
}

export default BiteSelectionName
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// React Imports
import React from 'react'
import Button from 'react-bootstrap/Button'

// Local Imports
import '../Home.css'
import ImageWithButton from './ImageWithPointMask'
atharva-kashyap marked this conversation as resolved.
Show resolved Hide resolved
import { useGlobalState, MEAL_STATE } from '../../GlobalState'

/**
* The BiteSelection component appears after the robot has moved above the plate,
* plate. It enables users to select their desired food item.
*/
const BiteSelectionPointMask = () => {
// Get the relevant global variables
const setMealState = useGlobalState((state) => state.setMealState)

/**
* Callback function for when the user indicates that they want to move the
* robot to locate the plate.
*/
function locatePlateClicked() {
console.log('locatePlateClicked')
setMealState(MEAL_STATE.U_PlateLocator)
}

/**
* Callback function for when the user indicates that they are done with their
* meal.
*/
function doneEatingClicked() {
console.log('doneEatingClicked')
setMealState(MEAL_STATE.R_StowingArm)
}

// Render the component
return (
<>
{/**
* In addition to selecting their desired food item, the user has two
* other options on this page:
* - If their desired food item is not visible on the plate, they can
* decide to teleoperate the robot until it is visible.
* - Instead of selecting their next bite, the user can indicate that
* they are done eating.
*/}
<div style={{ display: 'block' }}>
<Button
className='doneButton'
style={{ fontSize: '24px', marginTop: '0px', marginRight: '10px', marginLeft: 'auto', display: 'block' }}
onClick={locatePlateClicked}
disabled={true}
>
🍽️ Locate Plate
</Button>
<Button
className='doneButton'
style={{ fontSize: '24px', marginTop: '0px', marginRight: '10px', marginLeft: 'auto', display: 'block' }}
onClick={doneEatingClicked}
disabled={true}
>
✅ Done Eating
</Button>
</div>
<div>
<ImageWithButton imgSrc={require('./images/food.jpg')} imgWidth={1021} imgHeight={779} />
</div>
</>
)
}

export default BiteSelectionPointMask
Loading