0 / 6 页已完成

自动阶段是什么?What Is the Autonomous Period?

1.1 VEX 比赛流程1.1 VEX Match Structure

每场 VEX 比赛分为两个阶段:Each VEX match is split into two periods:

自动阶段的分数可能决定一场比赛的胜负。很多比赛,双方手动阶段打得差不多,最终谁赢就看自动阶段多拿了几分。The autonomous score can decide a match. In many matches, both sides score similarly during driver control, so whoever scores more in autonomous wins.

策略思维:15 秒能做什么?Strategic Thinking: What Can You Do in 15 Seconds?

15 秒听起来很短,但如果程序写得好,机器人可以:先拿最近的得分物 → 推到得分区 → 触碰色块。关键是先拿近的、容易的,不要贪多。15 seconds sounds short, but with good programming, the robot can: grab the nearest scoring object -> push it to the scoring zone -> touch the color pad. The key is to go for what's close and easy first -- don't be greedy.

1.2 autonomous() 函数1.2 The autonomous() Function

自动阶段的代码写在一个专门的函数里。比赛系统会在自动阶段开始时自动调用它。The autonomous code goes in a dedicated function. The competition system automatically calls it when the autonomous period begins.

C++ (VEXcode)
// 比赛模板
competition Competition;

// 自动阶段:15 秒,机器人自己跑
void autonomous() {
    // 你的自动代码写在这里
}

// 手动阶段:1 分 45 秒,遥控器控制
void userControl() {
    // 你的手动代码写在这里
}

int main() {
    Competition.autonomous(autonomous);
    Competition.drivercontrol(userControl);

    while (true) {
        wait(100, msec);
    }
}

代码解释:Code explanation:

C++ (VS Code)
// 比赛模板
competition Competition;

// 自动阶段:15 秒,机器人自己跑
void autonomous() {
    // 你的自动代码写在这里
}

// 手动阶段:1 分 45 秒,遥控器控制
void userControl() {
    // 你的手动代码写在这里
}

int main() {
    Competition.autonomous(autonomous);
    Competition.drivercontrol(userControl);

    while (true) {
        wait(100, msec);
    }
}

代码解释:Code explanation:

C++ (PROS)
// PROS 自动提供这些函数,你只需要填内容

// 初始化(程序启动时运行)
void initialize() {
    // 传感器初始化等
}

// 自动阶段:15 秒
void autonomous() {
    // 你的自动代码写在这里
}

// 手动阶段:1 分 45 秒
void opcontrol() {
    // 你的手动代码写在这里
}

PROS 的结构更简单:不需要手动注册回调,系统会自动在对应阶段调用对应函数。PROS has a simpler structure: no need to manually register callbacks -- the system automatically calls the corresponding function for each period.

1.3 自动 vs 手动:代码有什么不同?1.3 Autonomous vs Driver Control: What's Different in the Code?

核心区别Key Difference

手动阶段Driver control:代码在 while 循环里不断读遥控器输入,根据摇杆值控制电机。: Code runs in a while loop, constantly reading controller input and controlling motors based on joystick values.
自动阶段Autonomous:没有遥控器输入!代码是一步一步的指令序列——先做这个,再做那个,像菜谱一样。: No controller input! The code is a step-by-step sequence of commands -- do this first, then that, like a recipe.

C++ (VEXcode)
// 手动阶段 — 不断循环读遥控器
void userControl() {
    while (true) {
        int speed = Controller1.Axis3.position();
        LeftMotor.spin(forward, speed, percent);
        wait(20, msec);
    }
}

// 自动阶段 — 按顺序执行指令
void autonomous() {
    // 第 1 步:前进
    LeftMotor.spin(forward, 50, percent);
    RightMotor.spin(forward, 50, percent);
    wait(2, seconds);

    // 第 2 步:停
    LeftMotor.stop();
    RightMotor.stop();
}
C++ (VS Code)
// 手动阶段 — 不断循环读遥控器
void userControl() {
    while (true) {
        int speed = Controller1.Axis3.position();
        LeftMotor.spin(forward, speed, percent);
        wait(20, msec);
    }
}

// 自动阶段 — 按顺序执行指令
void autonomous() {
    // 第 1 步:前进
    LeftMotor.spin(forward, 50, percent);
    RightMotor.spin(forward, 50, percent);
    wait(2, seconds);

    // 第 2 步:停
    LeftMotor.stop();
    RightMotor.stop();
}
C++ (PROS)
// 手动阶段 — 不断循环读遥控器
void opcontrol() {
    pros::Controller master(pros::E_CONTROLLER_MASTER);
    while (true) {
        int speed = master.get_analog(ANALOG_LEFT_Y);
        left_motor.move(speed);
        pros::delay(20);
    }
}

// 自动阶段 — 按顺序执行指令
void autonomous() {
    // 第 1 步:前进
    left_motor.move(64);
    right_motor.move(64);
    pros::delay(2000); // 2000 毫秒 = 2 秒

    // 第 2 步:停
    left_motor.move(0);
    right_motor.move(0);
}

1.4 策略:先做什么?1.4 Strategy: What to Do First?

写自动程序之前,先想清楚策略:Before writing autonomous code, plan your strategy:

  1. 观察场地Observe the field:哪些得分物离起点最近?: Which scoring objects are closest to the starting position?
  2. 排优先级Prioritize:先拿容易拿的,稳稳得分: Go for easy ones first, score reliably
  3. 估时间Estimate time:15 秒不够做很多事,2-3 个动作就差不多了: 15 seconds isn't enough for much -- 2-3 actions is about right
  4. 考虑对手Consider opponents:对面的机器人会不会挡路?: Will the opposing robot block your path?
常见错误Common Mistake

新手最容易犯的错:想在 15 秒内做太多事。结果什么都没做完,还不如只做一件事做到位。The most common beginner mistake: trying to do too much in 15 seconds. Ending up finishing nothing is worse than doing one thing well.

检查点:比赛流程Checkpoint: Match Structure
VEX 比赛中,自动阶段持续多长时间?How long does the autonomous period last in a VEX match?