1 / 21

Follow the Leader

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.

Télécharger la présentation

Follow the Leader

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. Name the two robots Select names for the two robots being used. Robot 1 _______________________ Robot 2 _______________________ These names can be added to the brick as follows:

  3. 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.

  4. Plan the actions for the robots Copy and fill out the table:

  5. Program and randomize the actions Two programs are required: Leader and Follower Animation in progress Leader program Follower program Sends action via Bluetooth Receives Bluetooth message Program randomly selects one of the two actions (e.g., forward for 1 rotation) Copies the action of the Leader

  6. Program and randomize the actions Leader’s program first Start a new program or Program starts with a Loop as the leader will need to keep creating steps indefinitely.

  7. Program and randomize the actions The 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.

  8. Program and randomize the actions A Switch is added (from either the Common or Complete palettes). In the Switch configuration panel: Control = Value Type = Number

  9. Program and randomize the actions Wire from the Random Block to the switch Animation in progress As in the above animation – use left mouse click to change direction. … And one more time.

  10. Program and randomize the actions Place the actions you wrote down into the switch.

  11. 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.

  12. Sending a message via Bluetooth Open the Send Message block’s data hub by clicking on the bottom-left of the block (as shown).

  13. Sending a message via Bluetooth Draw out another wire from the Random block. Wire to the Number Plug on the Send Message block.

  14. 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.

  15. Do action 0 Wait for a Bluetooth message What action? Do action 1 0 1 Programming the Follower A flowchart of the Follower’s program

  16. 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

  17. Programming the Follower 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. Set the Message to Number.

  18. Programming the Follower Add a switch block set to Value. Wire from Number Out to the Switch. Animation in progress And add the action blocks you used in the Leader’s program. Download this program to the Follower’s brick.

  19. Connecting the bricks Before the two programs can be run, a Bluetooth connection needs to be established between the two bricks. Leader = Master Follower = Slave To do this you will need to access the “Educate NXT” PowerPoint called Establishing a Bluetooth Connection

  20. Happy Following! Once the Bluetooth connection has been established, run both programs at the same time.

More Related