MyRaspberryAndMe

Tinkering with Raspberry (and other things)

Pi-Hicle part 4 – Sensor Phalanx

4 Comments

I finally had the time to do some more work on my Raspberry Pi controlled Big Trak. So this is all about sensing the environment, well, avoiding obstacles, that is.

My idea is to have the vehicle measure the distance to any obstacles in front and to both sides. If it can’t move any further in forward direction, it will be turned in the direction (left or right) where there is the biggest distance to any obstacles. Very simple but that should be very effective. And it gives the impression of “real autonomy”, because the vehicle will turn in different directions to avoid a collision.

To get this done I ordered three Sharp GP2Y0A02YK0F distance sensors. They are well documented and used by many people out there, so I thought they should do for me, too. The sensors translate the distance into a voltage, so there is an analog value to be mapped to the distance. There is a data sheet with a nice graph showing the expected output voltage oder distance. According to the specifications the sensor has a range of 20 to 150 cm. That quickly proved to be a little too optimistic…

I started with making my own measurements. Therefore I constructed a “sensor housing” made of cardboard and hooked it up to an Arduino to take some measurements. The housing has the exact dimensions and angles of the Big Trak to get reference values to be used with the sensors attached to the Big Trak chassis. At first I experimented with a variety of filters that I applied to the measurements, like Kalman etc. but I discovered that the filtered values did not differ too much from a simple mean value calculation, so I continued with that. Here is a picture of the sensor assembly:

mock_angle

And the Arduino taking measurements:

mock_assembly

Another interesting observation was the independence of the side sensor values from an obstacle in front of the vehicle. I thought there would be some effect because of reflected or scattered light from the front sensor. The side sensors are mounted at an angle of about 70 degrees from the front plane which means the sensor is measuring obstacles parallel to the vehicles sides’s at angle of about 35 degrees. Even this angular measurement did only have a small effect on the measured values.

So here is a graph showing the normalized output values over the distance:

distance-graph

As you can see, the sensor does not work well beyond 60 (or 70) centimeters. The error in measurement gets too big to calculate the distance. Interestingly enough, there is not much difference between a small obstacle (30×40 cm, red line) and a big one (60×100 cm, blue).

The side sensors report values that are approximately 10% higher than those of the front sensor at a given distance. That gives me enough accuracy to develop a collision avoiding algorithm. The distance of about 70 centimeters that seems to be the maximum reliable distance is no problem at this point, because from the vehicle’s point of view that is “far away”.

The algorithm will be based on threshold values, there is not enough accuracy in the data to make a more sophisticated approach: Move forward until front-threshold is reached. Stop. Take left and right measurement. Slowly turn to where there is the greatest distance until front sensor reports same value as side sensor did at stop condition. Continue driving. While driving left and right sensor values are taken and the direction will be corrected in the same way if a side collision needs to be avoided.

Advertisements

4 thoughts on “Pi-Hicle part 4 – Sensor Phalanx

  1. Interresting read, really curious as to where this build will go.

    • Yeah, I’m curious too. At the moment it seems “automatic driving” would be possible without using a Raspberry Pi. Update is coming 🙂

  2. Pingback: Pi-Hicle part 3 – Big Trak autopsy and findings | MyRaspberryAndMe

  3. Pingback: Pi-Hicle final – motor-control and autonomous driving | MyRaspberryAndMe