Ultrasonic Wall Alignment

As @69922Nathan have said, getting UltraSonic distance finder to work reliably may be tricky.

The most important thing to know is that it could be influenced by external noise. It could sometimes return different range of values at the competition, than what you have experienced while testing it at home.

So, you have to treat its results not as the final truth but as advisory, and take a conservative action like slowdown before you hit the wall, but still treat the wall as the only true source of alignment. Essentially, you have to assume that values out of ultrasonic could be wrong at any time and handle that appropriately, but statistically they will, probably, be very close to the truth most of the time.

You may want to check out these links for more info:

https://renegaderobotics.org/vex-sensors-ultrasonic-range-finder/

https://www.vexforum.com/t/distance-sensor-field-of-vision/43551

https://www.vexforum.com/t/filtering-of-sensor-data/47096