Skip to content

real-time processing of imu on desktop sampled from esp32 -- transferred via serial or wifi

Notifications You must be signed in to change notification settings

plusk01/esp32imu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real-time IMU Processing from ESP32

Supporting software to stream IMU (ICM-42688-p) connected to ESP32 via SPI onto desktop computer via serial or WiFi. Serial/UDP IO is handled in C++ and exposed to Python with pybind11.

Getting Started

This repo provides the esp32imu Python package to allow easy access to the hardware from Python. The Python package includes C++ serial and UDP drivers for quickly communicating with the esp32. The C++ is hidden from the user via pybind11.

Once esp32imu is installed on your machine, you will be able to quickly plot data (see Examples below) like:

Building from Source

Linux / MacOS

After cloning this project onto your computer:

  1. Build C++ driver with Python bindings (requires Boost):
mkdir build
cd build
cmake ..
make

Once the package builds successfully, you can install the esp32imu Python package as described below.

Windows

Compilation of this package has been tested on a Windows 10 machine. The environment was setup as follows. Explicit versions used are listed, but these steps are expected to work with reasonably recent versions of these tools.

  1. Install git bash (2.30.1)
  2. Install CMake (3.19.5)
  3. Install Python (3.9.1)
  4. Install Visual Studio Community or Professional (Pro 2019, v16.8.5 with MSVC 14.28.29333)
  5. Install Boost (1.75.0, boost_1_75_0-msvc-14.2-64.exe)

Once the development environment is setup, use git bash (or cmd) to run the following commands

$ git clone https://github.com/plusk01/esp32imu # clone this repo in your preferred directory
$ cd esp32imu
$ mkdir build
$ cd build
$ cmake -DBUILD_SHARED_LIBS=OFF ..
$ cmake --build . --target ALL_BUILD --config Release # or open in VS: start esp32imu.sln
$ cmake --build . --target pypkg --config Release # to tar python pkg

Once the package builds successfully, you can install the esp32imu Python package as described below.

Installing Python Package from Source

Install the built-from-source Python package with pip:

cd build
make pip-install

Note: On windows, if the make pip-install command doesn't work, you will need to manually install the python package with

cd build/bindings/python
python -m pip install .

Check that esp32imu is properly installed by opening a new terminal and running python -m pip list and looking for the esp32imu package. Further, run python and import esp32imu and dir(esp32imu) - you should see a list of esp32imu attributes, including SerialDriver.

Setting up the ESP32 firmware

Flash ESP32 with firmware_serial/firmware_serial.ino sketch for serial comm and firmware_udp/firmware_udp.ino for WiFi/UDP.

Examples

See an IMU data plot in real-time with the examples/main.py file.

Attitude Estimation

You can use the esp32imu package for attitude estimation demos. To enable assessing algorithm accuracy, a cube can be built so that true pitch and roll angles can always be identified.

Creating New Messages

To create new or change existing messages, changes need to be made in esp32imu.h and in serial_driver.cpp. For these changes to appear in Python, py_teensyimu.cpp also needs to be changed. For an example of necessary changes, see this commit where two new messages (IMU_NoMag and IMU_3DOF) were added.

If messages are changed, this project must be built from source.

Board Pinout

About

real-time processing of imu on desktop sampled from esp32 -- transferred via serial or wifi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published