Ultrasonic not working

I started using an ultrasonic sensor to detect the height of loads of cones in front of it by moving up and down.

However, the sensor isn’t working every time, I mean, work after a few tries.

I have to start with something hanging 6cm in front of the sonar. After I remove it by user-control, the value of sensor was like locked at 6, and it doesn’t change no matter what.
I have to cover the input and output by finger, giving a -1 value, then remove and it will work as normal.
But this move is certainly not allowed in competition during pre-auton.

Is there some kind of solution by initialising or restarting?

I will have a look at this later, there should be no reason that this wouldn’t work, the ultrasonic sensor does not need any sort of re-initialization. It may be worth checking with the sensor plugged into different digital ports, there are some problems if you have used port 4 and/or port 10 depending on what they are used for.