Distance sensor malfunction


We have a distance sensor underneath our clamp on our robot for Tipping Point that seems to be going off randomly at the start of autonomous. The goal of the autonomous is to grab the neutral goal and pull it to the alliance side, and do the same with the middle goal. The problem is that at the beginning when the code is started, or after grabbing the first goal, the distance sensor would register there being something in front of it within reach of the four bar when there is nothing. That would cause part of the code to be started early.

Note that we have a function for Proportional (not fully PID) that is made to simply drive forward, gradually slow down and clamp the goal. This problem does not always happen, but it does frequently. Was wondering if there is a fix and if it is for sure the distance sensor.

I ran into this problem as well making a distance senor auton. I found that the distance senors will return 0 randomly and return it for distances beyond 70in. The rate of random zeros increases alot for distances beyond 50 in. This being said the distance senors still work for the most part and we got a consistent auton out of them inspite of this.

That’s by design.
The V5 distance sensor will return 0 when it has no object in range. It’s maximum working range is around 100in, but that’s under ideal conditions is reduced when the ambient light level increases.

Probably too close to the floor and occasionally getting a reflection from that or part of your robot.