15

Lesson 15: Advanced miniAuto Features

Unlocking your robot's full potential

Learning Objectives

By the end of this lesson, students will:

  • Implement line following algorithms
  • Use camera for basic AI vision
  • Control robotic gripper attachment
  • Create complex autonomous behaviors

Skills Developed:

  • Computer vision basics
  • PID control algorithms
  • Advanced robotics integration

Lesson Content

1 Line Following with PID Control (20 minutes)

Line Following Concepts:

  • • Use infrared sensors to detect dark lines
  • • Calculate error from center of line
  • • Apply PID control for smooth following
  • • Handle intersections and line breaks
// Line following with PID control
#define BASE_SPEED 120
#define KP 0.5  // Proportional gain
int lastError = 0;

void followLine() {
    int leftSensor = miniAuto.getLineSensor(LEFT);
    int rightSensor = miniAuto.getLineSensor(RIGHT);
    int error = calculateLineError(leftSensor, rightSensor);
    float correction = error * KP;
    int leftSpeed = BASE_SPEED - correction;
    int rightSpeed = BASE_SPEED + correction;
    miniAuto.setMotorSpeeds(leftSpeed, rightSpeed);
}

2 Camera and Color Tracking (20 minutes)

Vision Applications:

  • • Object detection and recognition
  • • Color tracking and following
  • • Visual navigation
// Basic color tracking
void trackColoredObject() {
    camera_fb_t* fb = esp_camera_fb_get();
    int objectX, objectY;
    bool found = detectColor(fb, &objectX, &objectY);
    if (found) {
        int error = objectX - (fb->width / 2);
        if (abs(error) < 20) {
            miniAuto.moveForward(100);
        } else if (error < 0) {
            miniAuto.turnLeft(80);
        } else {
            miniAuto.turnRight(80);
        }
    }
    esp_camera_fb_return(fb);
}

3 Robotic Gripper Control (15 minutes)

Gripper Applications:

  • • Pick and place operations
  • • Object sorting and manipulation
  • • Interactive object handling
// Gripper control functions
void pickUpObject() {
    miniAuto.moveForward(80);
    delay(1000);
    miniAuto.closeGripper();
    delay(500);
    miniAuto.moveBackward(80);
    delay(500);
}

void deliverObject() {
    navigateToDeliveryZone();
    miniAuto.openGripper();
    delay(1000);
}

4 Mission-Based Autonomous Systems (10 minutes)

Complex Behavior Integration:

  • • Combine multiple sensors and actuators
  • • Create mission-based state machines
  • • Implement error recovery

Hands-On Activity (25 minutes)

Project: Advanced Autonomous Robot

Create an advanced robot combining line following, vision, and gripper control.

Requirements:

  • • Implement line following with PID control
  • • Add color detection and tracking
  • • Include gripper control for objects
  • • Create mission-based behavior

Assessment & Homework

Quick Check:

  • • Line following implementation
  • • Vision system integration
  • • Gripper control mastery

Homework:

Competition Preparation

Prepare your robot for the final competition by optimizing all systems and creating a comprehensive autonomous behavior program.

← Previous: Lesson 14
📝 Take Lesson 15 Quiz Next: Lesson 16 →