Giter VIP home page Giter VIP logo

dtasm3-esp-demo's Introduction

Dtasm ESP32 demo

This is a demo for running a dtasm module on an ESP32-WROVER MCU. It demonstrates the platform-independent nature of dtasm, and its suitability for relatively modest hardware platforms. The demo is based on dtasm3, a dtasm runtime around the lightweight WebAssembly interpreter wasm3.

Requirements

  • Any ESP32 WROVER development board, e.g. Lolin D32 Pro or TTGO T8.
  • PlatformIO (e.g. Visual Studio Code with the PlatformIO extension) for building the ESP32 application.
  • WASI SDK to build the double pendulum dtasm module used by the demo.
  • A working C/C++ toolchain (e.g. gcc/g++) for your PC, as well as GNU make in your $PATH.

Steps

Be sure to clone the repo including submodules (git clone --recurse-submodules ...). Connect the ESP32 board to your PC and run these steps in the repo's root directory:

  • pio run This builds the demo application for the ESP32 target.
  • pio run -t buildfs Builds dpend_cpp.wasm dtasm module and copies to data folder, then creates an ESP32 filesystem image that contains dpend_cpp.wasm on a SPIFFS partition.
  • pio run -t uploadfs uploads the filesystem image to your ESP32,
  • pio run -t upload -t monitor uploads the application to your ESP32 and executes it.

If all goes well you should see the following output:

Reading file dpend_cpp.wasm... read 60921 bytes
Model description verifies ok
ID: {8ad29d6a-2525-4576-95be-e1facde6860e}
Name: Double Pendulum
Description: Double pendulum simulation by solving equations of motion using a simple Runge-Kutta scheme (http://www.physics.usyd.edu.au/~wheat/dpend_html/solve_dpend.c)
Generating Tool: 
 can_handle_variable_step_size: 1
 can_interpolate_inputs: 0
 can_reset_step: 0
Init returned status: OK
t,theta1,joint1.velocity,theta2,joint2.velocity
0,3.14159,0,0.0174533,0
0.1,3.14074,-0.0170964,0.0157574,-0.0336386
0.2,3.13817,-0.0342788,0.0108326,-0.064093
0.3,3.13387,-0.0519586,0.00313258,-0.088812
0.4,3.12773,-0.0712036,-0.00668981,-0.106453
0.5,3.11951,-0.0940834,-0.0179282,-0.117355
0.6,3.10868,-0.124047,-0.0300091,-0.123883
0.7,3.09429,-0.166369,-0.0427059,-0.130633
...

Congrats, you just ran the dpend_cpp dtasm module on your ESP32! Results will be exactly the same as if you executed the module on any other dtasm runtime on any platform. If you like you can visualize the simulated double pendulum motion using the provided Jupyter notebook.

Trivia

  • Why the need for a WROVER module, can the demo not run on the simpler and cheaper ESP32-WROOM series? The limition here is the RAM available to the ESP32. The provided dtasm modules make use of WASI extensions, which wasm3 only supports on ESP32 boards with PSRAM extension. In principle, if the dtasm module was compiled without WASI imports, it could work on a regular ESP32-WROOM as well.
  • Can the Rust-based dtasm modules be run on the ESP32? Rust unfortunately is not very good at compiling small binaries. There are some tricks (1, 2), but the dependency on flatbuffers makes it difficult to build dtasm modules that would fit in the memory of an ESP32.

dtasm3-esp-demo's People

Contributors

arrisde avatar

Stargazers

 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.