EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the...

21
EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation: Bluetooth communications (Send Message block, Receive Message block) Random behaviors (Random block) Wiring blocks together using Data hubs

Transcript of EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the...

Page 1: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Follow the Leader

Using Bluetooth communication, one robot can be made to follow the actions of a second robot.

Features in this presentation:• Bluetooth communications

(Send Message block, Receive Message block)

• Random behaviors (Random block)

• Wiring blocks together using Data hubs

Page 2: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Name the two robotsSelect names for the two robots being used.

Robot 1 _______________________

Robot 2 _______________________

These names can be added to the brick as follows:

Page 3: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Name the two robots

Enter name here

Click the Button straight after the name is typed in.

Name will appear on the NXT brick

screen.

Page 4: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Plan the actions for the robots

Action Block(s) required

1. (e.g. “Turn left for 1 second”)

(e.g. “Move block”)

2. (e.g. “Go forward 2 rotations”)

(e.g. “Move block”)

Copy and fill out the table:

Page 5: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Program and randomize the actionsTwo programs are required:

Leader and Follower

Leader program

Program randomly selects one of the two actions (e.g.,

forward for 1 rotation)

Follower program

Copies the action of the Leader

Receives Bluetooth message

Sends action via Bluetooth

Animation in progress

Page 6: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Program and randomize the actions

Start a new program

Leader’s program first

or

Program starts with a Loop

as the leader will need to keep creating steps indefinitely.

Page 7: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Program and randomize the actionsThe leader will perform

one of their two actions randomly.

A Random block will be required from the Complete palette.

The Random block is dragged into the loop.

Minimum is set to 0.

Maximum is set to 1.

Page 8: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Program and randomize the actions

A Switch is added (from either the Common or Complete palettes).

Control = Value

Type = Number

In the Switch configuration panel:

Page 9: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Program and randomize the actions

Wire from the Random Block to the switch

As in the above animation – use left mouse click to

change direction.

… And one more time.

Animation in progress

Page 10: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Program and randomize the actions

Place the actions you wrote down into the switch.

Page 11: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Sending a message via Bluetooth

Select and drag the Send Message icon into the Leader program.

Leave both the Connection and Mailbox in the Configuration panel set at 1.

Scott Sims
Is it OK that these graphics are touching?
Page 12: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Sending a message via Bluetooth

Open the Send Message block’s data hub by clicking on the bottom-left of the block (as shown).

Page 13: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Sending a message via BluetoothDraw out another wire from the Random block.

Wire to the Number Plug on the Send Message block.

whiteb
Graphics overlap.
Page 14: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

That is the finished Leader’s Program.

This can be downloaded to the Leader’s brick.

Don’t run it yet. The Follower needs to be

programmed.

Page 15: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Programming the Follower

0

1

What action?

Wait for a Bluetooth message

Do action 1

Do action 0

A flowchart of the Follower’s program

Page 16: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Programming the Follower

Drag a Receive Message Block into a Loop.

The loop means it will continually allow the Follower to look for a Bluetooth message before acting on it.

Set the loop to

Control = Logic and

Until = True

Page 17: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Programming the Follower

Set the Message to Number.

Wire from the “Message Received” data hub point to the “Loop Condition” as shown.

Once a message is received the program will now break out of the loop.

Page 18: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Programming the Follower

Add a switch block set to Value.

Wire from Number Out to the Switch.

And add the action blocks you used in the Leader’s program.

Download this program to the Follower’s brick.

Animation in progress

Page 19: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Connecting the bricksBefore the two programs can be run, a Bluetooth connection

needs to be established between the two bricks.

To do this you will need to access the “Educate NXT” PowerPoint called

Establishing a Bluetooth Connection

Leader = Master Follower = Slave

Page 20: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT

Happy Following!

Once the Bluetooth connection has been established, run both programs at

the same time.

Page 21: EducateNXT Follow the Leader Using Bluetooth communication, one robot can be made to follow the actions of a second robot. Features in this presentation:

EducateNXT