Operation “Don’t Bonk!”

Mission Briefing:

Robot PU is eager to see the world, and sometimes he gets a little too excited. He loves running at full speed, but the world is full of obstacles. To be a safe explorer, PU needs to master the art of the Precision Halt.

Your mission? Code an algorithm that lets PU run towards a solid wall and stop right in front of it. The goal isn’t just to stop—it’s to stop so close that you can barely slide a piece of paper between PU’s nose and the brickwork.

But be careful! If PU touches the wall… BONK! Mission failure.


🛠 The Setup

  1. The Arena: A flat surface with a distinct Start Line and a solid, flat Target Wall (a cardboard box works great).
  2. The Distance: Place Robot PU at the Start Line, exactly 2 meters (or 6 feet) away from the wall.
  3. The Gear: Robot PU equipped with his standard front-facing distance sensors (Ultrasonic, IR, or LiDAR).

📜 The Rules

  1. Autonomous Only: Once you press “Start,” you cannot touch a controller. PU must rely entirely on his code and sensors.
  2. The Approach: PU must move forward. Creeping inch-by-inch is allowed, but boring (see Tie-Breaker rules).
  3. ** The Stop:** Once PU’s wheels stop moving completely, the run is over. No inching forward after the initial stop!
  4. The Bonk Rule: If any part of Robot PU touches the wall at any speed, it is an automatic GAME OVER.

🏆 How to Win (Scoring)

Victory is determined by the Gap of Glory.

  1. Measurement: Use a ruler or calipers to measure the distance between PU’s frontmost point and the wall.
  2. The Ranking: The robot with the smallest distance greater than 0.00mm wins.
    • Example: * Player A stops at 5cm.
      • Player B stops at 1cm.
      • Player C touches the wall.
      • Winner: Player B!

⚡ The Tie-Breaker: The “Speed Demon” Rule

If two engineers write code that stops PU at the exact same distance (e.g., both stop exactly 2mm away), the winner is the robot that stopped first.

This means you can’t just program PU to drive at 1% speed. You need an algorithm that is fast and precise!


🧠 Engineering Tips for the Commander

  • Trust Your Sensors (But Not Too Much): Sensors have “noise.” They might say the wall is 10cm away when it’s actually 9cm. How will your code handle that uncertainty?
  • The Braking Curve: If you run full speed until the last centimeter, momentum will make PU skid into the wall. You need to calculate a deceleration curve (slow down as you get closer).
  • Sensor Update Rate: Remember, the faster PU moves, the less time the computer has to “think” between sensor pings. If you go too fast, you might hit the wall before the sensor realizes you were there!

Example Program

Tips to win the game:

  • Smooth the sonar distance to avoid measurement fluctuations
  • Map the sonar distance to proper moving speed

Ready? Upload your code. Calibrate your sensors. Don’t. Bonk.