vb.net read usb barcode scanner FIGURE 7.6 This routine keeps the robot on the line even at sharp turns. in Software

Paint QR-Code in Software FIGURE 7.6 This routine keeps the robot on the line even at sharp turns.

FIGURE 7.6 This routine keeps the robot on the line even at sharp turns.
QR-Code Scanner In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
Print QR Code In None
Using Barcode generation for Software Control to generate, create QR image in Software applications.
DEVELOPING A TOOLBOX OF BEHAVIORS
QR Code Recognizer In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
QR Code Creation In C#
Using Barcode printer for VS .NET Control to generate, create QR Code image in VS .NET applications.
FollowLine: while true if rSense() & 1 rTurn 1 LastTurn = 1 //remember which direction we WERE turning endif if rSense() & 4 rTurn -1 LastTurn = -1 // remember which direction we WERE turning endif rForward 2 // since we don't care if we lose the line, // move forward twice if rSense()=0 rTurn 3*LastTurn // if we lose the line make a BIG endif // turn back towards it wend Return
QR Drawer In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create QR image in ASP.NET applications.
QR Code Generator In .NET Framework
Using Barcode maker for Visual Studio .NET Control to generate, create Quick Response Code image in Visual Studio .NET applications.
FIGURE 7.7 This routine lets the robot nd the line after it has lost it in a turn.
Printing QR Code 2d Barcode In VB.NET
Using Barcode generator for VS .NET Control to generate, create QR image in Visual Studio .NET applications.
EAN-13 Printer In None
Using Barcode creation for Software Control to generate, create EAN-13 Supplement 5 image in Software applications.
In Fig. 7.6, the robot uses a while-wend loop to continue to turn as much as is necessary to stay on the turning line before moving forward. This means that the robot will not move forward until it has turned suf ciently to remain on the line. Extremely sharp turns, such as the last one in Fig. 7.1b, still present a problem, but the robot performs well in most situations. 7.3.3 A SECOND STRATEGY The second strategy is implemented in Fig. 7.7. The routine allows the robot to leave the line when it turns sharply and then reacquire it a short distance later. Once the robot loses the line it cannot use the line sensors to determine which way to turn. To solve this problem, we need a way for the robot to remember which way it was turning the last time it saw the line. This will normally be the direction the robot should turn if it has lost the line. Each time the robot makes a normal turn (the if-decisions in Fig. 7.7) the subroutine stores the turn direction in the variable LastTurn to remember which direction the robot was turning. Later in the routine, if none of the sensors are on (indicating we probably have lost the line), the robot will be able to head back toward the line. Extremely sharp turns are still a problem even for this algorithm. In this algorithm, since it is acceptable to lose the line, we can speed up the robot s progress by moving it forward 2 pixels at a time. While the robot is still over the line it will turn only 1 at a time to stay on it, but if the line is lost, the robot will take a 3 turns to help it get back on course. Notice that these choices for how much to move or turn are somewhat arbitrary. With a little experimentation, you can determine the optimum values for your situation. This reminds us again of the advantage of using a simulation. With RobotBASIC you can change the values and see how the robot responds to your changes very quickly. 7.3.4 VERY SHARP TURNS The routine in Fig. 7.6 stays on the line nicely and even handles 90 turns. However, if the line turns much more than 90 , the robot can still lose the line. There are many ways to solve this problem. Figure 7.8 shows a potential solution.
UCC - 12 Generation In None
Using Barcode creator for Software Control to generate, create Universal Product Code version A image in Software applications.
Draw Code39 In None
Using Barcode creator for Software Control to generate, create Code 39 Extended image in Software applications.
FOLLOWING A LINE
EAN128 Generation In None
Using Barcode printer for Software Control to generate, create EAN128 image in Software applications.
Barcode Drawer In None
Using Barcode generator for Software Control to generate, create bar code image in Software applications.
FollowLine: while true rForward 1 if rSense() = 3 rForward 20 //move the centre while rSense() = 0 rTurn 1 //turn back to the wend endif if rSense() = 6 rForward 20 //move the centre while rSense() = 0 rTurn -1 //turn back to the wend endif //-- reposition over the line while rSense() & 1 rTurn 1 wend while rSense() & 4 rturn -1 wend wend Return
USPS Confirm Service Barcode Creator In None
Using Barcode encoder for Software Control to generate, create USPS Confirm Service Barcode image in Software applications.
Code 128 Generation In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create Code 128C image in ASP.NET applications.
over the corner line
EAN / UCC - 14 Drawer In None
Using Barcode creator for Online Control to generate, create GS1 128 image in Online applications.
Reading ANSI/AIM Code 128 In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
over the corner line
Data Matrix ECC200 Maker In VB.NET
Using Barcode creator for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in .NET applications.
EAN-13 Supplement 5 Maker In None
Using Barcode generator for Font Control to generate, create GS1 - 13 image in Font applications.
FIGURE 7.8 This routine deals with sharp turns in a unique way, allowing it to not only handle very sharp turns, but also acquire the line if it nds it while roaming randomly.
Printing Barcode In Java
Using Barcode encoder for Android Control to generate, create bar code image in Android applications.
Encoding Code 39 Full ASCII In Visual C#.NET
Using Barcode encoder for .NET framework Control to generate, create Code 3/9 image in .NET applications.
The principle is that when one of the outside sensors and the middle sensor are on simultaneously, the robot assumes that the line must be making a sharp turn. When this situation is detected, the robot moves forward so that its center is near the point where the line turns. The robot then turns until its outside sensor nds the line again. Having done all this, the routine proceeds as before with the while-loops keeping the robot on the line in the same manner as in Fig. 7.6. When you run the program you will see that the new algorithm does in fact handle very sharp turns. You will also see that this new turning behavior happens even on moderately sharp turns, making the robot correctly follow more complex lines. However, the robot s movement is now somewhat erratic which may not be acceptable in some situations. There are many factors that can cause an algorithm to fail. The above algorithm, for example, will not work properly if the line width is reduced from 4 to 3 pixels. Any algorithm is only a potential solution until it has been thoroughly tested in a variety of expected environments. A robot s ability to perform properly depends on the programmer s ability to predict the situations the robot is likely to face. Subsequent chapters will explore this idea further.
7.4 Random Roaming with Line-Following (Racetrack)
In the previous sections we assumed that the robot is already over the line before starting the line-following procedure. What if the robot is not over the line You can test for such a situation by commenting out the rForward 10 statement in the MainProgram in Fig. 7.1a.
Copyright © OnBarcode.com . All rights reserved.