Skip to content

Commit

Permalink
Merge pull request #12 from IDATT1004-Team13-H2025/robot-funksjonalitet
Browse files Browse the repository at this point in the history
Laget klasser
  • Loading branch information
robinsp authored Oct 24, 2025
2 parents fd4f1d6 + a3681d4 commit f78f91c
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 4 deletions.
Empty file removed py/src/color_sensor.py
Empty file.
22 changes: 22 additions & 0 deletions py/src/drive.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
#Fil for programmering av kjøring
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.robotics import DriveBase


class Drive():
def __init__(self, motors: tuple, dimensions: tuple):
leftMotor, rightMotor = motors
wheelDiameter, axleTrack = dimensions


self.driveBase = DriveBase(leftMotor, rightMotor,
wheel_diameter=wheelDiameter, axle_track=axleTrack)


def forward(self, speed):
pass

def backward(self, speed):
pass

18 changes: 14 additions & 4 deletions py/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile

from drive import Drive
from sensors import Sensors
from robot import Robot


# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.

dimensions = ( # Wheel diamter
) #Axle track

motors = (Motor(port=Port.D), # Left motor for the drive base
Motor(port=Port.A)) # Right motor for the drive base

# Create your objects here.
ev3 = EV3Brick()
sensors = (ColorSensor(port=Port.S1), # Lyssensor for å måle fargen på jorda
UltrasonicSensor(port=Port.S2)) # Ultrasonisksensor for å sjekke for potensielle hindringer robotten må navigere unna

robotDrive = Drive(motors, dimensions) # Robottens kjørefunksjonalitet
robotSensors = Sensors(sensors) # Robottens sensorfunksjonalitet

# Write your program here.
ev3.speaker.beep()
robot = Robot(robotDrive, robotSensors) # EV3 robot
21 changes: 21 additions & 0 deletions py/src/robot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#Overklasse for all robot funksjonalitet
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile

from drive import Drive
from sensors import Sensors

class Robot():
def __init__(self, drive: Drive, sensors: Sensors):
self.hub = EV3Brick()
self.drive = drive
self.sensors = sensors



17 changes: 17 additions & 0 deletions py/src/sensors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile

class Sensors():
def __init__(self, colorSensor: ColorSensor, ultrasonicSensor: UltrasonicSensor):

self.color = colorSensor
self.ultrasonic = ultrasonicSensor


Empty file removed py/src/water.py
Empty file.
10 changes: 10 additions & 0 deletions py/src/water_bucket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

#!/usr/bin/env pybricks-micropython
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color


class WaterBucket:
def __init__(self):
pass

0 comments on commit f78f91c

Please sign in to comment.