Skip to content

Commit edd39a7

Browse files
committed
Revamp for 2023 Deployment
- Began with code from the `2023PreDeployment` branch - Split each component into a separate file - Added thorough in-code documentation - Adding eslint and prettier checks for readability and consistency - Implemented intentional splits between local and global state
1 parent fbb8a42 commit edd39a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+5014
-23560
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Feeding Web Interface
2+
3+
This repository contains code for the feeding web app. The app itself is in `feedingwebapp` and contains its own README. The other folder in this repository (will) contain a ROS package that can be used to test the web app's integration with ROS.

feedingwebapp/.eslintignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

feedingwebapp/.eslintrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 2020,
5+
sourceType: 'module',
6+
ecmaFeatures: {
7+
jsx: true
8+
}
9+
},
10+
settings: {
11+
react: {
12+
version: 'detect'
13+
}
14+
},
15+
env: {
16+
jest: true,
17+
browser: true,
18+
amd: true,
19+
node: true
20+
},
21+
extends: [
22+
'eslint:recommended',
23+
'plugin:react/recommended',
24+
'plugin:prettier/recommended' // Make this the last element so prettier config overrides other formatting rules
25+
],
26+
rules: {
27+
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: false }],
28+
'prettier/prettier': ['error', {}, { usePrettierrc: true }]
29+
}
30+
}

feedingwebapp/.prettierrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"embeddedLanguageFormatting": "auto",
5+
"htmlWhitespaceSensitivity": "css",
6+
"insertPragma": false,
7+
"jsxBracketSameLine": false,
8+
"jsxSingleQuote": true,
9+
"proseWrap": "preserve",
10+
"quoteProps": "as-needed",
11+
"requirePragma": false,
12+
"semi": false,
13+
"singleQuote": true,
14+
"trailingComma": "none",
15+
"useTabs": false,
16+
"vueIndentScriptAndStyle": false,
17+
"printWidth": 140,
18+
"tabWidth": 2,
19+
"rangeStart": 0
20+
}

feedingwebapp/README.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
> For Technical Documentation, please refer to [this file](https://github.com/personalrobotics/feeding_web_interface/blob/2023PreDeployment/feedingwebapp/TechDocumentation.md).
33
44
## Summary
5-
This project aims to develop a web app to connect and control feeding through ADA robot. The overall workflow (state machine) for this robot can be seen below.
5+
This project aims to develop a web app to connect and control feeding through ADA robot. The overall workflow (state machine) for this robot can be seen below.
66

77
<!-- ![Web App State Machine](https://user-images.githubusercontent.com/8277986/191333326-c71a1765-475c-40f6-87da-a79b7c73e0ee.png) -->
88
![newWebAppWorkflow](https://user-images.githubusercontent.com/26337328/223597500-5e520b7a-eb2b-45ad-b9e8-91fec1bdeba4.jpg)
@@ -11,7 +11,25 @@ This project aims to develop a web app to connect and control feeding through AD
1111
- [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
1212
- [ROS](http://wiki.ros.org/noetic/Installation)
1313

14-
## Usage
14+
## Misc Notes
15+
Q: Why are we using a global state to manage which page of the app the user is on, as opposed to React's Router?
16+
A: If we use React's Router, we allow users to navigate through the web app by changing the URL, or clicking the "back" button on their browser. However, not all pages should be reachable from all other pages, e.g., the bite selection page should only be reachable if the robot arm is above the plate. Hence, we use a global state so we can internally control the user's flow through the app.
17+
18+
TODO (amaln):
19+
- Document debug mode.
20+
- We use npm, not yarn, as a package installer for this repo
21+
- Add guidelines for contributing
22+
23+
## Style Guide
24+
- For writing your code, follow the [AirBnB React/JSX Style Guide](https://airbnb.io/javascript/react/). For anything not specified there (e.g., variable naming conventions), use the [AirBnB JavaScript Style Guide](https://airbnb.io/javascript/).
25+
- The style guide was written before hooks (e.g, `useState`) were added to React. Since hooks can only be used within the Component's function, ordering code within that function becomes important. See [this for an example of how to order calls to various hooks](https://dev.to/abrahamlawson/react-style-guide-24pp#comment-1f4fd).
26+
- For documenting code, follow the [React Styleguidist guide](https://react-styleguidist.js.org/docs/documenting/).
27+
28+
## TODO
29+
- Consider having a generic "Teleoperation" page that would be accessible from anywhere. The page would show the robot's live video and buttons for the user to teleoperate the robot. This is useful e.g., if the user wants to nudge the robot closer to their face, move the robot when it is above the plate so it doesn't obstruct their desired food, etc. In fact, maybe this should take the place of the "Video" modal, that the user can click anytime. If the robot is currently executing a plan the teleop buttons would be greyed out (but the can still see the video), else they can see the video and teleoperate the robot.
30+
- An additional axis of customization is to let the user specify the staging location, where one option should be "above the plate" e.g., don't stage it in front of their mouth until the user initiates the bite (with a method other than open mouth).
31+
32+
## Usage
1533
### How to run the app locally?
1634
- Clone the repo: `git clone [email protected]:personalrobotics/feeding_web_interface.git` using SSH, or `git clone https://github.com/personalrobotics/feeding_web_interface.git` using HTTP
1735
- See all branches: `git branch -a` and check to make sure `2022_revamp` branch shows up
@@ -21,51 +39,51 @@ This project aims to develop a web app to connect and control feeding through AD
2139
- Then, `npm start` to begin the application.
2240
- Then, use a web browser to navigate to `localhost:3000` to see the application.
2341

24-
In the `Home.js` file, you can set `debug = true` and run the application in debug mode to experience the GUI of the app without needing it to connect to ROS. Otherwise, set it to `debug = false` and run it along with roscore/ros messages.
42+
In the `Home.js` file, you can set `debug = true` and run the application in debug mode to experience the GUI of the app without needing it to connect to ROS. Otherwise, set it to `debug = false` and run it along with roscore/ros messages.
2543

2644
#### How to run ROS 'stuff' with the app in `debug = true` mode?
27-
For this, you just need the web app running. And, to mimic the robot/webapp communicating, there are some default buttons throughtout the app that can help mimic the state changes as described in the state machine picture above.
45+
For this, you just need the web app running. And, to mimic the robot/webapp communicating, there are some default buttons throughtout the app that can help mimic the state changes as described in the state machine picture above.
2846

2947
#### How to run ROS 'stuff' with the app in `debug = false` mode?
3048
- `cd` into the ROS workspace
31-
- Make sure to open up at least four terminals with all of them inside the workspace.
49+
- Make sure to open up at least four terminals with all of them inside the workspace.
3250
- Then, run `source devel/setup.bash` in each of the terminals that are open (Use Tmux to make splitting terminal easier on Ubuntu)
3351
- On the first terminal, run `roscore`
3452
- On the second terminal, run `roslaunch rosbridge_server rosbridge_websocket.launch` to start the webserver. _This will allow the webapp to actually directly connect with the server (when you hit "start feeding" button)._
35-
- On the third terminal (designate this terminal for yourself to be the "ROBOT sending messages to app") - You can publish messages to `/from_robot` topic and communicate with the webapp to make changes to the states. An example message is `rostopic pub /from_robot std_msgs/String "<state>"`.
36-
- On the fourth terminal (designate this terminal for yourself to be the "ROBOT receiving messages from app") - You can listen to messages from `from_web` topic. An example command is `rostopic echo /from_web` to listen to messages published from the webapp.
53+
- On the third terminal (designate this terminal for yourself to be the "ROBOT sending messages to app") - You can publish messages to `/from_robot` topic and communicate with the webapp to make changes to the states. An example message is `rostopic pub /from_robot std_msgs/String "<state>"`.
54+
- On the fourth terminal (designate this terminal for yourself to be the "ROBOT receiving messages from app") - You can listen to messages from `from_web` topic. An example command is `rostopic echo /from_web` to listen to messages published from the webapp.
3755

3856
#### How to run camera 'stuff' with the app?
39-
The following steps will outline the method to use to run the video collected from a particular topic in the [rosbag](http://wiki.ros.org/rosbag) _These steps might be diffrerent for if you were to connect to Robot's camera (please check)._
40-
- Start by downloading the rosbags that you wish to run and store them in your ROS workspace.
41-
- Make sure to run `source devel/setup.bash`.
57+
The following steps will outline the method to use to run the video collected from a particular topic in the [rosbag](http://wiki.ros.org/rosbag) _These steps might be different for if you were to connect to Robot's camera (please check)._
58+
- Start by downloading the rosbags that you wish to run and store them in your ROS workspace.
59+
- Make sure to run `source devel/setup.bash`.
4260
- Then make sure to download the [web video sever](http://wiki.ros.org/web_video_server) files by performing the following steps:
43-
- First, split the terminal and open up two terminals both inside the `camera_ws`. Make sure you perform `source devel/setup.bash`.
61+
- First, split the terminal and open up two terminals both inside the `camera_ws`. Make sure you perform `source devel/setup.bash`.
4462
- In the first terminal, perform the following:
4563
```
4664
git clone https://github.com/sfalexrog/async_web_server_cpp.git
4765
cd async_web_server
4866
git checkout noetic-devel
4967
```
50-
- In the second terminal, perform the following:
68+
- In the second terminal, perform the following:
5169
```
5270
git clone https://github.com/RobotWebTools/web_video_server.git
5371
```
54-
Then, perform `catkin build` from one of the terminals.
55-
72+
Then, perform `catkin build` from one of the terminals.
73+
5674
##### Running Rosbags
57-
- First navigate into your `catkin_ws` workspace and make sure you have your original rosbag files. This means, if you need to decompress, make sure you decompress and store the decompressed rosbag file. Usually, after decompressing, the rosbag file gets stored as <something>.orig.bag.
58-
- Next, run `rosbag play <name of the bag file>`.
59-
- You should see the rosbag running its contents.
60-
- While this is happening, we will need to start the web server to be able to see the images as video. So, we would navigate into the `camera_ws` workspace and change directory into where ever you have stored the `web_video_server`.
61-
- Inside this folder, run `rosrun web_video_server web_video_server`.
62-
- After this, you can go to a web browser and type in `localhost:8080` and see that there is a list of topics to choose from. Choose a particular topic to listen to and you should see the video playing. As you do that, you can notice the parameters in web url changing. Make sure you play with the parameters by referring to the document below to get the best quality video for the webapp.
75+
- First navigate into your `catkin_ws` workspace and make sure you have your original rosbag files. This means, if you need to decompress, make sure you decompress and store the decompressed rosbag file. Usually, after decompressing, the rosbag file gets stored as <something>.orig.bag.
76+
- Next, run `rosbag play <name of the bag file>`.
77+
- You should see the rosbag running its contents.
78+
- While this is happening, we will need to start the web server to be able to see the images as video. So, we would navigate into the `camera_ws` workspace and change directory into where ever you have stored the `web_video_server`.
79+
- Inside this folder, run `rosrun web_video_server web_video_server`.
80+
- After this, you can go to a web browser and type in `localhost:8080` and see that there is a list of topics to choose from. Choose a particular topic to listen to and you should see the video playing. As you do that, you can notice the parameters in web url changing. Make sure you play with the parameters by referring to the document below to get the best quality video for the webapp.
6381

64-
For further information about this, you can refer to [Web Video server](http://wiki.ros.org/web_video_server) document.
82+
For further information about this, you can refer to [Web Video server](http://wiki.ros.org/web_video_server) document.
6583

66-
## What are some next steps?
67-
- Enabling a method of selecting food from the live video feed that gets displayed in the video tab.
68-
- What happens if Wifi goes out?
84+
## What are some next steps?
85+
- Enabling a method of selecting food from the live video feed that gets displayed in the video tab.
86+
- What happens if Wifi goes out?
6987
- What happens if the user accidentally refreshes?
7088
- When you first start the webapp, it should first get the status from the robot and update itself to mimic that of the robot. This could be something that can be implemented to eliminate any syncing issues between the robot and the app. Further, in the Settings page, the app should get the settings as default from the robot.
71-
- Currently, the E-stop is not accessible when the video modal is open. Consider changing this.
89+
- Currently, the E-stop is not accessible when the video modal is open. Consider changing this.

0 commit comments

Comments
 (0)