By Manit
For Some of our runs, we need to be aligned with a landmark (the black line) because the measurements wouldn't always be completely accurate. So, I referenced a NXT program that would align to the black line and modified it into a EV3 program.
First, I have the robot reset. All the large motors and the gyro sensor are set to zero. Then, I have the B motor move until the port one sensor senses the black line and C motor move until the port three sensor senses the black line using two threads. While this is happening, I am giving a variable the value of zero. This variable will be used to record which sensor found the black line first.
Next, in each thread, I compare the variable value to zero so we could see if the value that we gave has changed or not. If the value has not changed, we give the sensor’s port number as the variable value. This way we have recorded the port number that found the line first.
One more thing. Because of inertia, any one or both wheels sometimes stops after a few amount of degrees from the black line. So, I have the both large motors rotate forward fifteen degrees and then move backwards with the power of five until the sensors find the black line. Because of reduced power, there is no impact of inertia.
When sensors sense the black line while travelling forward, during the adjustment to get the second sensor on the black line, the first sensor would pass the black line by ten degrees. So variable value determines the port number and hence the motor that will move back extra ten degrees.
First, I have the robot reset. All the large motors and the gyro sensor are set to zero. Then, I have the B motor move until the port one sensor senses the black line and C motor move until the port three sensor senses the black line using two threads. While this is happening, I am giving a variable the value of zero. This variable will be used to record which sensor found the black line first.
Next, in each thread, I compare the variable value to zero so we could see if the value that we gave has changed or not. If the value has not changed, we give the sensor’s port number as the variable value. This way we have recorded the port number that found the line first.
One more thing. Because of inertia, any one or both wheels sometimes stops after a few amount of degrees from the black line. So, I have the both large motors rotate forward fifteen degrees and then move backwards with the power of five until the sensors find the black line. Because of reduced power, there is no impact of inertia.
When sensors sense the black line while travelling forward, during the adjustment to get the second sensor on the black line, the first sensor would pass the black line by ten degrees. So variable value determines the port number and hence the motor that will move back extra ten degrees.