[RL75] Grade 7 - Session 5

Session 5: Teamwork Makes the Dream Work

Objective:
In this session, students will program two robots to collaboratively locate and mark “treasure” sites using the line sensor, distance sensor, and the remote BLE web client for real-time communication. They’ll learn how to coordinate actions between the two robots, with each robot handling specific roles to achieve a shared goal. This will help them understand communication protocols, teamwork between bots, and remote broadcasting.


Equipment Required:

  • Two M3D Robotics kits (M3D Go)
  • Laptops with Arduino IDE pre-installed
  • USB/OTG cables for connecting robots to laptops
  • Remote BLE web client access for broadcasting
  • Black tape to mark “digging spots” (treasure sites) on the floor grid

Learning Objectives:

  • Understand real-time inter-robot communication using a remote BLE client.
  • Use sensors (line and distance) to detect and act on environmental inputs.
  • Coordinate actions between two robots for a shared goal.
  • Explore task-switching based on communication and sensor data.

1. Introduction to the Treasure Hunt and Task Division (5 minutes)

Activity:
Begin by explaining the concept of a collaborative treasure hunt, where each robot has a specific role: one robot (the Scout) searches for digging spots, and the second robot (the Marker) marks these spots with an object. Explain how this requires each robot to communicate and respond to each other’s actions in real time.

Discussion:
You may say:

“Imagine two explorers working together—one searches for treasure spots, and the other marks the spot once it’s found. The first robot will search for black marks (digging spots) on the floor, and when it finds one, it will signal the other robot to follow and place a marker there.”

Teacher’s Role:
Explain how this will require sensor detection, movement, and communication through the BLE web client, and introduce the basic role of each robot. Ensure students understand the function of each robot to complete the task as a team.


2. Introduction to the Remote BLE Web Client and Broadcasting (5 minutes)

Activity:
Introduce students to the BLE web client and explain how they will use it to broadcast messages that allow the two robots to coordinate. Explain that each robot will use the web client to communicate specific messages, such as when a digging spot is found.

Instructions:

  1. Connecting to the Web Client:

    • Demonstrate how to check if the web client is connected using remote.isConnected().
  2. Broadcasting Messages:

    • Show students how to use remote.notify("Type message here"); to broadcast messages when a treasure site is found.

Example Code:

if (remote.isConnected()) {
    remote.notify("Digging Spot Found!");  // Broadcast message when a spot is detected
}

Teacher’s Role:
Guide students in understanding the importance of communication in coordinating the robots and how each bot can use the remote client to send important messages to the other.


3. Setting Up Robot Roles: Scout and Marker (10 minutes)

Activity:
Students will set up each robot’s primary role:

  • Robot 1 (Scout): Uses the line sensor and distance sensor to detect black marks (digging spots) on the floor. When a spot is found, it stops, broadcasts the message to the Marker robot, waits for 3 seconds, then turns left and moves away to let the Marker robot take over.

  • Robot 2 (Marker): Uses the distance sensor to follow the Scout and waits for it to stop. When the Scout broadcasts the message, the Marker moves to the spot, drops a marker object using its dumper, and then gets ready for the next spot.

Teacher’s Role:
Assist students in setting up the basic movement and sensor readings for each robot. Make sure they understand the goal of each robot and how they’ll interact.


4. Coding the Scout Robot (15 minutes)

Activity:
Guide students in programming the Scout robot to locate digging spots and signal the Marker robot when a spot is detected. The Scout will move along the line, stopping at black tape marks, and send a broadcast to the Marker robot via the BLE web client.

Example Code for Scout Robot:

#include <M3DGo.h>

void setup() {
    go.begin();
}

void loop() {
    go.forward(50);  // Move forward to scan for digging spots

    if (line.onTheLine()) {  // Check if on a black mark
        go.stop();
        if (remote.isConnected()) {
            remote.notify("Digging Spot Found!");
        }
        go.delay(3000);  // Wait 3 seconds before moving
        go.turnLeft(90); // Turn left to leave the spot
        go.delay(5000);  // Move forward for 5 seconds
    }
}

Teacher’s Role:
Walk students through this code, explaining how each part functions. Emphasize the role of line.onTheLine() to detect black tape, and the importance of the broadcast command to notify the Marker robot.


5. Coding the Marker Robot (15 minutes)

Activity:
Students will now program the Marker robot to follow the Scout using the distance sensor. When the Marker robot detects the Scout has moved on, it drops a marker object to signify a treasure site.

Example Code for Marker Robot:

#include <M3DGo.h>

void setup() {
    go.begin();
}

void loop() {
    if (range.get_cm() < 15) {  // Follow the Scout robot
        go.stop();
        go.delay(1000);         // Wait for 1 second
        go.spinClockwise(180);   // Rotate to face treasure spot
        hingeA.open();       // Drop the marker object
        go.delay(1000);         // Delay to ensure marker is dropped
        go.spinCounterClockwise(90); // Return to original position
        if (remote.isConnected()) {
            remote.notify("Digging Spot Marked!");
        }
    } else {
        go.forward(50);         // Continue following the Scout
    }
}

Teacher’s Role:
Help students understand how the Marker robot uses the distance sensor to follow and react to the Scout robot’s movement. Explain how the Marker’s dumper mechanism (hinge control) marks the treasure site.


6. Testing and Collaboration (10 minutes)

Activity:
Allow students to test their robots together in the treasure grid setup. Have them observe the interaction between the Scout and Marker robots as they move, detect, communicate, and mark digging spots.

Teacher’s Role:
Encourage students to troubleshoot any issues with synchronization and ensure they’re correctly using the remote broadcast commands. Offer guidance in adjusting sensor sensitivity or timing if necessary to enhance collaboration between the bots.


7. Reflection and Wrap-Up (5 minutes)

Reflection Questions:

  • You may ask:
    “How did communication between the two robots help complete the task efficiently?”
    “What was challenging about coordinating the robots, and how did you solve it?”
    “If you could add more bots or modify this task, what would you change?”

Teacher’s Role:
Facilitate a discussion about the importance of communication in multi-bot coordination, highlighting the collaborative effort in reaching a common goal.


Learning Outcome:

By the end of this session, students will have programmed two robots to work together through real-time communication. They’ll understand how to use the BLE client for remote messaging, apply sensor data to guide movement, and coordinate actions for a shared objective.