Engineering Journal

Jack Harrop
Initial Planning and Design
The RoboQuest Challenge requires robots to navigate an arena as part of either a shooting or blocking team. I chose to be a shooter, so my robot's main goal is to reach the center target inside a red circle and successfully launch a ping pong ball. To achieve this, I needed to design code that could detect colors accurately, avoid blocker, and go back to reload
My plan involves continuously reading the hue and brightness values from the color sensor. If the sensor detects black, the robot should rotate a random degree between 90 and 180 to stay within boundaries, while detecting red will indicate the target and trigger the launch code. An ultrasonic sensor is also required to detect nearby obstacles or the blocker, preventing collisions while navigating.
Code Development and Testing
The initial code was very basic, relying solely on hue detection to find the target. Testing showed that sensor readings were inconsistent, with black often misread as another color. To improve accuracy, I incorporated brightness detection. Black had a consistently low brightness, which allowed the robot to detect boundaries easily. By combining hue and brightness, the robot could differentiate between the floor, black boundaries, and the red circle.
Testing sessions involved placing the robot on the coloured tape / floor and observing how well it detected the colour. I learned that adding an ultrasonic sensor was required to prevent collisions with the blocker or anything that could block its path. I made also updated the movement logic and added random turns when black was detected, to prevent leaving the rectangle. Over multiple iterations, the robot's performance improved and became more consistent in navigating the arena.
if Math.isBetween(hue, 30, 70): Motors.write(0) print('Red Line Detected') break elif Math.isBetween(bright, 66, 150) and Math.isBetween(hue, 90, 105): print('Black Line Detected') Black() elif dis < 5: print('Blockage Detected') Motors.turnDegrees(104, speed) Motors.write(speed) else: print('Floor Detected') Motors.write(speed)
Challenges and Debugging
One major problem was the inconsistency of color sensor readings. The robot sometimes misidentified red or black for floor, causing it to get stuck and turn away from red. Another challenge was handling obstacles without interrupting the path-following behavior. I solved these problems by combining hue and brightness detection, and by adding ultrasonic readings to detect nearby objects.
The types of errors I encountered were mainly logic errors. Sometimes the robot would detect the wrong color and stop unnecessarily or fail to avoid the black line. Through testing, I refined the conditions and thresholds for hue and brightness, which improved overall reliability and ensured that the robot could reach the target easier.
Final Robot Design and Code
The final robot can successfully find the red circle, avoid black lines, avoid blockers and other close objects, detect the target, and launch a ping pong ball upon reaching it. It continuously reads the color, brighness and distance sensors. The code loops through sensor readings, stopping and shooting when the target is detected, turning randomly when edge is reached, and otherwise going forward. The integration of hue, brightness, and ultrasonic sensors ensures accuracy and smooth operation throughout the challenge.
# -------------------- # Functions # -------------------- def Black(): Motors.write(0) Motors.turnDegrees(rot, speed) Motors.write(speed) def LaunchReloadCycle(): while True: # Launch Servos.left(-90) delay(3) Servos.left(0) Servos.left(90) delay(3) Servos.left(0) # Reload while not Math.isBetween(bright, 66, 150) and Math.isBetween(hue, 90, 105): Motors.write(-30) Motors.write(0) delay(10) while not Math.isBetween(hue, 30, 70): Motors.write(30) # -------------------- # Robot 2015 program # -------------------- targ_dis = 40 speed = 15 while True: hue = Colour.readSensor(CS.HUE, 1) bright = Colour.readSensor(CS.BRIGHT, 1) dis = Ultrasonic.read() rot = Math.randint(-240, 240) if Math.isBetween(hue, 30, 70): Motors.write(0) print('red') break elif Math.isBetween(bright, 66, 150) and Math.isBetween(hue, 90, 105): print('black') Black() elif dis < 5: print('too close') Motors.turnDegrees(104, speed) Motors.write(speed) else: print('nothin') Motors.write(speed) while True: dis = Ultrasonic.read() if dis <= targ_dis: print('target') Motors.write(0) LaunchReloadCycle() break else: print('spinnin') Motors.turnDegrees(10, speed)
Reflection and Evaluation
The project worked pretty well overall. The robot successfully navigated the rectangle, mostly avoids blockers, and launched at the target. If I were to improve the design, I would work more on detection of the blockers, by looking at the code that the blockers have created to find strategies to defend against them.
References
No references were used for this journal or my code.