Open CaptainBrexit opened 4 years ago
Currently, none of the listed ideas, tested or untested, have been implemented, so code has not been changed
Untested Idea No. 4: If the robot detects white to both the left and right of it at the same time, have it simply turn left or right. For the completion, this would be needed for the second T-junction. If at this T-junction, we make the robot turned right when it detects a line on either side, it would pass this obstacle with ease
Implemented Changes: 1: Changed the default speed of motorR and motorL from vRight and vLeft to vRight - 10 and vLeft -10, so the robot takes corners more slowly and doesn't zigzag on straight lines immediately after corners
Unsure of how to implement this, but an idea could be to try and have the robot stop whenever it needs to turn, ie have it travel in a straight line, and then when it senses a corner (like the first corner), have it reach the corner, stop, and then pivot on the spot to turn corners. This might not be something to implement immediately, but would look nice on the finished product. It could help the robot follow the lines more closely
Current Problems: 1: When the robot reaches a dead end, it continues in a straight line. 2: When the robot passes the reaches the first T-junction, it approaches on an angle, meaning the white pixels are detected in an incorrect position, so the robot does not turn.
Tested Ideas: 1: Decrease the speed of the robot both in a straight line and around corners, so it does not turn corners as sharply, which was causing the robot to turn left and right on a straight line, as opposed to simply travelling forwards. Decreasing the speed made the robot take the corner more slowly, and stopped the side-to-side movements on a straight line.
Untested Ideas (Either haven't tried or tried but couldn't get working): 1: Create a loop for detecting a when no white pixels are on the screen, so when the robot reaches a dead end, it rotates 180 degrees on the stop, and continues in the opposite direction. (Couldn't figure out how to create a loop for detecting a lack of white pixels. Tried using 'if (whiteCount ==0)' and 'if (averagePos == 0)' both before and after 'else if (whiteCount != 0)' loop)
2: Increase the sensitivity of the loops detecting pixels to the side of the robot, so that when it reaches the T-junction, it turns to follow it instead of carrying on past it. (Tried editing values for detecting white pixels to the side, but don't understand the code enough to know exactly what's detecting what. This also relies partly on the previous issue, as the first time the robot Reaches the T-junction, it is on an angle, so the detection method may not function the same as if the robot reached the T-junction head on.)
3: Move the detection array closer to the robot and make it smaller, so that it follows the line more accurately. Currently, when the robot reaches a corner, it turns when the detection array detects a change in where the white pixels are, and begins turning before the robot itself reaches the corner. This means it cuts the corner, and takes some time to correct itself to going straight along the line, which is interfering with the detection of the T-junction. Moving the detection array closer to the robot means the robot would be closer to the corner when it turns, and wouldn't cut the corner, meaning it would continue straight along the line, as opposed to cutting the corner and ending up on an angle. (Couldn't find where the position of the detection array was, so couldn't change its size/position. Tried changing columnLeft, columnRight and fovArraySize, but none changed the size or position of the detection array)