[Media] GSim-RS - A G-code simulator in Rust, now with volumetric stock simulation.

117 points NavrajKalsi 7 comments
[Media] GSim-RS - A G-code simulator in Rust, now with volumetric stock simulation.

Hi there, thanks for clicking on this post!

A few months back I published the first version of gsim-rs. A G-code simulator for CNC milling machines supporting the Fanuc flavour of G-code.

Now I have completed the next major version. This version:

  • Supports volumetric simulation of cuboidal stocks.
  • Stock and tool sizes can now be configured with program config.
  • Cross-thread communication frequency is fraction of what it used to be (by using both Arc<Mutex> and mpsc::channel, depending on the type of data and its importance).
  • The simulation now supports orbiting, panning and zooming.
  • And much more.

I have tried to explain and highlight the workings of the program in the project README.

At a high level, the program is split between parsing, interpreting, geometry construction, simulation rendering, and machine-state rendering. GUI (rendered using WGPU) handles G-code parsing and execution and renders the simulation in the main-thread, while TUI (built with Ratatui) displays active machine state in a new thread.

Easily the most interesting part was implementing the volumetric stock simulation. The stock is represented volumetrically, with the tool removing material as it moves through the stock. I also wrote a blog post explaining my approach and some of the interesting challenges I ran into: My Blog

I would appreciate if you took some time to take a look at the project and offer any feedback, comment, criticism or suggestion. If you have any questions regarding my implementation, I would love to talk more!

Github: https://github.com/navrajkalsi/gsim-rs

Thank you!

AI Usage: All code is written solely by me. The architecture is also designed without any input from any LLM. Claude & ChatGPT were used to brainstorm ideas and research available tools.