From fdbc180e30dfda67f56c37865ec42e455797e221 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Tue, 9 Sep 2025 16:39:10 +0000 Subject: [PATCH 01/38] Test Test --- New Compressed (zipped) Folder.zip | Bin 0 -> 112 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 New Compressed (zipped) Folder.zip diff --git a/New Compressed (zipped) Folder.zip b/New Compressed (zipped) Folder.zip new file mode 100644 index 0000000000000000000000000000000000000000..718f7708fc8e0c3ddce7917259e547119d965b70 GIT binary patch literal 112 zcmWIWW@Zs#0D&7Zn$chelwb$aC8@ Date: Tue, 9 Sep 2025 16:39:58 +0000 Subject: [PATCH 02/38] Test new Test new --- New Compressed (zipped) Folder.zip | Bin 112 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 New Compressed (zipped) Folder.zip diff --git a/New Compressed (zipped) Folder.zip b/New Compressed (zipped) Folder.zip deleted file mode 100644 index 718f7708fc8e0c3ddce7917259e547119d965b70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 112 zcmWIWW@Zs#0D&7Zn$chelwb$aC8@ Date: Wed, 10 Sep 2025 13:31:27 +0000 Subject: [PATCH 03/38] Uploaded files from Bitbucket --- utils/base_robot_classes.py | 145 ++++++++++++++++++++++++++++++++++++ utils/color_sensor_navi.py | 41 ++++++++++ utils/combine_runs.py | 139 ++++++++++++++++++++++++++++++++++ utils/constants.py | 13 ++++ utils/robot_control.py | 43 +++++++++++ 5 files changed, 381 insertions(+) create mode 100644 utils/base_robot_classes.py create mode 100644 utils/color_sensor_navi.py create mode 100644 utils/combine_runs.py create mode 100644 utils/constants.py create mode 100644 utils/robot_control.py diff --git a/utils/base_robot_classes.py b/utils/base_robot_classes.py new file mode 100644 index 0000000..6d5e52a --- /dev/null +++ b/utils/base_robot_classes.py @@ -0,0 +1,145 @@ +# --- VICKRAM's CODE --- +# To do - make another version of this using DriveBase +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor +from pybricks.parameters import Port, Stop +from pybricks.tools import wait, StopWatch, multitask +from umath import pi, sin, cos, radians +import asyncio + +# Keep these--------------------------------------------------- +class Tracker: + def __init__(self, starting_pos_x, starting_pos_y, starting_angle): + self.position = [starting_pos_x, starting_pos_y] + self.angle = starting_angle + def update(self, straight_distance, delta_angle): + delta_angle = radians(delta_angle) # Convert to radians + self.position[0] += straight_distance * cos(delta_angle) # Calculate x coordinate + self.position[1] += straight_distance * sin(delta_angle) # Calculate y coordinate + self.angle += delta_angle + + def get_state(): + return self.position, self. angle + +class Attachment: + def __init__(self, port, start_angle=0): + self.motor = Motor(port) + self.start_angle = start_angle + def move(self, degrees, speed): + self.motor.reset_angle(0) + target_angle = degrees + tolerance = 2 + # Movement with timeout + movement_timer = StopWatch() + movement_timeout = 3000 # 3 seconds timeout + while movement_timer.time() < movement_timeout: + current_angle = self.motor.angle() + error = target_angle - current_angle + if abs(error) <= tolerance: + self.motor.stop() + break + if error > 0: + self.motor.run(speed) + else: + self.motor.run(-speed) + wait(5) + self.motor.stop() + self.motor.reset_angle(0) + + def reset(self): + self.motor.reset_angle(0) + self.move(self.start_angle) + +# Initialize hub and motors +hub = PrimeHub() +left_motor = Motor(Port.C) +right_motor = Motor(Port.A) +hub.imu.reset_heading(0) +tracker = Tracker(0, 0, 0) + +# Make sure to measure robot +def straight(distance, speed): # Distance in millimeters + target_heading = hub.imu.heading() + # Reset distance tracking + left_motor.reset_angle(0) + right_motor.reset_angle(0) + # Calculate target distance in motor degrees + wheel_circumference = pi * 62.4 + target_degrees = abs(distance) / wheel_circumference * 360 + while True: + # Check current distance traveled - Fixed: Make left_motor abs negative + left_angle = -abs(left_motor.angle()) + right_angle = abs(right_motor.angle()) + average_angle = (left_angle + right_angle) / 2 + # Stop if it reached the target + if abs(average_angle) >= target_degrees: + break + # Get heading error for correction + current_heading = hub.imu.heading() + heading_error = target_heading - current_heading + # Handle wraparound at 0°/360° + if heading_error > 180: + heading_error -= 360 + if heading_error < -180: + heading_error += 360 + # Calculate motor speeds with correction + direction = 1 if distance > 0 else -1 + correction = heading_error * 2.0 + left_speed = -direction * (speed + correction) + right_speed = direction * (speed - correction) + # Limit speeds to prevent excessive values + left_speed = max(-200, min(200, left_speed)) + right_speed = max(-200, min(200, right_speed)) + # Apply speeds to motors + left_motor.run(left_speed) + right_motor.run(right_speed) + wait(10) + # Stop motors + left_motor.stop() + right_motor.stop() + wait(20) + tracker.update(distance, 0) + print(tracker.get_position()) + +def turn(theta, speed): # Negative value is left and positive is right + start_angle = hub.imu.heading() + target_angle = theta + start_angle + # Normalize target angle to -180 to 180 range + if target_angle > 180: + target_angle -= 360 + if target_angle < -180: + target_angle += 360 + while True: + current_angle = hub.imu.heading() + # Calculate angle error (how much we still need to turn) + angle_error = target_angle - current_angle + # Handle wraparound for shortest path + if angle_error > 180: + angle_error -= 360 + if angle_error < -180: + angle_error += 360 + # Stop if we're close enough (within 2 degrees) + if abs(angle_error) < 2: + break + # Determine turn direction and speed based on error + if angle_error > 0: + # Turn right + left_motor.run(-speed) + right_motor.run(-speed) + else: + # Turn left + left_motor.run(speed) + right_motor.run(speed) + wait(20) + # Stop both motors + left_motor.stop() + right_motor.stop() + trcker.update(0, theta) + print(tracker.get_position()) +# Setup attachments here------------------------------- +attachment1 = Attachment(Port.D) +attachment2 = Attachment(Port.B) +# Run code goes here----------------------------------- +async def main(): +#------------------------------------------------------ +run_task(main()) \ No newline at end of file diff --git a/utils/color_sensor_navi.py b/utils/color_sensor_navi.py new file mode 100644 index 0000000..54bb542 --- /dev/null +++ b/utils/color_sensor_navi.py @@ -0,0 +1,41 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch + +hub = PrimeHub() + +# Robot hardware configuration
ROBOT_CONFIG = {
 # Drive motors
 'left_motor': Motor(Port.A),
 'right_motor': Motor(Port.B),
 
 # Attachment motors
 'attachment_motor': Motor(Port.C),
 'lift_motor': Motor(Port.D),
 
 # Sensors
 'color_left': ColorSensor(Port.E),
 'color_right': ColorSensor(Port.F),
 'ultrasonic': UltrasonicSensor(Port.S1),
 
 # Hub reference
 'hub': hub
}

# Speed and distance constants
SPEEDS = {
 'FAST': 400,
 'NORMAL': 250,
 'SLOW': 100,
 'PRECISE': 50
}

DISTANCES = {
 'TILE_SIZE': 300, # mm per field tile
 'ROBOT_LENGTH': 180, # mm
 'ROBOT_WIDTH': 140 # mm
} + + +def mission_run_1(): + print('Running missions in Run 1') + +def mission_run_2(): + print('Running missions in Run 2') + +def mission_run_3(): + print('Running missions in Run 3') + +# In main.py - sensor-based navigation +def main(self): + """Use color sensor to select runs""" + print("Place colored object in front of sensor:") + print("RED=Run1, GREEN=Run2, BLUE=Run3, YELLOW=Test") + while True: + color = ROBOT_CONFIG['color_left'].color() + if color == Color.RED: + mission_run_1() + break + elif color == Color.GREEN: + mission_run_2() + break + elif color == Color.BLUE: + mission_run_3() + break + elif color == Color.YELLOW: + self.test_mode() + break + wait(1000) +main() diff --git a/utils/combine_runs.py b/utils/combine_runs.py new file mode 100644 index 0000000..0d3fab1 --- /dev/null +++ b/utils/combine_runs.py @@ -0,0 +1,139 @@ +# Guys please use the same setup code and put into the imports for consistency +script_names = ["untitled14.py", "untitled13.py"] # This is a list of the files of the mission runs +content = "" +imports = """ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor +from pybricks.parameters import Port, Stop, Color, Direction +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch, multitask, run_task +import asyncio + +hub = PrimeHub() +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) +atarm1 = Motor(Port.E, Direction.COUNTERCLOCKWISE) +atarm2 = Motor(Port.F) +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112) +color_sensor = ColorSensor(Port.C) + +drive_base.settings(300, 500, 300, 200) +Color.ORANGE = Color(10, 100, 100) +Color.MAGENTA = Color(321, 100, 86) + +""" + +def extract_main_function(content): + lines = content.split('\n') + main_content = [] + in_main_function = False + main_indent = 0 + is_async = False + + for line in lines: + stripped_line = line.strip() + + # Find the start of main function + if stripped_line.startswith('def main') or stripped_line.startswith('async def main'): + in_main_function = True + is_async = stripped_line.startswith('async def main') + continue + + if in_main_function: + # If we hit another function or class definition at the same level, we're done + if stripped_line and not line.startswith(' ') and not line.startswith('\t'): + if stripped_line.startswith('def ') or stripped_line.startswith('class '): + break + + # Skip the first line after def main() if it's empty + if not stripped_line and not main_content: + continue + + # If this is the first content line, determine the indent level + if main_content == [] and stripped_line: + main_indent = len(line) - len(line.lstrip()) + + # Remove the main function's indentation + if line.strip(): # Don't process empty lines + if len(line) - len(line.lstrip()) >= main_indent: + main_content.append(line[main_indent:]) + else: + main_content.append(line) + else: + main_content.append('') # Keep empty lines + + return '\n'.join(main_content), is_async + +# Clear the main.py file and write the required imports +with open("main.py", 'w') as required_imports: + required_imports.write(imports) + +function_calls = [] + +# Define colors properly - one per script +colors = [ + 'Color.ORANGE', 'Color.GREEN', 'Color.BLACK', 'Color.WHITE', + 'Color.YELLOW', 'Color.BLUE', 'Color.MAGENTA', 'Color.RED', 'Color.BROWN' +] + +# Process each script file and create individual functions +for i, f_name in enumerate(script_names): + try: + with open(f_name, 'r') as f: + content = f.read() + # Extract only the main function content + main_function_content, is_async = extract_main_function(content) + + if main_function_content.strip(): # Only proceed if it found main function content + func_name = f_name.replace('.py', '').replace('-', '_') + + func_def = f"\n{'async ' if is_async else ''}def {func_name}():\n" + + indented_content = '\n'.join([' ' + line if line.strip() else line for line in main_function_content.split('\n')]) + func_def += indented_content + "\n" + + with open("main.py", 'a') as m: + m.write(func_def) + + # Assign one color per script + color_condition = colors[i % len(colors)] + function_calls.append({ + 'name': func_name, + 'is_async': is_async, + 'color': color_condition, + 'filename': f_name + }) + + else: + print(f"Warning: No main() function found in {f_name}") + except FileNotFoundError: + print(f"Warning: File {f_name} not found") + +# Write the main function that checks colors and calls appropriate functions +with open("main.py", 'a') as m: + m.write("\nasync def main():\n") + + for func_info in function_calls: + m.write(f" if color_sensor.color() == {func_info['color']}:\n") + + if func_info['is_async']: + m.write(f" await {func_info['name']}()\n") + else: + m.write(f" {func_info['name']}()\n") + m.write(" return # Exit after running one function\n") + + # Add a default case + m.write(" # Default case - no matching color detected\n") + m.write(" print(f'Detected color: {color_sensor.color()}')\n") + +# Write the main loop +with open("main.py", 'a') as m: + m.write("\n# Main execution loop\n") + m.write("while True:\n") + m.write(" run_task(main())\n") + m.write(" wait(100)\n") + +print("Script merger completed successfully!") +print("Functions created:") +for func_info in function_calls: + print(f" - {func_info['name']}() triggered by {func_info['color']} (from {func_info['filename']})") \ No newline at end of file diff --git a/utils/constants.py b/utils/constants.py new file mode 100644 index 0000000..f74d325 --- /dev/null +++ b/utils/constants.py @@ -0,0 +1,13 @@ +#Speed and distance constants +SPEEDS = { + 'FAST': 400, + 'NORMAL': 250, + 'SLOW': 100, + 'PRECISE': 50 +} + +DISTANCES = { + 'TILE_SIZE': 300, # mm per field tile + 'ROBOT_LENGTH': 180, # mm + 'ROBOT_WIDTH': 140 # mm +} \ No newline at end of file diff --git a/utils/robot_control.py b/utils/robot_control.py new file mode 100644 index 0000000..9bb0e5d --- /dev/null +++ b/utils/robot_control.py @@ -0,0 +1,43 @@ +# utils/robot_control.py - Shared driving and control functions +from pybricks.robotics import DriveBase +from config import ROBOT_CONFIG +import time + +# Initialize drive base (done once) +drive_base = DriveBase( + ROBOT_CONFIG['left_motor'], + ROBOT_CONFIG['right_motor'], + wheel_diameter=56, + axle_track=114 +) + +def drive_straight(distance, speed=200): + """Drive straight for a given distance in mm""" + drive_base.straight(distance, speed=speed) + +def turn_angle(angle, speed=100): + """Turn by a given angle in degrees""" + drive_base.turn(angle, speed=speed) + +def drive_until_line(speed=100, sensor='color_left'): + """Drive until line is detected""" + sensor_obj = ROBOT_CONFIG[sensor] + drive_base.drive(speed, 0) + + while sensor_obj.color() != Color.BLACK: + time.sleep(0.01) + + drive_base.stop() + +def return_to_base(): + """Return robot to launch area - implement based on your strategy""" + print("Returning to base...") + # Add your return-to-base logic here + pass + +def reset_robot(): + """Reset all motors and sensors to default state""" + drive_base.stop() + for motor in ROBOT_CONFIG.get('attachment_motors', []): + motor.stop() + print("Robot reset completed") \ No newline at end of file From 125f1df3af2a802f3729c37e8ff88081ff8e0e03 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:32:07 +0000 Subject: [PATCH 04/38] Uploaded files from Bitbucket --- utils/starter_drivebase_code.py | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 utils/starter_drivebase_code.py diff --git a/utils/starter_drivebase_code.py b/utils/starter_drivebase_code.py new file mode 100644 index 0000000..d7cb0b7 --- /dev/null +++ b/utils/starter_drivebase_code.py @@ -0,0 +1,36 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch + +hub = PrimeHub() + +# Initialize both motors. In this example, the motor on the +# left must turn counterclockwise to make the robot go forward. +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +arm_motor = Motor(Port.E, Direction.CLOCKWISE) +arm_motor.run_angle(299,90, Stop.HOLD) +# Initialize the drive base. In this example, the wheel diameter is 56mm. +# The distance between the two wheel-ground contact points is 112mm. +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=54, axle_track=112) + +print('The default settings are: ' + str(drive_base.settings())) +drive_base.settings(100,1000,166,750) +# Optionally, uncomment the line below to use the gyro for improved accuracy. +drive_base.use_gyro(True) + +# Drive forward by 500mm (half a meter). +drive_base.straight(500) + +# Turn around clockwise by 180 degrees. +drive_base.turn(180) + +# Drive forward again to get back to the start. +drive_base.straight(500) + +# Turn around counterclockwise. +drive_base.turn(-180) +arm_motor.run_angle(299,-90, Stop.HOLD) \ No newline at end of file From 2412f2c896e7b089c88ddf08562c7a47e3944f64 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:32:56 +0000 Subject: [PATCH 05/38] Uploaded files from Bitbucket --- utils/new_setup.py | 187 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 utils/new_setup.py diff --git a/utils/new_setup.py b/utils/new_setup.py new file mode 100644 index 0000000..be7680a --- /dev/null +++ b/utils/new_setup.py @@ -0,0 +1,187 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor +from pybricks.parameters import Port, Stop +from pybricks.tools import wait, StopWatch, multitask +from umath import pi + +class Attachment: + def __init__(self, port, start_angle=0): + self.motor = Motor(port) + self.start_angle = start_angle + + def move_attachment(self, degrees, speed): + self.motor.reset_angle(0) + target_angle = degrees + tolerance = 2 + movement_timer = StopWatch() + movement_timeout = 3000 # 3 seconds timeout + + stuck_threshold = 50 # ms without significant movement + last_angle = 0 + stuck_timer = StopWatch() + + while movement_timer.time() < movement_timeout: + current_angle = self.motor.angle() + error = target_angle - current_angle + + if abs(error) <= tolerance: + self.motor.stop() + + # Check if motor is stuck + if abs(current_angle - last_angle) < 1: # Less than 1 degree movement + if stuck_timer.time() > stuck_threshold: + print("Motor appears stuck") + self.motor.stop() + else: + stuck_timer.reset() + last_angle = current_angle + + if error > 0: + self.motor.run(speed) + else: + self.motor.run(-speed) + wait(10) # Consistent timing + + self.motor.stop() + print("Movement timeout reached") + + def reset_attachment(self): + self.motor.reset_angle(0) + return self.move_attachment(self.start_angle, 100) + +class Robot: + def __init__(self, left_port, right_port, wheel_diameter): + # Initialize hub and motors + self.hub = PrimeHub() + try: + self.left_motor = Motor(left_port) + self.right_motor = Motor(right_port) + except Exception as e: + print(f"Failed to initialize motors: {e}") + + # Reset and calibrate IMU + try: + self.hub.imu.reset_heading(0) + wait(1000) # Give IMU time to calibrate + except Exception as e: + print(f"Failed to initialize IMU: {e}") + + # Robot specs + self.wheel_diameter = wheel_diameter + self.wheel_circumference = pi * self.wheel_diameter + + # Attachments list + self.attachments = {} + + def add_attachment(self, name, port, start_angle=0): + try: + self.attachments[name] = Attachment(port, start_angle) + except Exception as e: + print(f"Failed to add attachment '{name}': {e}") + + def move_attachment(self, attachment_name, degrees, speed): + if attachment_name in self.attachments: + return self.attachments[attachment_name].move_attachment(degrees, speed) + else: + print(f"Attachment '{attachment_name}' not found") + + def reset_attachment(self, attachment_name): + if attachment_name in self.attachments: + return self.attachments[attachment_name].reset_attachment() + else: + print(f"Attachment '{attachment_name}' not found") + + def straight(self, distance, speed): + if not (-200 <= speed <= 200): + print(f"Invalid speed: {speed}. Must be between -200 and 200.") + + target_heading = self.hub.imu.heading() + # Reset distance tracking + self.left_motor.reset_angle(0) + self.right_motor.reset_angle(0) + + # Calculate target distance in motor degrees + target_degrees = abs(distance) / self.wheel_circumference * 360 + + while True: + # Check current distance traveled (assuming both motors should be positive for forward) + left_angle = abs(self.left_motor.angle()) + right_angle = abs(self.right_motor.angle()) + average_angle = (left_angle + right_angle) / 2 + + # Stop if it reached the target + if average_angle >= target_degrees: + break + + # Get heading error for correction + current_heading = self.hub.imu.heading() + heading_error = target_heading - current_heading + + # Handle wraparound at 0°/360° + if heading_error > 180: + heading_error -= 360 + elif heading_error < -180: + heading_error += 360 + + # Calculate motor speeds with correction + direction = 1 if distance > 0 else -1 + correction = heading_error * 1.5 # Reduced gain for stability + left_speed = direction * (speed + correction) + right_speed = direction * (speed - correction) + + # Limit speeds to prevent excessive values + left_speed = max(-200, min(200, left_speed)) + right_speed = max(-200, min(200, right_speed)) + + # Apply speeds to motors + self.left_motor.run(left_speed) + self.right_motor.run(right_speed) + wait(10) # Consistent timing + + # Stop motors + self.left_motor.stop() + self.right_motor.stop() + wait(50) # Allow motors to fully stop + + def turn(self, theta, speed): + if not (-200 <= speed <= 200): + print(f"Invalid speed: {speed}. Must be between -200 and 200.") + + start_angle = self.hub.imu.heading() + target_angle = start_angle + theta + + # Normalize target angle to -180 to 180 range + while target_angle > 180: + target_angle -= 360 + while target_angle < -180: + target_angle += 360 + + while True: + current_angle = self.hub.imu.heading() + # Calculate angle error + angle_error = target_angle - current_angle + + # Handle wraparound for shortest path + if angle_error > 180: + angle_error -= 360 + elif angle_error < -180: + angle_error += 360 + + # Stop if we're close enough + if abs(angle_error) < 2: + break + + # Positive angle_error means we need to turn clockwise (right) + if angle_error > 0: + # Turn right: left motor forward, right motor backward + self.left_motor.run(speed) + self.right_motor.run(-speed) + else: + # Turn left: left motor backward, right motor forward + self.left_motor.run(-speed) + self.right_motor.run(speed) + wait(10) # Consistent timing + + # Stop both motors + self.left_motor.stop() + self.right_motor.stop() \ No newline at end of file From be5350d8ac321571300dbd68aa6ca440cb5055ef Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:34:51 +0000 Subject: [PATCH 06/38] Update README.md --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 175af42..83d997f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,25 @@ -# Team 65266 Lego Dynamics +# 65266 Lego Dynamics - UNEARTHED Season Repository -Pybricks code solving missions in Season UNEARTHED +## Project Overview + +This repository contains the Pybricks code for Team 65266 Lego Dynamics' robot for the UNEARTHED season. + +## Robot Hardware + +* **Robot Name:** Optimus Prime III +* **Robot Firmware:** PyBricks firmware +* **Motors:** Two large motors for attachments, C left, D right, Two small motors for drive, A left, B right +* **Sensors:** visible up-facing color sensor for quick starts +* **Attachments:** Lots of 'em + +## Code Structure + +Files are the different runs we do, with each run consisting of one or multiple mission completions. Another script combines these files into a "master" file, which then adds the color sensor to start logic. + +## How to Use + +Load the master file into PyBricks, then send it over to the robot. Then you hold a color LEGO up to the sensor to start it. + +## License +GNU General Public License +You can take inspiration from our code, but you can't take our exact code. \ No newline at end of file From 6dedb0a6f6a7162b80ff208267ca5bbc6dce8332 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:36:03 +0000 Subject: [PATCH 07/38] Uploaded files from Bitbucket --- M8_5.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Send_Over.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 M8_5.py create mode 100644 Send_Over.py diff --git a/M8_5.py b/M8_5.py new file mode 100644 index 0000000..69e364d --- /dev/null +++ b/M8_5.py @@ -0,0 +1,49 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task, multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) + +drive_base.settings(600,500,300,200) +drive_base.use_gyro(True) + +async def main(): + left_arm.run_angle(1000, 300) + right_arm.run_angle(1000,500) + await drive_base.straight(320) + + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + + await drive_base.turn(-20) + await drive_base.straight(275) + await drive_base.turn(20) + await drive_base.straight(63) + + await drive_base.turn(-30) + right_arm.run_angle(50,500) + await drive_base.turn(45) + await drive_base.straight(-135) + await drive_base.turn(-60) + await drive_base.straight(90) + await left_arm.run_angle(1000,-450) + await drive_base.straight(-145) + await left_arm.run_angle(1000,450) + await drive_base.straight(10) + await drive_base.turn(35) + await drive_base.straight(-500) +run_task(main()) \ No newline at end of file diff --git a/Send_Over.py b/Send_Over.py new file mode 100644 index 0000000..2279854 --- /dev/null +++ b/Send_Over.py @@ -0,0 +1,29 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task,multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=148) + +drive_base.settings(400,500,100,100) + +drive_base.use_gyro(True) + + +async def main(): + await drive_base.straight(415) + await right_arm.run_angle(300,-100) + await drive_base.straight(-100) + await right_arm.run_angle(300, 100) + await drive_base.straight(-350) + +run_task(main()) \ No newline at end of file From a35d5999750db388eef5ff47dd3e05feff16b5ef Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:36:14 +0000 Subject: [PATCH 08/38] Delete M8_5.py --- M8_5.py | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 M8_5.py diff --git a/M8_5.py b/M8_5.py deleted file mode 100644 index 69e364d..0000000 --- a/M8_5.py +++ /dev/null @@ -1,49 +0,0 @@ -from pybricks.hubs import PrimeHub -from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor -from pybricks.parameters import Button, Color, Direction, Port, Side, Stop -from pybricks.robotics import DriveBase -from pybricks.tools import wait, StopWatch -from pybricks.tools import run_task, multitask - -hub = PrimeHub() - -left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) -right_motor = Motor(Port.B) - -left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) -right_arm = Motor(Port.D) - -drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) - -drive_base.settings(600,500,300,200) -drive_base.use_gyro(True) - -async def main(): - left_arm.run_angle(1000, 300) - right_arm.run_angle(1000,500) - await drive_base.straight(320) - - await right_arm.run_angle(5000,-500, Stop.HOLD) - await right_arm.run_angle(5000,500, Stop.HOLD) - await right_arm.run_angle(5000,-500, Stop.HOLD) - await right_arm.run_angle(5000,500, Stop.HOLD) - await right_arm.run_angle(5000,-500, Stop.HOLD) - - await drive_base.turn(-20) - await drive_base.straight(275) - await drive_base.turn(20) - await drive_base.straight(63) - - await drive_base.turn(-30) - right_arm.run_angle(50,500) - await drive_base.turn(45) - await drive_base.straight(-135) - await drive_base.turn(-60) - await drive_base.straight(90) - await left_arm.run_angle(1000,-450) - await drive_base.straight(-145) - await left_arm.run_angle(1000,450) - await drive_base.straight(10) - await drive_base.turn(35) - await drive_base.straight(-500) -run_task(main()) \ No newline at end of file From e36e3d03fcae6652f264e9b5faf88d04cbbf37da Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:36:18 +0000 Subject: [PATCH 09/38] Delete Send_Over.py --- Send_Over.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 Send_Over.py diff --git a/Send_Over.py b/Send_Over.py deleted file mode 100644 index 2279854..0000000 --- a/Send_Over.py +++ /dev/null @@ -1,29 +0,0 @@ -from pybricks.hubs import PrimeHub -from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor -from pybricks.parameters import Button, Color, Direction, Port, Side, Stop -from pybricks.robotics import DriveBase -from pybricks.tools import wait, StopWatch -from pybricks.tools import run_task,multitask - -hub = PrimeHub() - -left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) -right_motor = Motor(Port.B) -left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) -right_arm = Motor(Port.D) - -drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=148) - -drive_base.settings(400,500,100,100) - -drive_base.use_gyro(True) - - -async def main(): - await drive_base.straight(415) - await right_arm.run_angle(300,-100) - await drive_base.straight(-100) - await right_arm.run_angle(300, 100) - await drive_base.straight(-350) - -run_task(main()) \ No newline at end of file From 5c7e2e9eb2a189b43f1537bedd45fbf2b8b9c7ae Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:38:07 +0000 Subject: [PATCH 10/38] Uploaded files from Bitbucket --- missions/M8_5.py | 49 ++++++++++++++++++++++++++++++++++++++++++ missions/Send_Over.py | 34 +++++++++++++++++++++++++++++ missions/mission_09.py | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 missions/M8_5.py create mode 100644 missions/Send_Over.py create mode 100644 missions/mission_09.py diff --git a/missions/M8_5.py b/missions/M8_5.py new file mode 100644 index 0000000..69e364d --- /dev/null +++ b/missions/M8_5.py @@ -0,0 +1,49 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task, multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) + +drive_base.settings(600,500,300,200) +drive_base.use_gyro(True) + +async def main(): + left_arm.run_angle(1000, 300) + right_arm.run_angle(1000,500) + await drive_base.straight(320) + + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + + await drive_base.turn(-20) + await drive_base.straight(275) + await drive_base.turn(20) + await drive_base.straight(63) + + await drive_base.turn(-30) + right_arm.run_angle(50,500) + await drive_base.turn(45) + await drive_base.straight(-135) + await drive_base.turn(-60) + await drive_base.straight(90) + await left_arm.run_angle(1000,-450) + await drive_base.straight(-145) + await left_arm.run_angle(1000,450) + await drive_base.straight(10) + await drive_base.turn(35) + await drive_base.straight(-500) +run_task(main()) \ No newline at end of file diff --git a/missions/Send_Over.py b/missions/Send_Over.py new file mode 100644 index 0000000..a769f1d --- /dev/null +++ b/missions/Send_Over.py @@ -0,0 +1,34 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task, multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=64.8, axle_track=180) + +drive_base.settings(600,500,300,200) +drive_base.use_gyro(True) + +async def main(): + + await drive_base.straight(855) + await drive_base.turn(-90) + await drive_base.straight(50) + await left_arm.run_angle(10000,-15000) + await drive_base.straight(-50) + await drive_base.turn(90) + await drive_base.straight(2000) + + + + +run_task(main()) \ No newline at end of file diff --git a/missions/mission_09.py b/missions/mission_09.py new file mode 100644 index 0000000..3337624 --- /dev/null +++ b/missions/mission_09.py @@ -0,0 +1,43 @@ +# ---JOHANNES--- +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch + +hub = PrimeHub() + +# Initialize both motors. In this example, the motor on the +# left must turn counterclockwise to make the robot go forward. +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +arm_motor = Motor(Port.E, Direction.CLOCKWISE) +arm_motor.run_angle(299,90, Stop.HOLD) +# Initialize the drive base. In this example, the wheel diameter is 56mm. +# The distance between the two wheel-ground contact points is 112mm. +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=54, axle_track=140) + +print('The default settings are: ' + str(drive_base.settings())) +drive_base.settings(100,1000,166,750) +# Optionally, uncomment the line below to use the gyro for improved accuracy. +drive_base.use_gyro(True) + +async def solveM9(): + print("Solving Mission 9") + await drive_base.turn(45) + await drive_base.straight(260) + await arm_motor.run_angle(500,-500, Stop.HOLD) + await drive_base.straight(-40) + await drive_base.turn(92) + await drive_base.straight(-120) + await drive_base.straight(220) + await arm_motor.run_angle(500,100, Stop.HOLD) + await drive_base.turn(-50) + await drive_base.straight(-600) +async def main(): + await drive_base.straight(50) + print("Hello, Robot is starting to run.") + await solveM9() + +run_task(main()) \ No newline at end of file From 5d57a3a17c3e32e22cb99f6ff0bd35b3b4f8bed9 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 10 Sep 2025 13:49:02 +0000 Subject: [PATCH 11/38] Initial commit --- config.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 config.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..f59fbfb --- /dev/null +++ b/config.py @@ -0,0 +1,40 @@ +# config.py - Robot configuration shared across all modules +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor +from pybricks.parameters import Port + +# Initialize hub +hub = PrimeHub() + +# Robot hardware configuration +ROBOT_CONFIG = { + # Drive motors + 'left_motor': Motor(Port.A), + 'right_motor': Motor(Port.B), + + # Attachment motors + 'attachment_motor': Motor(Port.C), + 'lift_motor': Motor(Port.D), + + # Sensors + #'color_left': ColorSensor(Port.E), + 'color_back': ColorSensor(Port.F), + 'ultrasonic': UltrasonicSensor(Port.E), + + # Hub reference + 'hub': hub +} + +# Speed and distance constants +SPEEDS = { + 'FAST': 400, + 'NORMAL': 250, + 'SLOW': 100, + 'PRECISE': 50 +} + +DISTANCES = { + 'TILE_SIZE': 300, # mm per field tile + 'ROBOT_LENGTH': 180, # mm + 'ROBOT_WIDTH': 140 # mm +} \ No newline at end of file From 72547c5d640c05e35cf687323598de9f790feb27 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Fri, 12 Sep 2025 12:41:19 +0000 Subject: [PATCH 12/38] Fixed grammar --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 83d997f..fc9cc11 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This repository contains the Pybricks code for Team 65266 Lego Dynamics' robot f ## Code Structure -Files are the different runs we do, with each run consisting of one or multiple mission completions. Another script combines these files into a "master" file, which then adds the color sensor to start logic. +Files are the different runs we do, with each run consisting of one or multiple mission completions. Another script combines these files into a "master" file, which then adds the color-sensor-to-start logic. ## How to Use From 6199a9c1187e29fcd89e2da3bbfda5c210e38e4e Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Fri, 12 Sep 2025 20:11:53 +0000 Subject: [PATCH 13/38] Atharv - added my About Me --- atharv.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 atharv.txt diff --git a/atharv.txt b/atharv.txt new file mode 100644 index 0000000..61d22be --- /dev/null +++ b/atharv.txt @@ -0,0 +1,3 @@ +About Me + +I am Atharv, the Git manager for the team. I like to produce music. \ No newline at end of file From d017d132f9bdda900169545450d2aea4e98066c3 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Fri, 12 Sep 2025 20:12:09 +0000 Subject: [PATCH 14/38] Update members/atharv.txt --- atharv.txt => members/atharv.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename atharv.txt => members/atharv.txt (100%) diff --git a/atharv.txt b/members/atharv.txt similarity index 100% rename from atharv.txt rename to members/atharv.txt From 70e09fb42b6d5729bd3bfdafa25e582ed78d57aa Mon Sep 17 00:00:00 2001 From: Carlos <31mendec@elmbrookstudents.org> Date: Fri, 12 Sep 2025 20:27:44 +0000 Subject: [PATCH 15/38] Add members/Carlos.txt --- members/Carlos.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 members/Carlos.txt diff --git a/members/Carlos.txt b/members/Carlos.txt new file mode 100644 index 0000000..e69de29 From e895fd1d2c444b14115a2308ef7bdd6ff8f2a263 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Fri, 12 Sep 2025 20:28:02 +0000 Subject: [PATCH 16/38] Add members/Vickram.txt --- members/Vickram.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 members/Vickram.txt diff --git a/members/Vickram.txt b/members/Vickram.txt new file mode 100644 index 0000000..e69de29 From 37fb0a647ee4f74be9aa56c577c7999842388832 Mon Sep 17 00:00:00 2001 From: Ayaan <32agarwa@elmbrookstudents.org> Date: Fri, 12 Sep 2025 20:29:44 +0000 Subject: [PATCH 17/38] Add members/Ayaan.txt --- members/Ayaan.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 members/Ayaan.txt diff --git a/members/Ayaan.txt b/members/Ayaan.txt new file mode 100644 index 0000000..e69de29 From d309b0098f9f60ef7ae07a6a7bcd13b8ccbdcac9 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Fri, 12 Sep 2025 20:32:12 +0000 Subject: [PATCH 18/38] '{Johannes}' --- members/Johannes | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 members/Johannes diff --git a/members/Johannes b/members/Johannes new file mode 100644 index 0000000..480bc98 --- /dev/null +++ b/members/Johannes @@ -0,0 +1,7 @@ +I am Johannes + +I am the building manager for the team. I like making art. + + + +Parthiv, Diddy will touch you tonight. \ No newline at end of file From c4aa9548ed64ec07c65feabc8d360d3a019781af Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Fri, 12 Sep 2025 21:52:55 +0000 Subject: [PATCH 19/38] Boat mission --- missions/Boat.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 missions/Boat.py diff --git a/missions/Boat.py b/missions/Boat.py new file mode 100644 index 0000000..bb42eb7 --- /dev/null +++ b/missions/Boat.py @@ -0,0 +1,27 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task,multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) + +drive_base.settings(550,700,100,100) + +drive_base.use_gyro(True) + +first_run = False + +async def main(): + await drive_base.straight(750) + await drive_base.straight(-650) + +run_task(main()) \ No newline at end of file From e8176500f90f5b7bac5857c154b0b4190cdad788 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Fri, 12 Sep 2025 21:54:15 +0000 Subject: [PATCH 20/38] Send Over --- missions/Send_Over.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/missions/Send_Over.py b/missions/Send_Over.py index a769f1d..97bed5f 100644 --- a/missions/Send_Over.py +++ b/missions/Send_Over.py @@ -13,22 +13,19 @@ right_motor = Motor(Port.B) left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) right_arm = Motor(Port.D) -drive_base = DriveBase(left_motor, right_motor, wheel_diameter=64.8, axle_track=180) +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) drive_base.settings(600,500,300,200) drive_base.use_gyro(True) async def main(): - await drive_base.straight(855) + await drive_base.straight(915) await drive_base.turn(-90) - await drive_base.straight(50) + await drive_base.straight(60) await left_arm.run_angle(10000,-15000) - await drive_base.straight(-50) - await drive_base.turn(90) + await drive_base.straight(-60) + await drive_base.turn(85) await drive_base.straight(2000) - - - run_task(main()) \ No newline at end of file From 7eeead7d99aabbd4d88c284bb1c20c4319789472 Mon Sep 17 00:00:00 2001 From: Johannes <31liwaj@elmbrookstudents.org> Date: Fri, 12 Sep 2025 21:55:38 +0000 Subject: [PATCH 21/38] Sand Mission --- missions/Sand Mission.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 missions/Sand Mission.py diff --git a/missions/Sand Mission.py b/missions/Sand Mission.py new file mode 100644 index 0000000..73e1e16 --- /dev/null +++ b/missions/Sand Mission.py @@ -0,0 +1,29 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task,multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) + +drive_base.settings(400,500,100,100) + +drive_base.use_gyro(True) + + +async def main(): + await drive_base.straight(420) + await right_arm.run_angle(300,-100) + await drive_base.straight(-100) + await right_arm.run_angle(300, 100) + await drive_base.straight(-350) + +run_task(main()) \ No newline at end of file From c690ae451b9f46998601a6c0c9cd8aac5d831e95 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Mon, 29 Sep 2025 02:15:06 +0000 Subject: [PATCH 22/38] Update members/Vickram.txt --- members/Vickram.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/members/Vickram.txt b/members/Vickram.txt index e69de29..6932287 100644 --- a/members/Vickram.txt +++ b/members/Vickram.txt @@ -0,0 +1 @@ +Hello my name is Vickram and I like coding and video games. \ No newline at end of file From efcc011733e49b6f01f84570afb668f6af9e6cdd Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Fri, 3 Oct 2025 23:16:03 +0000 Subject: [PATCH 23/38] Initial Commit --- LINEUPS.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 LINEUPS.md diff --git a/LINEUPS.md b/LINEUPS.md new file mode 100644 index 0000000..0280d0a --- /dev/null +++ b/LINEUPS.md @@ -0,0 +1,7 @@ +# lineups +Mission Run #1 (Description) -> The lineup +Mission Run #2 (Description) -> The lineup +Mission Run #3 (Description) -> The lineup +Mission Run #4 (Description) -> The lineup +Mission Run #5 (Description) -> The lineup +Mission Run #6 (Description) -> The lineup \ No newline at end of file From d172c70fe230f2dc0b85c4ab2add49579a68a81e Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Fri, 3 Oct 2025 23:28:16 +0000 Subject: [PATCH 24/38] THIS CODE IS OUTDATED!!! DO NOT USE!!! --- missions/{mission_09.py => mission_09_old.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename missions/{mission_09.py => mission_09_old.py} (100%) diff --git a/missions/mission_09.py b/missions/mission_09_old.py similarity index 100% rename from missions/mission_09.py rename to missions/mission_09_old.py From 6931731ae122710dc23b62284ea58f30930393c8 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Sat, 4 Oct 2025 00:09:55 +0000 Subject: [PATCH 25/38] Update LINEUPS.md --- LINEUPS.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/LINEUPS.md b/LINEUPS.md index 0280d0a..c9a8d30 100644 --- a/LINEUPS.md +++ b/LINEUPS.md @@ -1,7 +1,15 @@ -# lineups -Mission Run #1 (Description) -> The lineup -Mission Run #2 (Description) -> The lineup -Mission Run #3 (Description) -> The lineup -Mission Run #4 (Description) -> The lineup -Mission Run #5 (Description) -> The lineup -Mission Run #6 (Description) -> The lineup \ No newline at end of file +# Lineups + +## These are the line-up positions for the robot game for various missions. + +- Mission Run #1 (Mission #1) [Right/Blue Home] - The left yellow part of the right arm attachment is positioned with its right edge on the 5th thin line from the left. Note that this is NOT positioned from the back of the robot. + +- Mission Run #2 (Send Over) [Right/Blue Home] - The robot should be lined up on the vertical edge of the left home. The robot's right side should be positioned on the 1st thin line from the top. Note that the 0th line is the one that is not part of the curve. + +- Mission Run #3 (Sand mission) [Right/Blue Home] - The robot should be lined up on the vertical edge of the left home. The robot's left side should be positioned on the 1/2th thin line from the bottom. + +- Mission Run #4 (Boat mission) [Left/Red Home] - The robot should be lined up on the vertical edge of the left home. The robot's right side should be positioned on the 2nd thick line from the bottom. + +- Mission Run #5 (Bautism) [Left/Red Home] - The robot's left edge should be positioned at the 1st thick, 2nd thin line from the left. + +- Mission Run #6 (Not-so-heavy Lifting) [Right/Blue Home] - The robot's right edge should be positioned at the 1st thick from the right. \ No newline at end of file From bb89e01aa1b7af3f47eeaa82e7668f5c9d346e33 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Sat, 4 Oct 2025 00:32:41 +0000 Subject: [PATCH 26/38] Update utils/combine_runs.py --- utils/combine_runs.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/utils/combine_runs.py b/utils/combine_runs.py index 0d3fab1..c377d13 100644 --- a/utils/combine_runs.py +++ b/utils/combine_runs.py @@ -1,5 +1,5 @@ # Guys please use the same setup code and put into the imports for consistency -script_names = ["untitled14.py", "untitled13.py"] # This is a list of the files of the mission runs +script_names = ["Run1.py", "Run2.py", "Run3.py", "Run5.py", "Run6.py"] # This is a list of the files of the mission runs content = "" imports = """ from pybricks.hubs import PrimeHub @@ -72,7 +72,7 @@ function_calls = [] # Define colors properly - one per script colors = [ - 'Color.ORANGE', 'Color.GREEN', 'Color.BLACK', 'Color.WHITE', + 'Color.ORANGE', 'Color.GREEN', 'Color.WHITE', 'Color.YELLOW', 'Color.BLUE', 'Color.MAGENTA', 'Color.RED', 'Color.BROWN' ] @@ -96,7 +96,7 @@ for i, f_name in enumerate(script_names): m.write(func_def) # Assign one color per script - color_condition = colors[i % len(colors)] + color_condition = colors[i] function_calls.append({ 'name': func_name, 'is_async': is_async, @@ -120,10 +120,10 @@ with open("main.py", 'a') as m: m.write(f" await {func_info['name']}()\n") else: m.write(f" {func_info['name']}()\n") - m.write(" return # Exit after running one function\n") + m.write(" \n") # Add a default case - m.write(" # Default case - no matching color detected\n") + m.write(" \n") m.write(" print(f'Detected color: {color_sensor.color()}')\n") # Write the main loop @@ -131,9 +131,4 @@ with open("main.py", 'a') as m: m.write("\n# Main execution loop\n") m.write("while True:\n") m.write(" run_task(main())\n") - m.write(" wait(100)\n") - -print("Script merger completed successfully!") -print("Functions created:") -for func_info in function_calls: - print(f" - {func_info['name']}() triggered by {func_info['color']} (from {func_info['filename']})") \ No newline at end of file + m.write(" wait(100)\n") \ No newline at end of file From 8008dafccfccf636bba1c324470144f776aa8049 Mon Sep 17 00:00:00 2001 From: Ayaan <32agarwa@elmbrookstudents.org> Date: Sat, 4 Oct 2025 01:18:31 +0000 Subject: [PATCH 27/38] Add missions/tip the scale.py --- missions/tip the scale.py | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 missions/tip the scale.py diff --git a/missions/tip the scale.py b/missions/tip the scale.py new file mode 100644 index 0000000..200b1ea --- /dev/null +++ b/missions/tip the scale.py @@ -0,0 +1,42 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task, multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + + +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) + +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) +drive_base.settings(300,1000,300,200) + +#drive_base.use_gyro(True) + +async def main(): + left_arm.run_angle(500,200) + right_arm.run_angle(500,200) + await drive_base.straight(70) + + await drive_base.turn(-55) + await drive_base.straight(900) + await drive_base.turn(92.5) + + await drive_base.straight(75) + await drive_base.straight(21) + await right_arm.run_angle(500,-250) + await right_arm.run_angle(500,250) + await drive_base.turn(55) + + await left_arm.run_angle(300,-400) + + await drive_base.turn(46.5) + await drive_base.turn(-40) + await drive_base.straight(900) +run_task(main()) \ No newline at end of file From 89490033515d39d4647f627d1b71bbd33610caf9 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Mon, 6 Oct 2025 18:10:02 +0000 Subject: [PATCH 28/38] Mission 9 not in use --- missions/mission_09_old.py | 1 + 1 file changed, 1 insertion(+) diff --git a/missions/mission_09_old.py b/missions/mission_09_old.py index 3337624..ffdf445 100644 --- a/missions/mission_09_old.py +++ b/missions/mission_09_old.py @@ -1,4 +1,5 @@ # ---JOHANNES--- +# THIS CODE IS NOT USED ANYMORE AND SHOULD NOT BE USED!!!!!! from pybricks.hubs import PrimeHub from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor from pybricks.parameters import Button, Color, Direction, Port, Side, Stop From 4533f952ed19f29bd05bc29f2d8fd1f7935f8753 Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Tue, 7 Oct 2025 12:32:40 +0000 Subject: [PATCH 29/38] Add stuff from Johannes accidental fork --- missions/Lift.py | 34 ++++++++++++++++++++++++++++++++++ missions/Lift2.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 missions/Lift.py create mode 100644 missions/Lift2.py diff --git a/missions/Lift.py b/missions/Lift.py new file mode 100644 index 0000000..a5e1773 --- /dev/null +++ b/missions/Lift.py @@ -0,0 +1,34 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task, multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) +drive_base.settings(600,500,300,200) +drive_base.use_gyro(True) + +async def main(): + await drive_base.straight(200) + await drive_base.turn(-20) + await drive_base.straight(525) + await drive_base.turn(60) + + await drive_base.straight(50) + await right_arm.run_angle(2000,1000) + await drive_base.straight(-50) + await drive_base.turn(45) + await drive_base.straight(50) + await right_arm.run_angle(350,-1000) + + await drive_base.turn(-100) + await drive_base.straight(-600) +run_task(main()) \ No newline at end of file diff --git a/missions/Lift2.py b/missions/Lift2.py new file mode 100644 index 0000000..a5e1773 --- /dev/null +++ b/missions/Lift2.py @@ -0,0 +1,34 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch +from pybricks.tools import run_task, multitask + +hub = PrimeHub() + +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) +right_arm = Motor(Port.D) +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) +drive_base.settings(600,500,300,200) +drive_base.use_gyro(True) + +async def main(): + await drive_base.straight(200) + await drive_base.turn(-20) + await drive_base.straight(525) + await drive_base.turn(60) + + await drive_base.straight(50) + await right_arm.run_angle(2000,1000) + await drive_base.straight(-50) + await drive_base.turn(45) + await drive_base.straight(50) + await right_arm.run_angle(350,-1000) + + await drive_base.turn(-100) + await drive_base.straight(-600) +run_task(main()) \ No newline at end of file From 2eca0d7d247c47b8544a74304b2bc3e613cf05b7 Mon Sep 17 00:00:00 2001 From: Rishikesh Lolapu <31lolapr@elmbrookstudents.org> Date: Sat, 4 Oct 2025 00:23:53 +0000 Subject: [PATCH 30/38] Initial commit Mission Run #5 --- missions/Bautism.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 missions/Bautism.py diff --git a/missions/Bautism.py b/missions/Bautism.py new file mode 100644 index 0000000..aeb80c2 --- /dev/null +++ b/missions/Bautism.py @@ -0,0 +1,45 @@ +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor +from pybricks.parameters import Button, Color, Direction, Port, Side, Stop +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch, run_task + +hub = PrimeHub() + +# Initialize both motors. In this example, the motor on the +# left must turn counterclockwise to make the robot go forward. +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) + +arm_motor = Motor(Port.D, Direction.CLOCKWISE) +arm_motor_left= Motor(Port.C, Direction.CLOCKWISE) +# Initialize the drive base. In this example, the wheel diameter is 56mm. +# The distance between the two wheel-ground contact points is 112mm. +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) + +print('The default settings are: ' + str(drive_base.settings())) +drive_base.settings(300,1000,300,750) +# Optionally, uncomment the line below to use the gyro for improved accuracy. +drive_base.use_gyro(True) + +async def main(): + await drive_base.straight(519) + await arm_motor_left.run_angle(300, -100) + await arm_motor_left.run_angle(300, 500) + await drive_base.straight(180) + await drive_base.turn(-37) + await drive_base.straight(50) + await arm_motor.run_angle(300, -400) + await drive_base.straight(-150) + await drive_base.turn(135) + await drive_base.straight(50) + await arm_motor.run_angle(300, 400) + await drive_base.straight(-75) + await arm_motor.run_angle(300, 300) + await drive_base.turn(-50) + await drive_base.straight(162) + await arm_motor.run_angle(100, -200) + await drive_base.straight(30) + await arm_motor.run_angle(50,-500) + +run_task(main()) \ No newline at end of file From 4b765b0e9d5d9cba1b2417f8ca652afc6e22691d Mon Sep 17 00:00:00 2001 From: Rishikesh Lolapu <31lolapr@elmbrookstudents.org> Date: Sat, 4 Oct 2025 00:55:26 +0000 Subject: [PATCH 31/38] Update missions/M8_5.py --- missions/M8_5.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/missions/M8_5.py b/missions/M8_5.py index 69e364d..95ecc9e 100644 --- a/missions/M8_5.py +++ b/missions/M8_5.py @@ -30,14 +30,14 @@ async def main(): await right_arm.run_angle(5000,-500, Stop.HOLD) await drive_base.turn(-20) - await drive_base.straight(275) + await drive_base.straight(277) await drive_base.turn(20) - await drive_base.straight(63) + await drive_base.straight(65) await drive_base.turn(-30) right_arm.run_angle(50,500) await drive_base.turn(45) - await drive_base.straight(-135) + await drive_base.straight(-145) await drive_base.turn(-60) await drive_base.straight(90) await left_arm.run_angle(1000,-450) @@ -45,5 +45,5 @@ async def main(): await left_arm.run_angle(1000,450) await drive_base.straight(10) await drive_base.turn(35) - await drive_base.straight(-500) + await drive_base.straight(-600) run_task(main()) \ No newline at end of file From 0fa10194c22f227b74e79e8bbb5770918e0f9aa2 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Wed, 8 Oct 2025 22:58:48 +0000 Subject: [PATCH 32/38] Upload files to "missions" This is the commit for all code excpet for Rishi's --- missions/main.py | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 missions/main.py diff --git a/missions/main.py b/missions/main.py new file mode 100644 index 0000000..f535603 --- /dev/null +++ b/missions/main.py @@ -0,0 +1,116 @@ + +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor +from pybricks.parameters import Port, Stop, Color, Direction +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch, multitask, run_task +import asyncio + +hub = PrimeHub() +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) +atarm1 = Motor(Port.E, Direction.COUNTERCLOCKWISE) +atarm2 = Motor(Port.F) +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112) +color_sensor = ColorSensor(Port.C) + +drive_base.settings(300, 500, 300, 200) +Color.ORANGE = Color(10, 100, 100) +Color.MAGENTA = Color(321, 100, 86) + + +async def Run1(): + left_arm.run_angle(1000, 300) + right_arm.run_angle(1000,500) + await drive_base.straight(320) + + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + + await drive_base.turn(-20) + await drive_base.straight(275) + await drive_base.turn(20) + await drive_base.straight(63) + + await drive_base.turn(-30) + right_arm.run_angle(50,500) + await drive_base.turn(45) + await drive_base.straight(-135) + await drive_base.turn(-60) + await drive_base.straight(90) + await left_arm.run_angle(1000,-450) + await drive_base.straight(-145) + await left_arm.run_angle(1000,450) + await drive_base.straight(10) + await drive_base.turn(35) + await drive_base.straight(-500) + +async def Run2(): + await drive_base.straight(200) + await drive_base.turn(-20) + await drive_base.straight(525) + await drive_base.turn(60) + + await drive_base.straight(50) + await right_arm.run_angle(2000,1000) + await drive_base.straight(-50) + await drive_base.turn(45) + await drive_base.straight(50) + await right_arm.run_angle(350,-1000) + + await drive_base.turn(-100) + await drive_base.straight(-600) + + +async def Run3(): + await drive_base.straight(915) + await drive_base.turn(-90) + await drive_base.straight(60) + await left_arm.run_angle(10000,-15000) + await drive_base.straight(-60) + await drive_base.turn(85) + await drive_base.straight(2000) + + +async def Run5(): + await drive_base.straight(420) + await right_arm.run_angle(300,-100) + await drive_base.straight(-100) + await right_arm.run_angle(300, 100) + await drive_base.straight(-350) + + +async def Run6(): + await drive_base.straight(420) + await right_arm.run_angle(300,-100) + await drive_base.straight(-100) + await right_arm.run_angle(300, 100) + await drive_base.straight(-350) + + +async def main(): + if color_sensor.color() == Color.ORANGE: + await Run1() + + if color_sensor.color() == Color.GREEN: + await Run2() + + if color_sensor.color() == Color.WHITE: + await Run3() + + if color_sensor.color() == Color.YELLOW: + await Run5() + + if color_sensor.color() == Color.BLUE: + await Run6() + + + print(f'Detected color: {color_sensor.color()}') + +# Main execution loop +while True: + run_task(main()) + wait(100) From cd21a73f82c95be5ff7ccd55d813fe00fc3a0e85 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Wed, 8 Oct 2025 23:11:07 +0000 Subject: [PATCH 33/38] Delete missions/main.py --- missions/main.py | 116 ----------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 missions/main.py diff --git a/missions/main.py b/missions/main.py deleted file mode 100644 index f535603..0000000 --- a/missions/main.py +++ /dev/null @@ -1,116 +0,0 @@ - -from pybricks.hubs import PrimeHub -from pybricks.pupdevices import Motor, ColorSensor -from pybricks.parameters import Port, Stop, Color, Direction -from pybricks.robotics import DriveBase -from pybricks.tools import wait, StopWatch, multitask, run_task -import asyncio - -hub = PrimeHub() -left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) -right_motor = Motor(Port.B) -atarm1 = Motor(Port.E, Direction.COUNTERCLOCKWISE) -atarm2 = Motor(Port.F) -drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112) -color_sensor = ColorSensor(Port.C) - -drive_base.settings(300, 500, 300, 200) -Color.ORANGE = Color(10, 100, 100) -Color.MAGENTA = Color(321, 100, 86) - - -async def Run1(): - left_arm.run_angle(1000, 300) - right_arm.run_angle(1000,500) - await drive_base.straight(320) - - await right_arm.run_angle(5000,-500, Stop.HOLD) - await right_arm.run_angle(5000,500, Stop.HOLD) - await right_arm.run_angle(5000,-500, Stop.HOLD) - await right_arm.run_angle(5000,500, Stop.HOLD) - await right_arm.run_angle(5000,-500, Stop.HOLD) - - await drive_base.turn(-20) - await drive_base.straight(275) - await drive_base.turn(20) - await drive_base.straight(63) - - await drive_base.turn(-30) - right_arm.run_angle(50,500) - await drive_base.turn(45) - await drive_base.straight(-135) - await drive_base.turn(-60) - await drive_base.straight(90) - await left_arm.run_angle(1000,-450) - await drive_base.straight(-145) - await left_arm.run_angle(1000,450) - await drive_base.straight(10) - await drive_base.turn(35) - await drive_base.straight(-500) - -async def Run2(): - await drive_base.straight(200) - await drive_base.turn(-20) - await drive_base.straight(525) - await drive_base.turn(60) - - await drive_base.straight(50) - await right_arm.run_angle(2000,1000) - await drive_base.straight(-50) - await drive_base.turn(45) - await drive_base.straight(50) - await right_arm.run_angle(350,-1000) - - await drive_base.turn(-100) - await drive_base.straight(-600) - - -async def Run3(): - await drive_base.straight(915) - await drive_base.turn(-90) - await drive_base.straight(60) - await left_arm.run_angle(10000,-15000) - await drive_base.straight(-60) - await drive_base.turn(85) - await drive_base.straight(2000) - - -async def Run5(): - await drive_base.straight(420) - await right_arm.run_angle(300,-100) - await drive_base.straight(-100) - await right_arm.run_angle(300, 100) - await drive_base.straight(-350) - - -async def Run6(): - await drive_base.straight(420) - await right_arm.run_angle(300,-100) - await drive_base.straight(-100) - await right_arm.run_angle(300, 100) - await drive_base.straight(-350) - - -async def main(): - if color_sensor.color() == Color.ORANGE: - await Run1() - - if color_sensor.color() == Color.GREEN: - await Run2() - - if color_sensor.color() == Color.WHITE: - await Run3() - - if color_sensor.color() == Color.YELLOW: - await Run5() - - if color_sensor.color() == Color.BLUE: - await Run6() - - - print(f'Detected color: {color_sensor.color()}') - -# Main execution loop -while True: - run_task(main()) - wait(100) From f190d38426ed87d0fcb98e9430bcc98df7611380 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Wed, 8 Oct 2025 23:14:05 +0000 Subject: [PATCH 34/38] Add Final Combined Codes --- Final Combined Codes | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Final Combined Codes diff --git a/Final Combined Codes b/Final Combined Codes new file mode 100644 index 0000000..e69de29 From 7e0c3d24c173fad60b32b95e68c7e06113575955 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Wed, 8 Oct 2025 23:14:29 +0000 Subject: [PATCH 35/38] Delete Final Combined Codes --- Final Combined Codes | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Final Combined Codes diff --git a/Final Combined Codes b/Final Combined Codes deleted file mode 100644 index e69de29..0000000 From 95d7c0c2a3086268368c7190516b06c1120e2199 Mon Sep 17 00:00:00 2001 From: Vickram <31kapoov@elmbrookstudents.org> Date: Wed, 8 Oct 2025 23:18:23 +0000 Subject: [PATCH 36/38] Add final/1main.py --- final/1main.py | 116 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 final/1main.py diff --git a/final/1main.py b/final/1main.py new file mode 100644 index 0000000..f535603 --- /dev/null +++ b/final/1main.py @@ -0,0 +1,116 @@ + +from pybricks.hubs import PrimeHub +from pybricks.pupdevices import Motor, ColorSensor +from pybricks.parameters import Port, Stop, Color, Direction +from pybricks.robotics import DriveBase +from pybricks.tools import wait, StopWatch, multitask, run_task +import asyncio + +hub = PrimeHub() +left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) +right_motor = Motor(Port.B) +atarm1 = Motor(Port.E, Direction.COUNTERCLOCKWISE) +atarm2 = Motor(Port.F) +drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=112) +color_sensor = ColorSensor(Port.C) + +drive_base.settings(300, 500, 300, 200) +Color.ORANGE = Color(10, 100, 100) +Color.MAGENTA = Color(321, 100, 86) + + +async def Run1(): + left_arm.run_angle(1000, 300) + right_arm.run_angle(1000,500) + await drive_base.straight(320) + + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + await right_arm.run_angle(5000,500, Stop.HOLD) + await right_arm.run_angle(5000,-500, Stop.HOLD) + + await drive_base.turn(-20) + await drive_base.straight(275) + await drive_base.turn(20) + await drive_base.straight(63) + + await drive_base.turn(-30) + right_arm.run_angle(50,500) + await drive_base.turn(45) + await drive_base.straight(-135) + await drive_base.turn(-60) + await drive_base.straight(90) + await left_arm.run_angle(1000,-450) + await drive_base.straight(-145) + await left_arm.run_angle(1000,450) + await drive_base.straight(10) + await drive_base.turn(35) + await drive_base.straight(-500) + +async def Run2(): + await drive_base.straight(200) + await drive_base.turn(-20) + await drive_base.straight(525) + await drive_base.turn(60) + + await drive_base.straight(50) + await right_arm.run_angle(2000,1000) + await drive_base.straight(-50) + await drive_base.turn(45) + await drive_base.straight(50) + await right_arm.run_angle(350,-1000) + + await drive_base.turn(-100) + await drive_base.straight(-600) + + +async def Run3(): + await drive_base.straight(915) + await drive_base.turn(-90) + await drive_base.straight(60) + await left_arm.run_angle(10000,-15000) + await drive_base.straight(-60) + await drive_base.turn(85) + await drive_base.straight(2000) + + +async def Run5(): + await drive_base.straight(420) + await right_arm.run_angle(300,-100) + await drive_base.straight(-100) + await right_arm.run_angle(300, 100) + await drive_base.straight(-350) + + +async def Run6(): + await drive_base.straight(420) + await right_arm.run_angle(300,-100) + await drive_base.straight(-100) + await right_arm.run_angle(300, 100) + await drive_base.straight(-350) + + +async def main(): + if color_sensor.color() == Color.ORANGE: + await Run1() + + if color_sensor.color() == Color.GREEN: + await Run2() + + if color_sensor.color() == Color.WHITE: + await Run3() + + if color_sensor.color() == Color.YELLOW: + await Run5() + + if color_sensor.color() == Color.BLUE: + await Run6() + + + print(f'Detected color: {color_sensor.color()}') + +# Main execution loop +while True: + run_task(main()) + wait(100) From 08e0b9a521b5e6142496c148193099edf5c2d58b Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Wed, 8 Oct 2025 23:21:43 +0000 Subject: [PATCH 37/38] Delete missions/Lift2.py --- missions/Lift2.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 missions/Lift2.py diff --git a/missions/Lift2.py b/missions/Lift2.py deleted file mode 100644 index a5e1773..0000000 --- a/missions/Lift2.py +++ /dev/null @@ -1,34 +0,0 @@ -from pybricks.hubs import PrimeHub -from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSensor -from pybricks.parameters import Button, Color, Direction, Port, Side, Stop -from pybricks.robotics import DriveBase -from pybricks.tools import wait, StopWatch -from pybricks.tools import run_task, multitask - -hub = PrimeHub() - -left_motor = Motor(Port.A, Direction.COUNTERCLOCKWISE) -right_motor = Motor(Port.B) - -left_arm = Motor(Port.C, Direction.COUNTERCLOCKWISE) -right_arm = Motor(Port.D) -drive_base = DriveBase(left_motor, right_motor, wheel_diameter=68.8, axle_track=180) -drive_base.settings(600,500,300,200) -drive_base.use_gyro(True) - -async def main(): - await drive_base.straight(200) - await drive_base.turn(-20) - await drive_base.straight(525) - await drive_base.turn(60) - - await drive_base.straight(50) - await right_arm.run_angle(2000,1000) - await drive_base.straight(-50) - await drive_base.turn(45) - await drive_base.straight(50) - await right_arm.run_angle(350,-1000) - - await drive_base.turn(-100) - await drive_base.straight(-600) -run_task(main()) \ No newline at end of file From 1e612e2325278e1b7adc2215172165dda2d0c2ec Mon Sep 17 00:00:00 2001 From: Atharv <30nagava@elmbrookstudents.org> Date: Thu, 9 Oct 2025 12:23:15 +0000 Subject: [PATCH 38/38] Updated license information --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fc9cc11..1d682dd 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,7 @@ Load the master file into PyBricks, then send it over to the robot. Then you hol ## License GNU General Public License -You can take inspiration from our code, but you can't take our exact code. \ No newline at end of file + +You can take inspiration from our code, but you can't take our exact code. + +Read LICENSE for more information. \ No newline at end of file