# #Robotics Finding objects with an Ultrasonic sensor

This is almost the final article explaining the techniques to handle the challenges your robot will face during the line rescue division of Robocup Junior Australia competition.

Your robot should now be able to navigate all the way through the course following the line and handling intersections and obstacles in its path. The final part of the challenge is the rescue and this article discusses the first part of the rescue process…. finding the victim.

This article is focused on finding a victim (375ml aluminium drink can weighted to 100 grams covered in shiny aluminium foil or tape) in the Robocup Junior Australia line rescue challenge, but the techniques can be used whenever you want to locate an object with the ultrasonic sensor.

It is important to understand that the ultrasonic sensor does not fire a straight beam of light like a laser, but instead uses a cone of high frequency sound waves. When it detects waves reflected back from an object, it can use the delay in the returned signal to work out the distance travelled to and from the object based on the speed of sound in air. It can then halve this to get the distance to the object.

Because the range is a cone, our robot will not be directly pointing at the object when it first detects it. To ensure our robot is looking directly at the object we need to be a bit smarter with our detection process.

Note: You will need to know how many degrees the motors of your robot need to rotate through to move forward 10cm. You can get this by marking 10cm on paper and manually rolling the robot forward while getting readings from the rotation sensors. You can then divide this value by 10 to get the number of degrees you need the motors to rotate to move the robot 1cm. This movement factor is used in Step 9.

Below are some example steps for detecting the victim in the green rescue zone (chemical spill):

Step 1: Line follow until you detect the silver strip, then stop

Step 2: Move forward into the middle of the rescue zone, then stop

Step 3: Rotate on the spot until facing just before the entrance to the rescue zone

Step 4: Start slowly rotating back looking for an object to be detected by the ultrasonic

Step 5: Continue scanning until an object is detected, then reset a motor rotation counter

Step 6: Scan until the object is no longer detected, then read motor rotation counter

Step 7: Divide the motor rotation counter by 2 and rotate back half the distance

Step 8: You might need make an adjustment if the robot is always off centre the same way

Step 9: Now you can measure the distance to the object and move forward to the object

Notes:

• Make sure you are setting the ultrasonic range long enough to look into the corners of the rescue zone.
• Don’t set the ultrasonic range too long as it will pick up obstacles or people’s legs outside of the rescue zone.
• Test with the victim in as many positions as you can.

See the next article for more information completing the rescue for primary, secondary and open divisions.