Lesson 10: Basics of Robotics

Lesson Description

In this lesson, you will learn about robots, their advantages, applications, and how to program a robot to move forward, left, right, and back. You will also learn how to wirelessly control a robot.

Introduction to Robotics

A robot, in simple words, is any machine designed to carry out a task. This would make you say, “So, a calculator, a PC, a vacuum cleaner – all these are also robots?” Not exactly. Robots are machines that use programming to make decisions and carry out tasks.

For e.g. a screwdriver is a machine because it carries out the task of fastening a screw, and reduces human effort. But it is not a robot. If we combine it with a robotic arm, then the entire thing can be called a robot.

Advantages of Robots

  1. Robots never tire. They can work at the same speed with the same consistency without any breaks or holidays.
  2. They are useful when you need to perform a particular task over and over again without getting bored. This enables us to utilize our full potential in tasks that can only be done by humans.
  3. Robots are quick. They can do a lot of work in a short duration of time. This, in turn, helps save time.
  4. Since robots can do a greater amount of work in a shorter duration, the overall output increases.
  5. Robots can be used to perform tasks that would be dangerous for a normal human being. They can also work in hazardous environments without the fear of any damage.
  6. Robots can perform tasks with greater accuracy and quality than humans.

Applications

We can find robots in a multitude of fields – right from cleaning your home to celebrating birthdays on Mars. Jokes apart, in the modern world, robots have found a place in almost every field. Some of their endless applications are given below:

  1. Industry: For handling and moving materials from one place to another, and for other purposes such as painting, manufacturing, welding, etc.
  2. Space: For exploring outer space. E.g., the Curiosity Rover
  3. Hospitals: Surgical robots, rehabilitation robots, pharmacy robots, etc.
  4. Transportation: Self-driving cars, transportation of goods and services, etc.
  5. Agriculture: For tasks such as vegetable and fruit picking.
  6. Military: Bomb discarding robots, drone explorations, etc.
  7. Households: For cooking, cleaning, and washing purposes.
  8. Entertainment: Humanoids, robot dogs, mobile phones, computers, etc. E.g. Aibo the robot dog.

Activity 1: Making Quarky Move

Make your robot move forward, left, right, and back.

Coding Steps

Follow the steps below:

  1. Open PictoBlox App, go to My Space, and click on + button to create a new file.
  2. Connect Quarky to PictoBlox.
  3. Forward Movement: Let’s make the script for the robot to run the robot forward for 1 second and then stop. If both the wheels of the robot rotate in the forward direction, then it will move forward. That makes sense, right?
    1. First, go to the Robot palette and add the run () motor () with () speed Select the left motor, the forward direction of motion, and 100% speed are set as the default values.
    2. Now, copy the run () motor () with () speed block and add it below the first one. Select the right motor from the dropdown.
    3. Next, add a wait () seconds block from the Control palette and set the waiting time as 1 second.
    4. Drag and drop the when flag clicked block into the scripting area from the Events palette.
    5. Next, add a stop () motor block from the Robot palette below the wait () seconds block and select left as the option.
    6. Next, add another stop () motor block from the Robot palette and select right as the option.
    7. Now, run the script by clicking the green flag.
  4. Backward Movement: If both wheels rotate in the backward direction, the robot will move backward. Let’s convert the above script to make the robot run backward for 1 second and then stop.
    1. Change the direction in the first run () motor () with () speed block to backward. This will make the left motor go backward.
    2. Change the direction in the second run () motor () with () speed block to backward. This will make the right motor go backward.
  5. Left Movement: Making the robot turn left and right is the tricky part. To make Quarky turn left, its right wheel should rotate in the forward direction but its left wheel should rotate in the backward direction. Let’s convert the above script to make the robot run to the left for 1 second and then stop.
    1. Change the direction in the first run () motor () with () speed block to backward. This will make the left motor go backward.
    2. Change the direction in the second run () motor () with () speed block to forward. This will make the right motor go forward.
  6. Right Movement: On the other hand, to make Quarky turn right, its left wheel should rotate in the forward direction and the right wheel should rotate in the backward direction. Let’s convert the above script to make the robot run to the left for 1 second and then stop.
    1. Change the direction in the first run () motor () with () speed block to forward. This will make the left motor go forward.
    2. Change the direction in the second run () motor () with () speed block to backward. This will make the right motor go backward.

Activity 2: Wirelessly Controlled Robot

Make your robot move forward, left, right, and back with keys.

Logic

We’re going to control Quarky wirelessly using the arrow keys of the keyboard of your desktop/in the PictoBlox mobile app.

  • Using the up arrow key, we will make Quarky move forward.
  • Using the down arrow key, we will make it move backward.
  • Using the right arrow key, it will move right.
  • Using the left arrow key, it will move left.
  • When none of the arrow keys is pressed, Quarky should stop moving.

Coding Steps

Follow the steps below:

  1. Open PictoBlox App, go to My Space and click on the + button to create a new file.
  2. Connect Quarky to PictoBlox.
  3. We want to ensure that Quarky moves forward only if the up arrow key is pressed. To check if it is pressed, we’re going to use an if block. Go to the Control palette and drag and drop an if-else block.
  4. Now, go to the Sensing palette and add a key () pressed? block inside the diamond-shaped space of the if block. This block will check if the selected key is pressed. The up arrow key is the default option.
  5. Go to the Robot palette and add a go () at () % speed for () second block inside the if block. Now, we need to do the same for the remaining three directions.
  6. Duplicate these blocks by right-clicking the if-else block. Then, in the key () pressed ? block, change the key to down and in the go () at () % speed for () second block, change the direction to backward.
  7. Repeat step 6 two more times for the remaining two directions.
  8. Now put the stop robot block in the last else branch.
  9. Complete the script by adding a forever & when flag clicked blocks at the top.
  10. Now, run the script by clicking the green flag.
  11. Save the file with the name Wirelessly Controlled Robot.

Activity 2: Output

Make sure you finish and submit the assignment, as well as take the quizbefore moving on to the next lesson.

Table of Contents