0 / 6 页已完成

综合挑战Comprehensive Challenge

6.1 任务要求6.1 Task Requirements

把 Level 1 和 Level 2 学到的东西结合起来,写一个完整的遥控程序:Combine everything you've learned in Level 1 and Level 2 to write a complete driver control program:

目标:Arcade 底盘 + 升降臂三位置状态机Goal: Arcade Drivetrain + 3-Position Lift State Machine

6.2 分步提示6.2 Step-by-Step Hints

不知道怎么开始?按这个顺序来:Not sure where to start? Follow this order:

  1. 先定义 enum class LiftState,三个状态First define enum class LiftState with three states
  2. 写升降臂控制函数(while + switch),准备放到后台线程Write the lift control function (while + switch), ready for a background thread
  3. 写主循环:Arcade 底盘 + R1 按钮切换状态(记得边沿检测!)Write the main loop: Arcade drivetrain + R1 button to switch states (remember edge detection!)
  4. 在 main/opcontrol 里启动线程Start the thread in main/opcontrol
先自己试!Try It Yourself First!

在看参考答案之前,先自己写一遍。写不出来也没关系,但一定要先动手试。Before looking at the answer, write it yourself. It's okay if you can't finish it, but you must try first.

提示:把 Level 1 的 Arcade 底盘代码和 Level 2 的状态机代码拼在一起,就完成了大半。Hint: combine Level 1's Arcade drivetrain code with Level 2's state machine code, and you're mostly done.

6.3 参考答案6.3 Reference Answer

检查点:综合理解Checkpoint: Comprehensive Understanding
在上面的程序中,如果把升降臂控制代码直接写在主循环里(不用后台线程),会有什么问题?In the program above, what's the problem if you put the lift control code directly in the main loop (without a background thread)?