Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement...

13
Scribbler Movements Sec 9-3 Web Design

Transcript of Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement...

Page 1: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Scribbler Movements

Sec 9-3Web Design

Page 2: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Objectives

The student will:• Understand the basic movement commands

for the Scribbler• Know how to create and execute a series of

commands

Page 3: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Scribbler Movements• If you look at the scribbler from the bottom

you will notice that it has 3 wheels.– The small wheel is for support only– The large wheels are motorized. Each wheel has it

own motor.– You can control each motor individually.

motors( Left, Right)• Left and Right are in ranges from -1.0 to 1.0• Negative numbers turn the motor backward• 1.0 is the max speed of the motor. Think of the

numbers as % of total speed

Page 4: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Scribbler Movements - motors()• Examples:– motors(1.0, 1.0) – move forward– motors(-1.0, -1.0) - move backward– motors(1.0, 0) – tight circle to the right– motors(1.0, -1.0) – spin (turn) to the right

• Note the action will continue until another command (i.e. stop() ) is issued.

Page 5: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Scribbler Movements - motors()• What do think will happen with the following

commands:1. motors(0,0)2. motors(1, 0.5)3. motors(1, -0.5)4. motors(.25, -.25)

Page 6: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Scribbler Movements• Myro also provides built in functions for the

most common movements:1. forward(speed)2. backward(speed)3. turnLeft(speed)4. turnRight(speed)5. Stop()

Page 7: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Scribbler Movements

• Another version of the commands accepts a second argument (parameter) which is the amount of time in seconds.

1. forward(SPEED, SECONDS)2. backward(SPEED, SECONDS)3. turnLeft(SPEED, SECONDS)4. turnRight(SPEED, SECONDS)

Page 8: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Draw a Square

forward(1, 1)turnLeft(1, .29)forward(1, 1)turnLeft(1, .29)forward(1, 1)turnLeft(1, .29)forward(1, 1)turnLeft(1, .29)

• There is no way to tell the robot to move 5 feet or to turn right 90o

• For Bucky .29 works the best for the turn but that might not be right for your robot.

Page 9: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Translate and Rotate

• translate(speed) moves the robot forward or back.

• rotate(speed) turns the robot left.• move(TRANSLATE_SPEED, ROTATE_SPEED)

will perform a translate and rotate at the same time. The result will be a circle.

Page 10: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Executing a Series of Commands• If you would like to type a series of commands

and have them executed all at once then you can…

1. Open a new window: 2. Type in the commands3. Save the file4. Run the module:

Page 11: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

IDLE Tips – Command History

• You can repeat a previous command by using IDLE's command history feature:– ALT p retrieves previous command‐– ALT n retrieves next‐– You can also click your cursor on any previous

command and press ALT ENTER to repeat that ‐command.

Page 12: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Summary

• Many different ways to move your robot.– motors(), forward(), backward(), turnLeft(), turnRight(), move(), stop(), etc.

• You can type in a series of commands, save them and then have the IDLE shell execute those commands.

Page 13: Scribbler Movements Sec 9-3 Web Design. Objectives The student will: Understand the basic movement commands for the Scribbler Know how to create and execute.

Rest of Today• Experiment with your robot to make a octogon:

• Make the side a movement of 0.5 seconds (keep the octagon small).

• The robot should end up roughly where it started and facing the same direction as when it started.

• Once you have the commands that make a octagon, show it to me.

• Read pages 21-26 in Learning Computing with Robots.