a1tD00000088IvFIAU

Course: CTE IT with Dobot
Lesson 2: Automated Tower Building

  • 9-12 grade
  • Intermediate

Lesson Description:

Learn how to build a tower with the robotic arm, store values in a variable, and use variables to increment through steps. 

image description

Lesson Modules


Teaching Tips:

Observe Module Overview:

These questions will check for understanding of basic Blockly coding, and the programming concept of variables. Go through them wilth students one by one, or allow them to work individually to answer all 4.

#1

  • It will create a box named “Z”
  • Give it the value of 10
  • Then when you to tell it to print Z it will display the value 10 on your screen!

#2

You need to tell it Z + 10

  • This will tell blockly to take the value of the "Z” box (which is 10)
  • And add another 10 more points to it.
  • We achieve this by using a math formula in blockly.
  • In the first line you start with setting variable Z = 10.
  • In the second line you tell it to set variable Z to +10.

#3

  • It will display the number 50.
  • In the first line variable Z is created with value 40.
  • In the 2nd line it increases Z by another 10.
  • In the 3rd line it prints the variable which at this time it has increased to 50!

#4

  • 1st line we set variable Z to 20.
  • 2nd line we set variable Z to +(-10).
    Making it  Z+(-10)
  • 3rd line it prints variable Z
  • Resulting in it displaying 10. Because 20+(-10) = 10


Lesson Overview:

  1. Ensure the Dobot firmware and software is updated to the latest version. This will reduce troubleshooting.
  2. This lesson can be done individually or in groups. Depending on size of class or number of robots. If several students per robot, you might want to assign them separate responsibilities for full engagement.
  3. This lesson can take between 1 to 2 class periods depending on coding knowledge of students with Blockly or Script.
  4. This lesson and skills is considered basic and will be built upon to higher levels in the next lessons.
  5. Having students start in the home position is recommended, so that every student or group has their Dobot(s) start from the same spot.


  1. We recommend you place the PICK and PLACE handouts at a similar position and distance from the Dobot to prevent Range Limit ERRORS! Make sure students are aware and remember the working area and limits of Dobot. This will prevent errors and reduce troubleshooting time allowing the lesson to completed quicker. TIP! Tape some of the corners to prevent paper moving!
  2. Let students know that utilizing the SetJointAngle command is more efficient and error free when setting Dobot in an ARC motion as in this project simulation. This helps students learn more about Dobot, software, and making Dobot working efficiently and less prone to errors. Many students will try programming dobot to move from one end of the arc to another just using the MOVE command, which will very likely result in “Mov Limit Alarm Triggered” errors!


Materials Needed:

Here is a lesson plan for your records.

Use these code solutions as a reference for grading: tower , Yaxis

Here is a detailed explination of the code solution. It is useful to help students who are stuck in the prototyping process.


Optional Materials:

Print this Key Term vocab sheet to use as a reference dring class.

Look at these example codes in Blockly. What will they do?

#1

#2

What would you need to do to INCREASE variable Z by another 10?


#3

Take a look at this program. What will it do?

#4

Lets do another, but with a different value added. Look at it carefully.

What will it do this time?



Teaching Tips:

Explore Module Overview

  1. Have students read through the key terms for this lesson. They will need these terms to communicate with their groupmates during the next module. 
  2. Go through the module with students as a class, and allow them to answer the questions as you go.
  3. Follow the instructions for beginning to program Dobot to stack blocks as a group. This will prepare students for the programming challenge ahead and ensure that everyone starts from the same level of knowledge.


Question 1 answer

If you said Z you are correct!

Remember:The coordinates for the 1st cube in the PLACE location were  X(206)  Y(73)  Z(-38) in our example.

In order for Dobot to correctly place the 2nd cube on top of the first, the Z coordinate (-38) needs to increase.


Question to promote higher-order thinking:

Can you think about how to achieve this mathematically with the help of a variable like you learned at the beginning?


Question 2 answer

That’s right we would need to increase it by 24.33

We first start by creating a variable in the code.  We’ll name it “Z” as it will be holding values for the Z axis.

Then we replace the Z value for the second location (PLACE) with the “Z” variable.


Question 3 answer

No, we are not increasing the value yet.

If you said “It would do the same thing as before!” you are correct and on your way to understanding variables!!

The reason Dobot would do the exact same thing as before is because it sees the exact same values for each Axis on the 2nd JumpTo command. It sees 206 for X, 73 for Y, and -38 for Z. It identifies the Z variable you put on there as -38 because on top of the code you created variable “Z” with a value of -38.


Question 4 answer

If you said Z you are correct !!

Remember: The coordinates for the 1st cube in the PLACE location were X(206)  Y(73)  Z(-38) in our example. In order for Dobot to correctly place the 2nd cube on top of the first, the Z coordinate (-38) needs to increase.



Question 5 answer

No, we are not increasing the value yet.

If you said “It would do the same thing as before!” you are correct and on your way to understanding variables!

The reason Dobot would do the exact same thing as before is because it sees the exact same values for each Axis on the 2nd JumpTo command.

It sees 206 for X, 73 for Y, and -38 for Z. It identifies the Z variable you put on there as -38 because on top of the code you created variable “Z” with a value of -38.

In order to increase the value:

We need to increase the value of the Z variable by 24.33 units (the height of each cube). We do so by using the same method you saw before. By using the math formula Z+24.33 at the end of the code.

Key Terms

  1. Variable – are used to store information to be referenced and manipulated in a computer program. You can think of them as containers that hold information.
  2. Blockly -  is a client-side JavaScript library for creating visual block programming languages and editors. It is a project of Google and is open-source under the Apache 2.0 License
  3. Cartesian coordinate system -  is a coordinate system that specifies each point uniquely in a plane by a pair of numerical coordinates
  4. Loop/Repeat - a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.


What if we wanted Dobot to come back to the PICKUP location, grab another cube, and PLACE it on top of the 1st cube?

Hint: Look at the coordinates in the picture



What Axis would need to change?


Each cube is exactly 24.33 units high.

Our starting Z axis is -38



How much would we need to increase the Z axis in order to precisely put the 2nd cube on top?


Look at the code carefully and follow it down one step at a time. Imagine following the steps as if you were Dobot.

HINT: Are we increasing the value?

If we push START on this code what do you think would happen?



 

Hint: Look at the coordinates in the picture

Can you think of what Axis would need to change?
  • X
  • Y
  • Z


Look at the code carefully and follow it down one step at a time. Imagine following the steps as if you were Dobot.

HINT: Are we increasing the value?

HINT: Are we increasing the value?


Teaching Tips:

Prototyping Module Overview

Each group or individual is to program Dobot with the following guidelines:

  • Dobot must move to a top starting location
  • Dobot must move down to pickup cube
  • Dobot must move back up to original starting spot
  • Dobot must place the cube 2 full cube lengths towards the right each cycle

Prototyping Challenge

As you can see variables are awesome for coding because they have many advantages.

For example: Imagine what it would be like to write this tower building code without variables. You'd have to write many more JumpTo commands for each cube, compared to just writing one line of code that increases the value by a certain amount each time.


Now that you’ve learned what a variable is, how use they work, and their advantages continue changing the code to create your tower!

Perhaps you can compete with your classmates on who can build the highest tower. Experiment with changing the code to get different results. 


NOTE:

Dobot does have height and range limits so keep that in mind. It will warn you by displaying errors and you will need to go back and change the code.



Teaching Tips:

Reflect Module Overview

  • Review with class on what variables are and how they are used.

  • The different types of commands covered in the lesson

  • How can they use this knowledge in a future project

  • Have students reflect and rate their performance as robot programmers. How many failed attempts? How much time?


Questions and Answers

  1. What is variable when it comes to coding?
    1. used to store information to be referenced and manipulated in a computer program. You can think of them as containers or boxes that hold information.
  2. What is an advantage of using variables?
    1. With just one line of code you can change values in many other lines instantly.
  3. Can you think of more not mentioned here?
    1. Answer will vary
  4. DobotStudio allows you to use _________ to program Dobot?
    1. Blockly.
  5. What does the Z axis control on Dobot?
    1. The height.
  6. What does the Y axis control on Dobot?
    1. The right or left movement.
  7. What does the X axis control on Dobot?
    1. The front / back movement.
  8. What does the code above do?
    1. It creates variable named Z. Assigns it the value of 10. Then prints the value.
  9. What does the code above do? 
    1. It creates variable named Z. Assigns it the value of 40. Adds 10 more units to that value. Prints the value.
  10. What command do we use to repeat commands a number of times?
    1. The Loop/Repeat command
  11. Did Dobot do anything unexpected while you were testing?

    1. Answers will vary
  12. Where did you identify the cause of it in your code?

    1. Answers will vary
  13. Can you think of some other way to modify the code with variables to make it do something else?

    1. Answers will vary
  14. What new things did you learn during the project?

    1. Answers will vary