Week 8 – Josh

Today we were given a challenge with the ultrasonic sensor that would prepare us for the rescue challenge.  The ultrasonic sensor would be used when we are attempting to push the can out of the zone.

Pseudocode written for challenge:

  1. The robot will stop on the aluminium foil.
  2. Turn ultrasonic sensor on and detect objects within 50cm
  3. Turn left for 360° continuously.
  4. If no object found move forward 5cm
  5. Repeat steps 3 and 4 until object found.
  6. If object is found stop.
  7. Continue moving left until sensor loses object then stop again.
  8. Determine the distance between the 2 stops then divide the rotations by 2.
  9. Turn right that amount of rotations.
  10. Move forward for 10 seconds.

This challenge was extremely difficult and challenging.  We had lots of hiccups and problems.

Fig 1. problem with the sensors massive FOV

The first and main problem that we had was the ultrasonic sensors FOV (Field Of View).  So that when the can was further away the sensor was picking it up a way before it was aligned straight with the robot.  So that that when the robot moved straight it missed the can.  This diagram shows what the problem would look like. Fig 1.

Fig 2. My end code is where it uses variables and maths to find the dead centre.

We eventually came up with the idea that if we used a variable we could calculate how far the distance is from when it picks it up (1) ,to when it loses it (2), then it goes back halfway (3).

 

 

Sometimes it doesn’t pick it up a circular object very well because the sound bounces off but more often than not it still works really well.

Other problems we encountered included the robot not going quite straight but if you started slower it didn’t jolt as much.  With other little fixes of bugs along the way I finally had a working product.  The code follows my pseudocode and after weeks of work it works like a charm.

Here is a video of my code detecting and pushing the can out.

Our Mindstorm adventures continue…