This PR is adding a feature node Food on Fork that will allow for automatically detecting the presence of food on the fork. It is addressing the issue linked https://github.com/personalrobotics/ada_feeding/issues/43. It will output a confidence to a topic /food_on_fork and it represents the confidence with which the model is able to predict food on the fork.
Design Decisions
Outlined, in the readme, there is an overview of the models being used.
Testing procedure
Test the Training Procedure
Make sure to download the necessary testing files (ideally store them directly inside /ada_feeding_perception/ada_feeding_perception). Don't unzip the files. The code will unzip and process at runtime. The three datasets as linked below:
Change directory into /ada_feeding_perception/ada_feeding_perception/.
Run the food_on_fork_categorical_naive_bayes_training.py.
This file takes in a few arguments. So, follow the command outlined below:
General format of the command: python food_on_fork_categorical_naive_bayes_training.py "<boolean>" "<dataset_zip>" --model_save_file "<name>"
The first argument (boolean) specifies whether or not to use the entire dataset for training. It also specifies whether or not a model should be saved.
Second argument (dataset_zip) specifies the location of the zip file that you have downloaded from the first step. _Ideally, you should just store the downloaded zip file in ada_feeding_perception/ada_feeding_perception_.
Third argument (name) is optional and is dependent on whether or not the first argument is true or false. If the first argument is true, the third argument is required, otherwise it is not required. This is the name that you want to provide for the model being saved
Note that parts of this procedure is also outlined here.
Test the model on the robot
Now that you have confirmed that you are able to mimic the training procedure, perform a model training on the full dataset. Run the following command to train on the full dataset: python food_on_fork_categorical_naive_bayes_training.py "True" "./train_test_data_no_hand_8-30-23.zip" --model_save_file "categorical_naive_bayes_without_hand_8-30-23.pkl". This should create a .pkl file, which is the model. Now either move this model into /ada_feeding_perception/model/ folder or use the model already present inside that folder. To be able to use this model, navigate to food_on_fork.yaml file and change the location of the model.
To test this model, follow these steps:
Position the robot such that the arm is in "resting position". Make sure to listen to /food_on_fork topic (ros2 topic echo /food_on_fork). If there is food on fork, you should notice values close to 1.0 and if there is no food on fork, you should notice values close to 0.0.
Run the FoF node and echo ros2 topic echo /food_on_fork and then visually test out by adding various food items onto the fork.
Then, reposition the arm into the "in-front of face" position, sit in the chair, and conduct the test outlined in Step 2.
Note: Try different food items. Try to test the extremes of adding food items as well. But, please don't get stuck on minor cases. There will still be cases where if the food is only partially on the fork and the prediction might be incorrect.
Before opening a pull request
[x] Format your code using black formatterpython3 -m black .
[ ] Run your code through pylint and address all warnings/errors. The only warnings that are acceptable to not address is TODOs that should be addressed in a future PR. From the top-level ada_feeding directory, run: pylint --recursive=y --rcfile=.pylintrc ..
Description
This PR is adding a feature node Food on Fork that will allow for automatically detecting the presence of food on the fork. It is addressing the issue linked https://github.com/personalrobotics/ada_feeding/issues/43. It will output a confidence to a topic
/food_on_fork
and it represents the confidence with which the model is able to predict food on the fork.Design Decisions
Outlined, in the readme, there is an overview of the models being used.
Testing procedure
Test the Training Procedure
/ada_feeding_perception/ada_feeding_perception
). Don't unzip the files. The code will unzip and process at runtime. The three datasets as linked below:/ada_feeding_perception/ada_feeding_perception/
.food_on_fork_categorical_naive_bayes_training.py
.python food_on_fork_categorical_naive_bayes_training.py "<boolean>" "<dataset_zip>" --model_save_file "<name>"
boolean
) specifies whether or not to use the entire dataset for training. It also specifies whether or not a model should be saved.dataset_zip
) specifies the location of the zip file that you have downloaded from the first step. _Ideally, you should just store the downloaded zip file inada_feeding_perception/ada_feeding_perception
_.name
) is optional and is dependent on whether or not the first argument is true or false. If the first argument is true, the third argument is required, otherwise it is not required. This is the name that you want to provide for the model being savedpython food_on_fork_categorical_naive_bayes_training.py "False" "./train_test_data_no_hand_8-30-23.zip"
<dataset_zip>
specifies the dataset you downloaded.Test the model on the robot
Now that you have confirmed that you are able to mimic the training procedure, perform a model training on the full dataset. Run the following command to train on the full dataset:
python food_on_fork_categorical_naive_bayes_training.py "True" "./train_test_data_no_hand_8-30-23.zip" --model_save_file "categorical_naive_bayes_without_hand_8-30-23.pkl"
. This should create a .pkl file, which is the model. Now either move this model into/ada_feeding_perception/model/
folder or use the model already present inside that folder. To be able to use this model, navigate tofood_on_fork.yaml
file and change the location of the model.To test this model, follow these steps:
/food_on_fork
topic (ros2 topic echo /food_on_fork
). If there is food on fork, you should notice values close to 1.0 and if there is no food on fork, you should notice values close to 0.0.ros2 topic echo /food_on_fork
and then visually test out by adding various food items onto the fork.Before opening a pull request
python3 -m black .
ada_feeding
directory, run:pylint --recursive=y --rcfile=.pylintrc .
.Before Merging
Squash & Merge