Friday, October 31, 2014

More About Sonar Sensors

Unfortunately, further tests with multiple sonars show that the sonars have a lot of errors, mostly when not pointed directly at a flat surface. That is, if the angle of the sensor to a wall is close to the normal, the sensors are quite accurate. As the angle from normal increases, the incidence of spurious large distances also increases.

As well, there appear to be false echoes off the ground – since my robot has little ground clearance – when the actual distances increase. You can see that from this graph, which shows sonar distances while the robot is moving. The robot path is shown as the blue plot. The sonar positions are left-side (about 80° to the left of straight ahead), left-front (about 10° to the left), right-front (10° to the right), and right-side (80° to the right).



Friday, October 17, 2014

Sonar Measurements While Moving

I've been worried about two things regarding the sonar sensors, HC–SR04 units:
  • The sonars may have a lot of variance in their measurements, according to reports on the web.
  • Measurements from the sonars may be affected by movement, or by noise from the motors.
So I wrote a program to capture one sonar distance as the robot moved, and captured the robot position and sonar distance periodically. The result was surprisingly accurate:


The wall distance before about 3 seconds was from an intermediate obstacle to the left. Robot distance traveled is based on the wheel encoders, which have 30 segments per revolution, about 7mm per tick. The wall distance was measured by an HC–SR04 sensor pointing forward.

I was expecting a lot more variation in the sonar sensors (distance to wall). The actual values are accurate enough that little smoothing or filtering may be necessary. There are more wiggles in the speeds, because I calculated those based on measurements in the interval, 1/4 second.

Further Questions

Do the sonar sensor readings have more variance if the wall is at an angle?

Do the sonar sensors interfere with each other if they are fired close together?

Is there electrical noise from firing the sonars that interferes with the measurements?

Friday, October 10, 2014

More About Odometry

A few weeks after I had the odometry working, I found that the robot started veering off course, and it wouldn't follow waypoints as accurately. I was adding sonar sensors at the time and was worried I was getting noise from all the additional wiring. So I researched a little more and experimented with a pull-up resistor instead of a pull-down.

The old wiring:


With the pull-down resistor, the analog reading on pin A0 ranged from about 30 (black stripe) to about 150 (white stripe), enough to distinguish, but not high enough to use a digital input.