If you get to a solution that is too complex you should always try to improve it. This is what we are doing here. Arriving at a solution for aligning to the wall that has become too complex.
- 14 Nov 2015
We are trying to show you the process of developing the programs. Not just the final programs. We think that this gives more value instead of providing a final solution (that is of course available in some of the next episodes from the series)
Previous video tutorials:
Previously we stopped at a program that was trying to align to a border. If we start it from here, it stopped. If we start it from here, it again stops. In this video we'll continue the program, so that it actually aligns the robot to the border.
Looking at the program it seems that it's getting quite complex, but nevertheless we'll continue with this program and in some of the next videos we'll look for ways to improve it. But for now this is the logic of the program. We move with motor A and D forward, we detect with the sensor on port 4 that we've reached a border and we stop. After we stop we must do the following thing. We would move motor A, just forward and this is our right motor, because this is our left sensor, the sensor on port 4 and this is our right motor, we'll turn it forward slowly, not very fast,
until the other sensor detects the wall, it's the ultrasonic sensor, compare, distance in inches, we need something that is less than or equal to 4 inches and then we stop with motor A.
The other case when sensor on port 4 is not detecting the wall. This is the other case and only the sensor on port 1 is detecting, we must do the following thing but for the other sensor. The same thing but for the other sensor. We would start, this time we start motor on port D very slowly, forward, with a power of let's say 15 until the sensor on port 4 detects a border at a distance of 4 inches, then we stop with the motor on port D.
I would have to zoom out here to have more space.
We just stop the motor on port D.
The program is getting quite abstract. we have 2 switches with 2 states and with different motors turning in different times, but let's check if it behaves as we would expect. Position the robot and I'll run it.
Let's try the program from the other side.
Something happened here but it was not quite correct. The program is not behaving as we would expect. Now that's a problem and it's a problem of the program that we are building because the program is getting quite abstract with a few blocks, distributed in different places and most of the students find it difficult to understand initially programs with such complexity, so what I would like to do is to move to a program that's more clear and look for ways to make the program more clear. The moment you see so many ifs, and so many blocks, and so many states, this means that you are doing something wrong. Let's look at the program in the next video and look for ways to improve this.