Currently I am using Robot Mesh C++ for the V5 system and was wondering how to program ultrasonic sensors. Basically, I have two ultrasonic sensors, one on the front left and one on the front right of my robot. I want to use them to align with the wall a certain distance away in order to not run into balls. What is the best way to “square up” with the wall with ultrasonic sensors? And how do I do it? I’ve never use ultrasonic sensors before and thought I’d give it a go.
With the untrasonics if you position them right you can get the distance to the top slither of metal on the permieter. They don’t work amazingly off the transparent part, so you have to be careful with placing them, and you have to take into account that they aren’t perfectly accurate. A tried-and-tested method of squaring up is to just drive into the wall for half a second, which does a decent job of straightening out the bot : )
You see, I used to just drive into the wall but balls would get in the way. I also tried to eliminate the issue by using. Bumper switch alignment system, but I continued to run into the same issue. Would you have any other suggestions rather than the ultrasonic sensors to eliminate this issue?
Maybe try and alter whatever part of your auton causes balls to roll in front of the wall
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: