Brayden – Week 11

This week in robotics class we decided to put two colour sensors on the Mindstorm. We decided to do this so that we could detect the green squares (hints) and use them to turn in the correct direction. To start the lesson we watched a video on YouTube to show us a piece of code that we could use to programme the Mindstorm. After writing this piece of code we then tried it out on the course. No ones worked due to the fact that the turning speed was far too low. Before we amended our speeds we decided to use variables (red blocks) to make it easier when we are changing our speed in our code. We tried this again and it worked. After revising our code so that it worked we decide to start ‘tuning’ our code. This meant we started trying various speeds and turning speeds so that we could have the fastest working robot. While we were tuning our speeds we agreed to move the two colour sensors closer together to see what difference doing that would make. It had a huge impact on the success of the Mindstorm. Causing it to lose the line at some speeds and perfecting other speeds. Here is my piece of code:

My code to use with two colour sensors

We will continue to tune and improve the performance and success of the Mindstorm by using the two sensors. Although we did not get to programming the Mindstorm to detect the hints, next week we will use the colour sensors to detect the green hints and turn in the direction of that specific hint.

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.

Week 7 – Brayden

This week in robotics class we began to use the ultrasonic sensor. The ultrasonic sensor uses sound waves that are at a higher frequency than human beings can hear to detect and measure the distance to an object. We began the session by taking on a challenge in which we had to use the ultrasonic sensor. For this challenge we had to programme the mindstorm to move until it was 20cm away from a wall. We achieved this task fairly quickly.

My code for the first ultrasonic challenge.

After completing this challenge we moved on to a second challenge in which we had to programme the mindstorm so if it was closer than 20cm to an object it would move backwards and otherwise move forwards. This was called ‘Using the Force’.

My code for the second challenge

We then attempted one final challenge for which we used the same code as challenge 2 but if the Mindstorm was between 15-20cm it would ‘rest’ and stop. In this challenge we were ‘Mastering the Force’.

My code for ‘Mastering the Force’

While completing the challenges this week we noticed some discrepancies in the comment blocks of the challenge solutions.

Week 6 – Brayden

This week we completed two line following challenges using the colour and touch sensors. At the start of the lesson we were given a challenge where we had to programme the Mindstorm to follow the right side of a line.

This had to be completed by programming the mindstorm to ‘zigzag’ across the edge of the line by using a switch in the code.

We used the switch to determine whether the Mindstorm was on the black line or on the white of the track. If it was on the black it would turn slightly to the right and move in that direction. If it was on the white it would turn slightly to the left and move in that direction. This would cause the Mindstorm to cross back and forth over the edge of the line. At first there were a few bugs in the code but after some alterations to the code we all achieved this.

My Line Follower Challenge 1 Code (Explanation in the blue comment blocks)

We then attempted another challenge. In this challenge we had to use the code we had just created and alter it so if the touch sensor was pressed the Mindstorm would stop moving. We achieved this challenge fairly quickly.

My Code for the Line Follower Challenge 2

I am looking forward to testing my coding knowledge in future weeks.

Week 3 – Brayden

This week during robotics class we began learning about pseudocode. To start with we discussed what pseudocode is. Pseudocode is detailed notes that are not in a specific language that a programmer can use to communicate their plan with others and review later to write their code. To learn this we looked at an example of students trying to write instructions to make a peanut butter & jelly sandwich which was then given to their teacher to follow. The 3 students who wrote the instructions did not write them very clearly which caused their teacher to fail at making a PB&J sandwich. After we looked at this example we moved on to attempting a challenge. For this challenge we had to make a robot go around in a square.

This is the pseudocode for the challenge:
Step 1: Move forward 4 wheel rotations
Step 2: Turn left 90 degrees
Step 3: Repeat steps 1 and 2 three more times

This may seem like an easy task but it was very difficult to get the correct amount of degrees to turn. After many attempts we decided to use port view to find the correct amount of degrees to turn. This is my loop of code that I used to complete the challenge:

We were then shown some pseudocode which we had to use to work out what the proper code would do.

Week 2 – Brayden

This week  during robotics class we started basic programming of the  Mindstorm robot. We completed a challenge where we had to programme the robot to move straight to a green line and back to a black line. When we first attempted this we programmed the robot to move forward for 1.75 seconds at full speed, and then back at the same speed and for the same length of time. We then tried the task again, but this time we had to work out the amount of degrees the wheels had to turn to reach the green line, and then get back to the start. We did this by using the motors. For the final part of the challenge we had to work out how rotations of the wheels would it take to reach the green line and then back again. We did this by dividing the amount of degrees this would take by the amount of degrees in a circle (360) to get our answer of 3.536111… rotations. We then programmed this to make the robot go to the line and back. Here is my programme:

My Code

After this fun challenge we began using the colour sensor to make the Mindstorm stop when it ran onto the colour green. We experimented with this by using different shades of green. To start with we tested this on a printed shade of green on the line follower track. We used a Lego piece to see if it would work better, after we found out that it only worked one time on the printed shade of green. The piece of Lego we used worked indefinitely better as it worked every time. It was interesting because we tried to create a shadow over the green on the track so it would appear to be a darker colour. In the end this had no effect on the results.

During next week’s session we are going to explore the abilities of the colour sensor to a further degree.

Week 1 – Brayden

During robotics class last week we bought a .space domain. We bought this domain so that we could document what we are completing each week and the projects we work on, because at the RoboCup competition they will ask you what you and your team have learnt, and the projects you have completed preparing for the competition. By using this domain we are learning the fundamental components of WordPress; which is what we are using to manage and build our domain. This week we installed the Lego Mindstorms EV3 software so that we can program the Mindstorms robot. During the session we observed the EV3 line-following software and how it uses programming blocks. We also tried moving the colour sensor closer to the centre in front of the robot and closer to the wheels to see what difference it would make, and how it would affect the robots ability to stay on the line and manage the sharper turns.