QUB-ASL / bzzz

Quadcopter with ESP32 and RaspberryPi
MIT License
7 stars 0 forks source link

Read data from Terabee TOF sensor #162

Closed jamie-54 closed 7 months ago

jamie-54 commented 7 months ago

Main Changes

A class EvoSensor has been developed based of the Anemometer class and the Terabee sample_code repo.

Data acquisition happens in background Data is kept in a buffer

A separate file data_logger.py has been created to save recorded data that can be used for the anemometer and the TOF sensor.

filters.py has been updated to include 3 different filters that can be used for the anemometer and the TOF sensor.

Example

    filename = datetime.datetime.now().strftime("%d-%m-%y--%H-%M.csv")
    processor = MedianFilter()
    with EvoSensor(window_length=3,
                    data_processor=processor,
                    log_file=filename) as sensor:
        for i in range(20):
            time.sleep(1)
            print(sensor.distance)
        time.sleep(60)

filename is used to save the file as the current date and time. processor is set to MedianFilter().

When the EvoSensor class is called with window_length=3 and processor = MedianFilter(), every time a new measurement is received the median average well be determined from the current measurement and previous 2 measurements (3 in total). The for loop is used to print the current reading every second for 20 times and the sensor will collect data for a minute

Tests

This has been tested and works well at 15m and 60m one.

jamie-54 commented 7 months ago

Hi all, not sure what happened to old PR for this, I was trying to merge dev but whatever happened it was saying it there was 100+ file changes so I forced pushed back to the correct branch.

Anyway here is the new class for the Evo sensor I based it of the anemometer.py file and it has been tested and works

jamie-54 commented 7 months ago

May I ask what is this file data_processor_and_filters.py for and is it available for both the old and new sensor?

It works for new sensor but should work for both, it can be used to take a moving average for measurements. I've updated the PR description which should help explain