Ejemplo n.º 1
0
def testExploringWithMoving(get_plateau, x, y, direction, expected_x,
                            instructions, expected_y, expected_direction):
    rover = Rover(RoverPosition(RoverCoordinates(x, y), direction))
    rover.explorePlateau(instructions)
    assert (rover.position.coordinates.x
            == expected_x) and (rover.position.coordinates.y
                                == expected_y) and (rover.position.direction
                                                    == expected_direction)
Ejemplo n.º 2
0
    #Read Inputs and check its syntax
    reader = InputReader()
    reader.readInputs("InputController/roverInputs.txt")

    #Initialize Plateau
    plateauDimensions = reader.getPlateauDimensions()
    Plateau.initializePlateau(plateauDimensions)

    print(
        f"Plateau dimensions {plateauDimensions.upper_right_x}, {plateauDimensions.upper_right_y}"
    )
    print("------------------------------------------------------------------")

    #Iterate on the rovers and their instructions and start explorations in sequential order
    for p, i in reader.getRoversandInstructions():
        marsRover = Rover(p)
        Plateau.getInstance().addRover(marsRover)

        print(
            f"Input: {marsRover.position.coordinates.x} {marsRover.position.coordinates.y} {marsRover.position.direction}"
        )

        marsRover.explorePlateau(i)
        print(
            f"Output: {marsRover.position.coordinates.x} {marsRover.position.coordinates.y} {marsRover.position.direction}"
        )

        print(
            "------------------------------------------------------------------\n"
        )
Ejemplo n.º 3
0
def testRoversCollision(get_plateau, x, y, direction, instructions):
    Plateau.getInstance().addRover(
        Rover(RoverPosition(RoverCoordinates(1, 1), "N")))
    with pytest.raises(NextSpotNotEmptyException):
        rover = Rover(RoverPosition(RoverCoordinates(x, y), direction))
        rover.explorePlateau(instructions)
Ejemplo n.º 4
0
def testMoveOutsidePlateau(get_plateau, x, y, direction, expected_x,
                           instructions, expected_y, expected_direction):
    with pytest.raises(RoverOutsidePlateauException):
        rover = Rover(RoverPosition(RoverCoordinates(x, y), direction))
        rover.explorePlateau(instructions)
Ejemplo n.º 5
0
def make_rover():
    rover = Rover()

    buzzer = Buzzer(RoverPins.BUZZER_PIN)
    rover.buzzer = buzzer

    camera = Camera()
    rover.camera = camera

    g_h_servo = Servo(RoverPins.SERVO_HEADER_2)
    g_v_servo = Servo(RoverPins.SERVO_HEADER_3)
    gimbal = Gimbal(g_h_servo, g_v_servo)
    rover.gimbal = gimbal

    #TODO do rgb_led on your own
    r_led = LED(RoverPins.LED_RED_PIN)
    g_led = LED(RoverPins.LED_GREEN_PIN)
    b_led = LED(RoverPins.LED_BLUE_PIN)
    rgb_led = RGBLed(r_led, g_led, b_led)
    rover.rgb_led = rgb_led

    lf = LineFollower(RoverPins.LINE_FOLLOWER_L2_PIN,
                      RoverPins.LINE_FOLLOWER_L1_PIN,
                      RoverPins.LINE_FOLLOWER_R1_PIN,
                      RoverPins.LINE_FOLLOWER_R2_PIN)
    rover.line_follower = lf

    rd = RoverDrive(RoverPins.DRIVE_LEFT_IN1_PIN, RoverPins.DRIVE_LEFT_IN2_PIN,
                    RoverPins.DRIVE_LEFT_EN_PIN, RoverPins.DRIVE_RIGHT_IN1_PIN,
                    RoverPins.DRIVE_RIGHT_IN2_PIN,
                    RoverPins.DRIVE_RIGHT_EN_PIN)
    rover.rover_drive = rd

    s = Servo(RoverPins.SERVO_HEADER_1)
    rover.servo = s

    ping = SonarPing(RoverPins.PING_TRIGGER_PIN, RoverPins.PING_PULSE_PIN)
    rover.sonar_ping = ping

    led = LED(RoverPins.SERVO_HEADER_4)
    w = Warner(led, buzzer)
    rover.warner = w

    return rover