Skip to content

tobbelobb/hp-sim5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hp-sim5 - Hangprinter Simulator

Demo

hp-sim5 simulates the physics of Hangprinter. hp-sim5 currently simulates:

  • How lines behave
  • How spools behave
  • How motors behave
  • etc etc

The goal is to reproduce real world Hangprints as closely as possible.

The Slideprinter demo reproduces infills with resonance patterns, ringing after sharp corners, slack lines along smooth curves and even lost steps from overly aggressive moves. All these issues become easier to understand and fix with this tool.

Try the live demos:

Intended uses:

  • Hardware design -- reduce guesswork when building new machines.
  • Digital twin -- run the simulator before and during prints to optimise speed and quality while avoiding catastrophes.
  • Software design -- enables rapid firmware development and experiments with advanced control and AI.

hp-sim5 have two fully functional, equivalent implementations; one in JavaScript and one in Python. hp-sim5 includes a Cable Joints library and XPBD physics engine inspired and coded from the work of Matthias Müller.

For a deeper dive into the physics engine and the classic flipper demo see README_adv.md.

To compile and invoke the x86_64 version of ReprapFirmware, do:

cmake --build RRF/build --target rrf_simulator -j
./RRF/build/rrf_simulator --vsd RRF/run/vsd --gcode gcodes/draw_squares.gcode --can-log logs/draw_squares.csv -c sys/config_slideprinter.g

HTTP Endpoint Mode

The rrf_simulator supports an HTTP server mode for interactive G-code execution:

Starting the Server

./RRF/build/rrf_simulator \
    --vsd RRF/run/vsd \
    -c sys/config_slideprinter.g \
    --server \
    -p 8080

Endpoints

  • POST /machine/code - Execute G-code, returns reply text
  • GET /machine/status - Get server status

Example Usage

# Set torque mode
curl http://localhost:8080/machine/code -d "M569.4 P40.0 T0.001" -H "Content-Type: text/plain"
# Response: 0.001000 Nm,

# Return to position mode
curl http://localhost:8080/machine/code -d "M569.4 P40.0 T0" -H "Content-Type: text/plain"
# Response: pos_mode,

# Execute move
curl http://localhost:8080/machine/code -d "G1 X10 F1000" -H "Content-Type: text/plain"

JavaScript Integration

See examples/js/slideprinter/rrfHttpBridge.js for programmatic access.

hp-sim CLI bridge (no UI changes)

  • Start the simulator in server mode (as above), then run
    node scripts/rrf_http_bridge.mjs --server http://localhost:8080 --ws-port 8790
  • Type G-code lines into the CLI (or pass --cmd "G1 X10" for one shots); replies are printed immediately.
  • Open hp-sim locally with ?gcode_ws=ws://localhost:8790 appended to the URL so the visualization consumes the streamed motion without new UI controls.

Quick Start

Running Demos Locally

  1. Install Node.js
  2. In this repository run:
    npm install        # only needed the first time
    npx vite           # Needed every time to serve the html and js
  3. Open http://localhost:5173/hp-sim5/hp-sim in your browser. There's also http://localhost:5173/hp-sim5/flipper for the flipper demo.
  4. Hack away!

hp-sim5 context: the Hangprinter Project

hp-sim5 is part of an effort to automate the Hangprinter Project. We want to automate everything except the actual users, and digitize everything except the finished working machines and their output.

About

Simulating cables and stuff

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •