personalrobotics / ada_feeding

Robot-assisted feeding demos and projects for the ADA robot
4 stars 4 forks source link

Food-on-Fork Detection #169

Closed amalnanavati closed 5 months ago

amalnanavati commented 6 months ago

Description

In service of #43 , this PR implements automatic food-on-fork detection.

The core approach is to store a representative set of 3D points that correspond to the fork shape when there is no food on it. Then, given a new depth image, compute the average distance between the points in that image and the nearest point on the stored image. When there is no food-on-fork, that distances are on the order of 1e-4 m, whereas when there is food on the fork, they are on the order of 1e-3 m. Train a classifier on those distances to predict the probability that there is food on the fork.

As a concrete example, the specific model pushed in this PR stores 2426 points which look like the below image: Screenshot 2024-03-08 at 6 59 12 PM

This approach achieves ~96% accuracy on bagged data of 8 real bites (acquisition and transfer) when we use an upper and lower threshold of 0.5. Inference takes a median of 0.016s (25th percentile 0.007s, 75th percentile 0.022s).

Testing procedure

Documented Commands for Training

Ideas for Future Improvements

  1. Add a filter to the FoodOnForkDetection node for more stability.
  2. Instead of storing points, consider using urdfpy to get the actual fork mesh and get the closest point to that. (Although we know that at least as of now, our fork URDF is slightly off from the real fork, both because of some movement of the fork handle (#170 ) and because of the fork tines bending.)

Before opening a pull request

Before Merging

amalnanavati commented 6 months ago

TODOs:

amalnanavati commented 6 months ago

Mostly done. When playing back the above ROSbag, the predictions were quite unstable in the in-front-of-face configuration. I tried retraining with mean, but it didn't fix that. Worth looking into this more. But first test it in-person / play back the other ROSbags to not overfit to one case. Also because as of now, we won't be checking food-on-fork in the in-front-of-face configuration.

amalnanavati commented 5 months ago

Did the in-person tests. It works...except that it is very sensitive to the fork being slightly rotated in the gripper. The thing is, this is a problem we have had before that causes the fork to not skewer items centered. So while there are some FoF changes I can do to make it less sensitive (e.g., only focus on deviation in the z direction, or maybe weight deviations in each direction differently), I think we should first try to come up with a proper fix to ensuring the forktip is actually aligned with the frame.