There are 3 states.
1) the basket is increasing its distance from echoing surfaces
2) the basket is approaching echoing surfaces
3) it is too close to measure.
If samples are taken periodically over time and stored the 3 states can be distinguished. A velocity can be computed and an estimated position of the next sample can be determined and compared to the actual sample. The period would be such that the basket couldn't travel even at maximum speed more than a few centimeters between samples.
Yep, that is what I implied as far as a error trap code, but you went into much more detail...
however as basket is metal it can be a problem. sensors have 30 degrees view angle
You would need to experiment, but I doubt you will see much if any bounce back from the vertical bottom of the bucket, if you do simply rotate the sensor downward a bit and use triangulation to adjust for actual distance if it skews the numbers that bad... I have played with these types of sensors on a desktop and can't say I recall false readings due to the desktop aka vertical surface...