Up to this point, you have built various types of robots using this book. Did you observe one thing that they have in common? None of these robots have their own eyes through which they can see and follow a specific path! Usually, robots tend to follow the line and accomplish the iterative tasks on a specific given route. Ideally, these robots are used in warehouses as well as other indoor industrial applications. You will be building a similar line-following robot using the color sensor that you have in the BOOST kit. As the name suggests, a robot will follow the black line and reach out to the required places to accomplish the tasks:
In this chapter, you will do the following:
In this robot, you will be replicating a human-like structure with legs, hands, and a head. Give this robot some cool name of your choosing.
In this chapter, you will need the following:
Refer the following link for the detailed build instructions of the line-follow robot:
Your line following robot will look as shown in the following figure:
Let's now code this robot to follow the line.
Let's now start coding this line-following robot. There are various line-following techniques, such as two-state, five-state, proportional, and proportional integral derivative. In this chapter, you will be learning the easiest yet most accurate technique – the two-state line follow. You will be using the if-else programming block from the Control pallet. For line-following robots, it is necessary to have the right environment, including the following:
Remember one thing. The robot always follows the edge of the line and not the center. Wondering why? This is because, if the robot follows the center of the line, it will miss the turns and leave the line, but if it is following the edge, it will never ever miss the turns/curves. The algorithm for two-state line following is simple – if the robot senses black, turn toward the white, otherwise turn toward the black. This will ensure that the robot is always near the edge while following the black line. Do the following setup before you start with the activities. Use the one-inch-thick tape on the white background to do this setup:
Let's now perform an interesting activity.
Write a code to follow the line for 5 seconds at 20% motor power:
You will be able to follow the right edge of the line using this code. Simply swap the motor ports in the if-else condition and the robot will follow the left edge of the line. If you increase the speed of this robot, it will wobble more and cover more distance in the same time. More wobbling is not good for line following, hence we have retained a slow speed for the robot.
Challenge #1
Attach the external motor to this robot on the top and build an arm that can hit the tennis ball. Now, perform the following setup:
Solve the following tasks:
The robot must finish this challenge accurately each time. While following the line, you must focus on accuracy instead of speed, as the most important element in such cases is the accuracy of the tasks solved, followed by time. You can play around with the speed of this robot and see how quickly you can complete this challenge with the utmost accuracy.
In this chapter, you learned about the practical application of the line-following technique and its use in industry. You wrote your own two-state line-following program and executed the same to solve various tasks. You also applied your construction skills in the challenge section to solve the challenge given. You will be able to build such humanoid robots on your own using LEGO elements on any other platform, such as EV3 and WeDo. In the next chapter, you will be building a robot with wheels and a color sensor on it that will be landing on the moon's surface for exploration purposes. You will be performing logical activities to identify the types of minerals present on the surface of the moon and grab some of these minerals.
Amazon is said to be leading the race when it comes to automation and robotics at its gigantic warehouses across the globe. Read the following article about their execution of line-following robots: https://www.wired.com/story/amazon-warehouse-robots/.
Once you are familiar with programming, you can learn about advanced line-following techniques such as five-state and proportional derivative integrals using advanced Mindstorms sets or any other open-source platforms.
3.141.31.209