mars22 / adventures-in-motion-control

A realistic simulator for a 3D printer motion controller

Home Page:http://adventures.michaelfbryan.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adventures in Motion Control

Build Status

(API Documentation/Blog Series)

A realistic simulator for a 3D printer motion controller.

Think of this as a worked example of how embedded systems are made. The project is a lot more than just a gcode interpreter, it gives you a full-blown motion controller which behaves like a real 3D printer complete with automation sequences and diagnostics.

To follow along with the making of this project, check out the Adventures in Motion Controller blog series.

Getting Started

This project has components from two different languages, which makes building things a little... complex.

First you'll need to generate the WASM bundle for the sim crate using wasm-pack.

$ wasm-pack build --release sim
$ ls sim/pkg 
  aimc_sim.d.ts aimc_sim.js aimc_sim_bg.d.ts aimc_sim_bg.wasm package.json
  README.md sim.d.ts sim.js sim_bg.d.ts sim_bg.wasm

The generated WASM also needs to be linked into our JavaScript. The way this is normally done is by running yarn add to copy sim/pkg/*.wasm to node_modules.

$ cd frontend
$ yarn add ../sim/pkg

NOTE: It'd be better if we could use yarn link to symlink the ../sim/pkg folder once-off instead of copying files every time.

For some reason the symlinks generated by yarn link don't really work because it's not picking up new changes. If you know why, let me know!

Next, you'll need to compile the frontend JavaScript code. During development, you'll probably want to use the dev server:

$ yarn serve
  yarn start
  yarn run v1.17.3
  ℹ 「wds」: Project is running at http://localhost:8080/
  ℹ 「wds」: webpack output is served from /
  ℹ 「wds」: Content not from webpack is served from /home/michael/Documents/adventures-in-motion-control/frontend
  ℹ 「wdm」: Hash: 78364a5d221de5e26c0a
  Version: webpack 4.39.3
  Time: 2337ms
  Built at: 09/22/2019 11:05:18 PM
                             Asset       Size  Chunks             Chunk Names
                    0.bootstrap.js   17.8 KiB       0  [emitted]  
                    1.bootstrap.js   1.06 KiB       1  [emitted]  
                      bootstrap.js    372 KiB    main  [emitted]  main
  ea9e01c84ad93861b0ad.module.wasm   90.6 KiB       0  [emitted]  
                        index.html  349 bytes          [emitted]  
  Entrypoint main = bootstrap.js

Or to generate a production build:

$ yarn run build
$ ls dist 
  0.bootstrap.js 1.bootstrap.js bootstrap.js ea9e01c84ad93861b0ad.module.wasm
  index.html

If you want the code to be automatically recompiled whenever there are any changes, you can usewatchexec.

TL;DR:

watchexec \
    --clear \
    --restart \
    --ignore 'sim/pkg/*' \
    --ignore 'frontend/package.json' \
    --ignore 'frontend/yarn.lock' \
    --ignore 'frontend/node_modules/*' \
    'wasm-pack build --release sim && cd frontend && yarn add ../sim/pkg && yarn start'

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A realistic simulator for a 3D printer motion controller

http://adventures.michaelfbryan.com/

License:Apache License 2.0


Languages

Language:Rust 82.4%Language:Vue 14.9%Language:HTML 1.3%Language:TypeScript 0.7%Language:JavaScript 0.7%