Session 9: Dumper Dynamics: Automated Loading and Unloading
Duration: 50-60 minutes
Equipment Required:
- M3D Robotics kit with distance sensor and dumper attachment
- Laptop with Arduino IDE and Web BLE setup
- USB/OTG cables to connect the robot to the laptop
- Black tape for creating a curved line path
- Objects for loading and unloading points
- Projector for live coding demonstration
Learning Objectives:
- Program the robot to follow a path, detect objects, and automate actions based on sensor input.
- Use Web BLE client to send and receive messages for interactive task feedback.
- Introduce students to displaying emojis on the robot’s screen for expressiveness.
- Program the robot to respond to user feedback and physical actions.
1. Introduction to Robot Emotions with Emojis (10 minutes)
Activity:
Begin with a light, engaging introduction to the concept of robot emotions. Explain that the robot can display different emojis to express its “feelings,” such as joy or frustration, at different stages of its task.
Instructions:
- Introducing Emoji Commands:
-
Show students the
display.emoji("Emoji Name")command and explain that the robot has a variety of emojis it can display on its screen, such asJoy,Confused, orFrustrated. -
Explain that these emojis help convey how the robot might “feel” during its task, like showing
Confusedif it’s unsure where to go next orJoywhen it completes its delivery.
- Demonstration and Practice:
-
Demonstrate a few emojis on the projector, asking students to guess which ones fit different situations.
-
Allow students a few minutes to try out different emojis on their robot screens.
Example Commands:
#include <M3DGo.h>
void setup()
{
go.begin();
}
void loop(){
display.emoji("Smile"); // Display a smiling emoji
go.delay(2000); // Wait for 2 seconds
display.emoji("Confused"); // Display a confused emoji
go.delay(2000);
}
Teacher’s Role:
Guide students in testing the emoji commands and help them understand when different emojis might be used in a task.
2. Setting Up the Automated Delivery Task (5 minutes)
Activity:
Introduce the main objective of the session: programming the robot to perform a series of tasks involving line following, detecting loading/unloading stations, and responding to user feedback.
Instructions:
- Explain that students will program the robot to first follow a curved line, then move to a loading station, wait for a package, and finally return to an unloading station, notifying each task stage on the Web BLE client.
- Go over the series of steps the robot will follow, encouraging students to visualize the sequence of actions.
- Encourage them to write the steps down to make coding the sequence easier.
Teacher’s Role:
Ensure students understand each step of the delivery task and how the sequence builds on previous lessons.
3. Programming the Delivery Sequence (15 minutes)
Activity:
Guide students in programming the robot to perform the delivery task, ensuring it correctly distinguishes between loading and unloading stations to avoid repeating actions. Introduce the concept of using variables to track task progress, such as knowing if the package has already been collected. This will prevent the robot from re-entering the loading stage after the package is collected.
You can divide the whole routine into smaller stages so that it is easier to code and understand:
-
Stage 1: Line Following to the Loading Station
- Program the robot to follow a curved line until it reaches the end, then move forward to the loading station.
-
Stage 2: Detecting and Waiting at the Loading Station
- Use the distance sensor to detect proximity to the loading station.
- Upon reaching it, have the robot turn around and notify the Web BLE client: “Waiting for package.”
- Use a variable (e.g.,
packageCollected) to track whether the package has been loaded.
-
Stage 3: Receiving the Package
- The robot will wait until it detects an object (e.g., a wave) close to the sensor, signaling the package has been loaded.
- Once loaded, set
packageCollected = trueto ensure the robot skips this section when returning to the unloading station. - Resume movement back to the line, following it to the unloading station.
-
Stage 4: Detecting the Unloading Station and Completing the Delivery
- When the robot reaches the unloading station, it will check the
packageCollectedvariable. - If
packageCollectedistrue, the robot will dump the package, notify “Delivery successful” on the Web BLE client, and end the sequence.
- When the robot reaches the unloading station, it will check the
Example Code:
#include <M3DGo.h>
bool packageCollected = false; // Variable to track package status
void setup() {
go.begin();
}
void loop() {
// Stage 1: Follow the line to the end
if (line.onTheLine()) {
go.forward(50); // Move forward if on the line
display.text("Following Line");
} else if (line.getLeft() > line.getRight()) { // Left sensor detects more white
go.spinClockwise(30); // Turn right
display.text("Adjusting Right");
} else { // Right sensor detects more white
go.spinCounterclockwise(30); // Turn left
display.text("Adjusting Left");
}
go.delay(500);
// Stage 2: Detect loading station and wait for package
if(packageCollected == false){
if (range.get_cm() < 10) { // Check if package not yet collected
go.stop();
go.spinClockwise(180); // Turn around
remote.notify("Waiting for package");
}
// Stage 3: Wait for signal to load package
while (range.get_cm() > 10) {
display.text("Waiting...");
}
// Package loaded
packageCollected = true;
display.text("Package loaded!");
}
// Stage 4: Detect unloading station and complete delivery
if(packageCollected == true){
if (range.get_cm() < 10) {
go.forward(50); // Start moving back
display.text("Delivery successful!");
remote.notify("Delivery successful");
}
// Reset package status for potential future deliveries
packageCollected = false;
}
}
Teacher’s Role:
Guide students in understanding the use of the packageCollected variable to manage task flow. Explain how this helps the robot differentiate between loading and unloading stages, ensuring smooth task automation. Encourage students to test and troubleshoot, reinforcing the value of condition checks and variables for more complex automation.
4. Interactive Challenge: Real-Time Feedback Response (10 minutes)
Challenge:
After the robot completes the delivery, prompt the user on the Web BLE client to rate the bot’s performance on a scale of 1 to 5. Based on the rating, the robot will display a relevant message on the screen (since emojis aren’t available due to attachment limits).
- Task: Ask the user to rate the delivery and have the bot display a message like “Thank you!” for high ratings or “Will try harder!” for low ratings.
Example Code:
float feedback = remote.askNumber("Rate delivery (1-5)");
if (feedback >= 4) {
display.text("Thank you for your rating!");
} else {
display.text("Will try harder!");
}
go.delay(2000); // Show the message for 2 seconds
Goal:
Observe how feedback-driven interactions can personalize the robot’s actions and add a user-centered approach to automation.
Teacher’s Role:
Help students implement this additional challenge and explore how the robot’s responses add a more interactive, user-friendly experience.
5. Reflection and Wrap-Up (5 minutes)
Discussion Questions:
- You may ask:
- “How did the robot respond at each stage? What were some challenges you faced?”
- “How could we add more feedback-driven actions?”
- “Where else could you use automation like this outside the classroom?”
Teacher’s Role:
Conclude with a discussion about real-world applications of automated delivery and communication. Encourage students to share insights and ask questions about user feedback and sensor-based actions.
Learning Outcome:
By the end of this session, students will understand how to program the robot to perform automated tasks based on sensor input, use Web BLE to receive feedback, and design feedback-driven actions that personalize the bot’s responses.