130 likes | 354 Views
Robotics. Learn. Apply. Mr. Mundo. Objectives. In this lesson you will learn: What is a robot What is a computer program What is program structure What is Pseudo code. What is a robot?. None Moving robot (None Functional Robot). Program (NXT Program). Program (NXT Program).
E N D
Robotics Learn Apply . Mr. Mundo
Objectives • In this lesson you will learn: • What is a robot • What is a computer program • What is program structure • What is Pseudo code
What is a robot? None Moving robot (None Functional Robot) Program (NXT Program) Program (NXT Program) Moving robot (Functional Robot)
What is a robot? Definition 1: is a human-shaped mechanical device that acts as human. Definition 2: is an electronic machine that functions independently, without human control. Mundo’s Definition: A robot is a device that is built and programmed to perform specific actions and interact with its surroundings.
What is a computer program? A computer program is a set (list) of instructions that are executed by a computer A computer program is written in a language that a computer understand A computer program is written to solve a specific problem Programming is the act of writing programs
Programs are for humans too Monday: be at school at 7:10 7:25 start 1th P 8:25 start 2th P 9:25 start 3th P 10:25 start 4th P 11:25 start 5th P 12:25 start 6th P 1:25 start conference P Repeat steps for next four days • Do you follow a similar program every week? We all follow or perform programs in some way in our daily lives Example: here is the program I follow every working week:
Programs for our robotics class • Our programs will give our robots behavior, the ability to respond to events • The forward.rbt you wrote for your robot made it move forward • The complexity of a program is only limited by your imagination We’ll be writing programs that will make our robots perform actions.
Program Structure Example1: Mr. Mundo: Class, drag a Move block into Says the NXT programming area. Mr. Mundo: Class, open your NXT software. Says Mr. Mundo: Class create a file named moveBack Says • Does this program structure makes sense? Structure means the way a set of things are put together or organized Program structure refers to the way instructions (commands) are organized.
Program Structure Revised example 1 Mr. Mundo: Class, open your NXT software. Says Mr. Mundo: Class create a file named moveBack Says Mr. Mundo: Class, drag a Move block into the Says NXT programming area. The structure of the previous instructions were wrong Each instruction was correct, but the way they were placed together was wrong and confusing
What is pseudo code? This is Pseudo Code Mr. Mundo: Class, open your NXT software. Says Mr. Mundo: Class create a file named moveBack Says Mr. Mundo: Class, drag a Move block into Says the NXT programming area. • Pseudo code is program instructions written in plain English • Pseudo code is not to be understood by the computer or robot, but by the programmer • Pseudo code helps us plan and organize our programs • With pseudo code, we accomplish three things when programming our robots • We gain a better understanding of the tasks our robot will perform. • We look at the world from the robot’s point of view, which is extremely important when programming it. • We create an ordered set of instructions (structure) for our robot to follow.
Pseudo Example 1 ROBOT, move forward until your Touch sensor is pressed and released. Then, stop. ROBOT, I want you to turn left 90 degrees. Now, I want you to give a loud Beep! ROBOT. Now move backward until your light sensor detects something black. Then, stop. Now, ROBOT, do a little dance for 2 seconds. Then stop
Pseudo Cont… Pseudo code Example 1: ROBOT, move forward about 10 inches; turn left 90 degrees, and start moving forward; then start looking for a black object with your Ultrasonic sensor, because I want you to stop when you find a black object; then turn right 90 degrees, and move backward 2 feet, OK? Pseudo code Example 2 1. ROBOT, move forward 10 inches and stop. 2. Now turn left 90 degrees. 3. Starting moving forward, and turn on your Ultrasonic sensor. 4. Stop when you find a black object. 5. Turn right 90 degrees and stop. 6. Now move backwards 2 feet and stop. • Which one is less confusing? Pseudo code instructions should be simple and possible Look at the following two examples:
Hints for writing pseudo code REMEMBER, you will convert this English instructions into programming code for your robot to perform. The easier and clearer your pseudo code is the easier will be for you to convert them to computer code . Do not combine instructions Keep your instructions short and simple Write your instructions in clear English statements Be specific