# Difference between revisions of "Turns & Rotations"

In NetLogo, it is very hard or rather impossible to visualize the proper rotations of the window cleaning robot during its motion and subsequently end up at exactly the right position. Therefore it was decided to not visualize the rotations, but instead, the turning movements are modeled by letting the robot ’teleport’ from the place before to the place after the turn. The time it takes to make a certain turn is then simply added to the time instance before the rotation. In this way, it is still possible to model the turns and rotations of the window cleaning robot in a realistic way. The question becomes then what will be the time that each specific turn takes? To give realistic values for this, the characteristic rotations and turns of the window cleaning robot are studied. In total there are six different turns or rotations which the window cleaning robot should be able to make. They are schematically shown in the figure below.

The first turn the robot should be able to perform is a pure rotation (Figure 2.a). This motion is very often needed during the robot’s cleaning job. To assign a time to the rotation, two parameters should be known: the angle to which the robot is currently heading, the angle to which the robot should head and the rotational speed of the robot when it is rotating. In reality, the robot knows how it is oriented by means of gravity sensors and thus knows the angle to which it is currently heading. Therefore it seems appropriate to use the angle at which the robot is heading in NetLogo as the current angle. The time it takes to perform a pure rotation can then be calculated by means of the following equation:

where t(rotation) is the time it takes to perform a pure rotation (s), w is the angular velocity of the robot (°/s) and Δa is the angle over which the robot should be rotated to face the upper edge of the window (°) (the angle to which the robot should head). The angular velocity of the robot is determined by using its speed and its dimensions:

where v is the speed of the window cleaning robot (m/s) and r(track) is the distance from the center of the robot to one of the crawler tracks. The value v equals 0.1 m/s which is determined by looking at a comparable window cleaning robot (WINDORO) while r(track) is estimated to be 0.09 m.
Another important motion of the window cleaning robot should be performed when it is for example in the upper left corner with its cleaning section headed to the window edge. The robot has to perform the motion that can be seen in Figure 2.b. First, it has to drive backwards to a position where it is able to turn. Since the robot has dimensions of 25 x 25 ""cm"" the distance from the upper edge that is needed to do a rotation can be simply calculated with use of the Pythagorean theorem:

Where s(turn) is the distance from an arbitrary edge of the window that is needed to do a rotation (m), w is the width of the window cleaning robot (m) and h is the height of the window cleaning robot (m). Because the robot moves over an arc, calculating the distance that it travels is very hard analytically. Therefore a MATLAB script has been written to calculate the length of the arch over which the robot is moving numerically. One important decision that has been made in the script is the distance between the edge of the robot and the edge of the window in the starting position. There needs to be a little distance between them in order to allow the robot to turn to move away from the edge. The further the robot moves away from the edge, the more it can turn and the faster it can get away from that edge. This means that the distance between the edge of the window and the robot has a huge influence on the time it takes to move away from that edge, as well as the distance traveled in the direction parallel to that edge. In the script, the distance between the robot and edge of the window is assumed to be 5mm. Running the script with this value yields a traveled distance s(arc,corner) of 0.33 m. Assumed in this calculation is that after making the bend, the robot has an angle of 45° with the vertical. Subsequently, the window cleaning robot has to do a pure rotation over 180° to make sure its cleaning pad will face the right side of the window after the entire movement. To calculate the time that this rotation takes, Equation 3.1 can be used again. Eventually, the robot moves again back to the left upper corner of the window over the same arch as mentioned before.
Hence the following expression for the time of the entire movement is obtained:

where t(turn,corner) is the time it takes to perform the motion depicted in figure 2.b (s) and s(arc,corner) the length of the arc over which the window cleaning robot has to move in this motion (m).

A third motion that the robot should perform is the turn at the top of the window, see Figure 2.c. This motion is needed to orient the robot parallel to the upper edge of the window. Because of this turn, the robot is able to move eventually to the upper left corner. To achieve an expression for the time it takes to perform this motion, the movement is split up into three consecutive phases. The first phase consists of the robot simply driving backwards till it has enough space to do a rotation. This distance can again be calculated with Equation 3.3. The second phase of this motion consists of a pure rotation over 45°. The time this rotation takes can again be calculated with Equation 3.1. In the third and last phase of this particular movement the window cleaning robot should make a turn till it aligns with the upper edge of the window. The length of the arc of this motion is the same as s(arc,corner) which is already determined by using the MATLAB script. Hence the following expression is obtained for the time of the entire movement at the top of the window:

where t(turn,top) is the time that the movement at the top takes (s).

Another characteristic movement of the robot is changing from row to row. Since this movement is dependent on the location of the robot it is split up into two cases. The first movement case is when the robot is located in a corner (see Figure 2.d). The second movement case is when the robot is located anywhere between two corners (see Figure 2.e). In other words it touches only one side edge of the window. The former case will be discussed first. Note that in both cases it is assumed that robot faces the edge of the window that is the furthest away with its cleaning pad.

When the robot is located in a corner, it first has to move out of the corner to create space to perform a turn. It has to travel again the distance s(turn,corner) that is calculated with the MATLAB script as mentioned before. After this bend, the robot makes an angle with vertical of 45°. To move down the robot heading should be perpendicular to the upper edge of the window, so it rotates another 45°. Now it is able to move vertically down to the next row that should be cleaned. The vertical distance s(changerow) of this is also determined by means of the developed MATLAB script and equals 0.2 m. The next part of the motion is again a pure rotation, but now over 90°. After this, the robot’s heading is again parallel to the upper edge but in a different row. Hence the expression for the time that is needed to change row when the robot is located in a corner is as follows:

where t(changerow,corner) is the time needed to change row when the robot is located in a corner (s) and s(changerow) is the vertical displacement the robot should perform to get to the next row (m). The second case happens when the robot only touches one of the side edges of the window. The motion that it should perform in that instance is quite simple. First, the robot has to move the distance s(turn) away from the edge to create space to rotate. Next, it rotates over 90° and moves 0.25 m down to go to the row below. After that, it should rotate again 90° to face the other side edge of the window. The time that this procedure takes is then as follows:

where t(changerow,normal) is the time to change row when the robot is not located in a corner at the beginning of the motion (s). The last characteristic motion of the window cleaning robot is its turning motion at the end of each row (see Figure 2.f). This motion is, of course, necessary in all algorithms since remaining stripes should be wiped away, or because the row is simply not clean yet. It consists out of three phases. First, moving away a distance s(turn) from the edge of the window to enable the robot to rotate. Second, a pure rotation over 180° and third, a movement back to the edge of the window (again over distance s(turn)), but now facing the other side of the window. Hence the equation for the time of this motion becomes:

where t(turn,row) is the time it takes to turn the robot to the other side of the window when it is at the end of a certain row (s). As mentioned before, the equations above are implemented in NetLogo to model the times of the rotations. The rotations itself are not explicitly made visible, but the robot is ’teleported’ from its location before to the location after the turn.