Chapter 16: The BOOST Humanoid

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:

Figure 16.1 – Line-following robots at a warehouse

Figure 16.1 – Line-following robots at a warehouse

In this chapter, you will do the following:

  • Build a line-following robot
  • Let's code a robot to follow the line
  • Time for a challenge

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.

Technical requirements

In this chapter, you will need the following:

  • LEGO BOOST kit with six AAA batteries, fully charged
  • A laptop/desktop with Scratch 3.0 programming and an active internet
  • One-inch-thick black tape
  • A table top with a white background

Building a line-following robot

Refer the following link for the detailed build instructions of the line-follow robot:

https://github.com/PacktPublishing/Build-and-Code-Creative-Robots-with-LEGO-BOOST/blob/main/Bonus%20Chapter/Chapter16/B17095_BuildInstructions_16_Final_NM.pdf

Your line following robot will look as shown in the following figure:

Figure 16.2

Figure 16.2

Let's now code this robot to follow the line.

Let's code the 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:

  • A plain white background
  • A properly etched black line
  • Controlled lighting conditions

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:

Figure 16.3 – Field setup

Figure 16.3 – Field setup

Let's now perform an interesting activity.

Activity #1

Write a code to follow the line for 5 seconds at 20% motor power:

Figure 16.4 – Sample code

Figure 16.4 – Sample code

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.

Time for a challenge

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:

Figure 16.5 – Route setup

Figure 16.5 – Route setup

Solve the following tasks:

  1. Follow the line until the first ball. Now, hit the ball and clear the robot's path to reach the next stop. Change the BOOST Hub color to red.
  2. Now, follow the line to the second ball and hit that ball as well. Change the BOOST Hub color to blue.
  3. Reach the stopping place and play a sound of your choice.

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.

Summary

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.

Further reading

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.31.209