sensor = SR04(33, 35)
panTilt = PanTiltDriver()
piCam = picamera.PiCamera()

# Init some params
panStepSize = 10.0  # In Degrees
tiltStepSize = 5.0  # In Degrees
panStepDuration = 0.5  # In seconds
tiltStepDuration = 0.5  # In seconds
currentPanAngle = 0.0
currentTiltAngle = 0.0

# Go to initial position
panTilt.panLeft()
time.sleep(panStepDuration)
panTilt.tiltUp()
time.sleep(panStepDuration)

# Take a 180 degree sweep
measurements = []
try:
    while currentTiltAngle <= 45.0:
        while currentPanAngle < 180.0:
            # Take measurement and add it to the list
            imageFilePath = currentMappingDir + "/" + str(time.time()) + ".jpg"
            piCam.capture(imageFilePath)
            distance = sensor.getDistanceCM()
            measurement = Measurement(currentPanAngle, currentTiltAngle, distance, imageFilePath)
            measurements.append(measurement)

            # Continue sweep