Week 9 – 2019 – Oliver

This week our task was to make the robot achieve the whole course up to the can-finder. We aimed to complete the hints, the ramp and the silver – with the line follower still functioning perfectly.

My updated code…

Last week, I made a part of code that made one wheel turn backwards for every forwards turn of the other wheel. I discovered that by adding this code, I affected the turning speed of the robot. My turnSpeed variable was set to 50, which I chose because it was not too aggressive but could cope with the sharp corners of the line. However, with the sensors moved closer to the chassis of the robot, the robot made too aggressive turns to move over the hints, and the wheel turning backwards at 0.5x the speed of the other wheel didn’t help. With no hint detector in my code, the robot did 3 turns over the hint and ended up turning the wrong way.

To fix that error, I adjusted turnSpeed to 25, and decreased the back wheel turning ratio to 0.25. With this change, the robot could follow the hints.

To go over the ramp, I made a piece of code to detect when the sensors were off the mat and therefore receiving very little reflected light. I explained in my last post, as the robot goes up the ramp, the amount of reflected light drops as the sensors above the ground.

My solution to the problem was to add the reflected light values together, and deduce from that whether the robot was on a ramp, on a hint, on silver or on the line. I altered my old hint-finder in a completely new project to add the ramp.

My test code for the ramp-finder.

This is my ramp-finder test code. It found reflected light values and added them together to find the total. If the total was greater than 80, the robot outputted ‘RAMP’ and set the output variable to 0. If the value was less than 80, it would cut into my old silver/green hint-finder code, which used the Absolute Value to find the difference between numbers and deduce what colour the sensors were on and which way to turn. When I tested the program on the robot, it worked most of the time, but when I tried to incorporate it into my main line-follower, it stopped on silver and green and worked on the ramp only once out of 5 times.

Next week I need to add another part of my program to detect the difference between white and a ramp. The problem is that the code only has four switch block possibilities, as explained on this table below:

Sensor 1Sensor 2
<50<50
<50>50
>50<50
>50>50

To add in my ramp-finder code, I need to add a fifth instance to distinguish the parts of the RoboCup Jr. map that are not possible with the regular line following code. I may have to achieve this by even adding a sixth instance for hints instead of the ramp.

Useless Fact of the Day: No piece of square dry paper can be folded in half more than 7 times. If you folded a piece of paper 103 times, it would be thicker than the Universe!