Giter VIP home page Giter VIP logo

kalmanfilter_with_hc-sr04's Introduction

kalmanFilter_with_hc-sr04

This is a simple project to demonstrate how to use a Kalman filter to fuse multiple HC-SR04 ultrasonic sensors together

avgMeasurment Version

Libraries

ESP32 server library used: https://registry.platformio.org/libraries/madhephaestus/ESP32Servo

Standard Arduino Library: https://github.com/arduino/Arduino

Hardware

This code uses:

1 ESP32 microcontroller
3 HC-SR04 ultrasonic (US) distance sensors  
4 LEDs
1 DF9GMS servo motor.

avgMeasurment Version

The HC-SR04 has range of 2-400 cm and a baud rate of 9600.

Brief

This project aims to demonstraight the effectivness of a Kalman filter so fuse multiple sensors together to create a more ruobust measurement.

Using this improved distance measurement I attached a servo to move a "robot" to loop up at you as you approach.

Design

The basic flow is:

- measure sensors, 
- print distance,
- save distance to array,
- display distance via the LEDs and Servo.

After 10 seconds send the full array over serial to the computer. This allows the user to grab the data and graph it if desired. 

In variables.h there are two variables that allow you to change how the system behaves.

1) useKalmanFilter
        This turns on/off the Kalman filter. 
            Kalman Filter Mode: 
                When using the Kalman filter the system updates the kalman filter for all three sensors each iteration then saves the distance into the array. 
            No Kalman Filter Mode:
                When the Kalman filter is turned off the system measures all three US sensors then simply takes the average and saves that as the distance. 
2) inORcm
        Changes the units of measurment between cm and inches (0 for inches and 1 for cm)

Results

The output of the system was captured for a steady state run where a wall was 49 inches directly in front of the sensors. The resulting array was then saved to steadyStateMeasurements.ods and graphed. The graphs are saved in steadyStateMeasurements.ods and as images: kalmanFilteredMeasurements.png & 3avgedMeasurements.png

avgMeasurment Version

avgMeasurment Version

As shown in the graphs, the Kalman filtering completely eliminates the noise.

Real World Implementation

avgMeasurment Version

Below shows how the setup moves depending on the distance

NOTE: The servo moves in a smooth arch 5 discrete locations...

80cm away

avgMeasurment Version

60 cm away

avgMeasurment Version

40 cm away

avgMeasurment Version

20 cm away

avgMeasurment Version

< 20 cm away

avgMeasurment Version

kalmanfilter_with_hc-sr04's People

Contributors

gqster avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.