Scribbler movements

advertisement

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 a series of commands

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

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.

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)

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()

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)

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

Draw a Square

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

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

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.

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 commands

3. Save the file

4. Run the module:

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.

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.

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.

Download