Wall Following Ultrasonics

We are trying to us ultrasonics to follow the side barrier on the field by a set distance. We initially created a basic program using if statements to drive and turn based on the distance from the wall and gyro heading. Does anyone know how we would be able to implement PID or some other sort of closed loop control to follow the wall? Do we need to use multiple ultrasonics? Is the gyro necessary? Or is there a different method for maintaining a set distance from the wall that you would recommend?

Any help or suggestions would be appreciated.

I’m not sure about PID loops, but from what I know if you want it done accurately a gyro+ultrasonic or two ultrasonics is your best bet.

For other people who know more about PID loops than me, it would probably be helpful if you shared your drive base type.

We are using 6 traction wheels That are belt driven on the bot we are developing the code for. However, our competition bot will be 6 pneumatic tires using chains

I also believe that one of these two configurations are probably enough to achieve what you guys are trying to do. But I recommend 2 ultrasonic configuration as gyros tend to drift over time and if you are going to use this in tele-op, relying on a gyro might cause a problem near the end game.

Back when I was on VEX, we ran PID on two ultrasonics as well as PID on the drivetrain. If I were doing it today, I probably would use two ultrasonics, a gyro, and drivetrain PID since that accounts for if something fails. The most important thing was drivetrain PID since it was virtually impossible to try to drive in a straight line under bang-bang control.

I tried this last year, keep in mind it was our rookie year, so my failure was due to inexperience, lack of time, and lack of more resources to throw at this. We used just one ultrasonic sensor, and that does not work.

The problem with only one ultrasonic sensor is that it has no idea the angle of your robot to the wall. Imagine the robot parallel to the wall, ultrasonic sensor sitting in the center of your frame pointed at the wall. The distance measured is perhaps 20 inches. Lets say you want 10 inches, so you must turn towards wall. As the robot turns towards wall, the ultrasonic sensor also turns, no longer pointed directly at the wall at a 90 degree angle, but instead at some other angle, say 135 degrees. Even if your robot hasn’t moved forward at all during this turn, the ultrasonic sensor now thinks its about 28 inches from the wall, and try’s to turn even harder towards it.

If I were to try again, I would use a gyro, or two ultrasonic sensors, one on the front and one on the back.

I would highly recommend just using odometry and encoding your drivetrain. But with that being said, it seems like you would want to input the ∆ between the two sensors into the PID loop and adjust heading left or right based on which is greater. you could then tune the PID loop to get the output as close to ultrasonic A equaling ultrasonic B as possible. That’s basically how I would do it. Good luck!

This seems like the hardest part to me.

If you have two sensors (front and back), placed symmetric distances from your center of rotation, you may be able to take their average, and the rotational effects would be canceled out?

The cheap ultrasonics tend to be fairly noisy - could cause more issues.

As far as control strategies go - Lego League bots seem to use lots of bang-bang control of a rotation command (combined with a fwd/rev command). I’d be willing to bet a P controller might work better, but have no experimental experience to say for sure.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.