Week 8 – Brayden

This week we were asked to write piece of code to detect the can in the green area and push it out of the ‘chemical spill’. The Mindstorm would then move towards the can and push it out of the green area. This is my pseudocode which is what I have used to design my code:

Pseudocode

  1. When the mindstorm reaches the green area it will stop
  2. Rotate left until can is detected
  3. Continue turning left until can is lost from sight
  4. The robot will be measuring the distance it turns to find the width of the can
  5. Halve the degrees measured and turn right that many degrees to find the centre of the can 
  6. Move forward

Trying to create the code to solve the challenge was extremely hard. It took us two weeks to completely write it and make sure there were no bugs in it. In my code I made many alterations as I had multiple bugs. These were things like rotating in the wrong direction and the speed of the Mindstorm. My most prominent problem was when I had wrongly coded my robot to measure the width of the can and then turn left half of that number of degrees where it should have been turning right. Here is my working piece of code:

My code to save the can in the rescue challenge

Here is a video of my code in action:

When creating this piece of code we had to use data operations blocks ( The blocks with red along the top) to measure the degrees from when the Mindstorm found the can to when the Mindstorm lost sight of the can and then divide that amount of degrees by two to find the exact centre of the can. The Mindstorm would then continuously move forward and push the can out of the green area. It was a relief after finding that my code had finally worked. One thing that I will find difficult is if the can is positioned directly in front of the Mindstorm when it reaches the green area.