bw / simu

Created 7 months ago
Maintained by bw
simu
Members 2
Ivan Mahonin committed 3 months ago
simu - is the program for generation and simulation gcode (track) files for CNC

simu - is the public domain


currently implemented only 4-axis milling (rotate model around X axis)
simulator simulates all four axes, but generator uses only three: X, Z and Angle

in the world exists a lot of opensource XYZ generators but XZA is the rare,
so i implement it first for my CNC

i hope it will easy to implement classic XYZ miling (basreliefs), can you?


requirements:
    SDL2

build:
    just run build.sh
    executable file is ./simu
    
    if you want to build it for windows (i have not tried)
    you need to compile and link all *.cpp files in current folder
    and link libSDL2

run:
    ./simu <file-to-simulate.tap|.> [<model.stl|.> [output-generated-file.tap|.]]
    
    in other words first argument is always filename of input gcode for simulation,
    if you does not need this just set the dot as first arg

    second argument is always input model in binary STL format,
    you may set the dot to do not load model

    third argument is always filename for output gcode,
    you may set the dot too
    
    
    you cannot generate something without a model
    you cannot generate something if you use simulaton arg
    
examples:
    simulate already generated gcode:
        ./simu file.tap
    
    simulate already generated gcode and show the target model:
        ./simu file.tap model.stl
        
    just show the model:
        ./simu . model.stl
        in this mode you can move the tool by W, S, A, D keys
        to check how collision detection works

    generate gcode from model:
        ./simu . model.stl newfile.tap

    
    in all modes use the left mouse button to rotate camera,
    right button to zoom and middle button to translate

options:
    - looks easy but where the other options - cutter shape, strateg, layers etc?
    - in the code
    
    first look function main() in main.cpp
        this line sets the simulatior options:
            SimulatorXYZA simulator_xyza(400, 360);
        - simulatior is XYZA with resolution along X axis is 400 samples,
          angular resolution is 360 samples per round
          see: simulator.h, simulator.cpp

        these lines configure a tool:
            //FlatTool tool(1.5);
            ConeTool tool(1.25, 10, 0.75);
        - base radius, height of cone part, small radius at the end of cone (can be zero)
          see: tool.h, tool.cpp
          
        direction of the tool for testing:
            Vector3 dir(1, 3, -3);
        - when you pass only model as argument (./simu . model.stl)
        you can move the tool manually (by WSAD) and see how collision detector works
        this line determines direction (angle) of the tool
        
        look down in parsing third arg there is lines to configure generator:
            GeneratorRowsZAX generator;
            //generator.step_z = 1.5;
            generator.step_z = 0;
            //generator.step_a = 2*tool.radius*0.5;
            generator.step_a = 0.5*1.5;
            generator.step_x = 0.5;
            //generator.skip_middle_layers = true;
            generator.feed_speed = 150;

        generator supports layered milling (output/example-tux-p1.tap)
        
        step_z, mm - determines a maximum height of layer (zero for no layers, output/example-tux-p3.tap)
        step_a, mm - step along rotation in millimeters! generator will calculate degrees
        
        combination of step_z and skip_middle_layers helps to optimize final processing
        model splits to several layers (layer heigth is near to step_z) and for each layer determines an angular step
        for points near to axis of rotation angular step is bigger than for that points far from axis
        (output/example-tux-p2.tap)

        - see: generator.h, generator.cpp


    also look constructor Scene::Scene() in scene.cpp
        here you can set:
            time_forward, seconds      - draw path to the future for some seconds while path animation
            time_backward, seconds     - draw path to the past for some seconds while path animation
            time_speed, positive float - amplifier of animation speed (10 - is 10x time speed)
            move_tool, bool            - move or do not move the tool while animation
            rotate_model, bool         - rotate or do not rotate the model while animation
        
example files:
    models:
        input/example-pyramid.stl - simple shapes
        input/example-triangle.stl - single triangle
        input/example-tux-small.stl - Tux model
    gcode:
        output/example-tux-p1.tap - preprocessing of tux-small.stl for FlatTool(1.5)
        output/example-tux-p2.tap - optimized final processing of tux-small.stl for ConeTool(1.25, 10, 0.75)
        output/example-tux-p3.tap - final processing of tux-small.stl for ConeTool(1.25, 10, 0.75)