RobotGCode is a small Julia package for converting trajectory data into G-code for a robot or CNC-style motion system.
The package currently focuses on one workflow:
- read a trajectory from an HDF5 file, or
- accept a trajectory matrix directly in Julia,
- convert coordinates from meters to millimeters,
- write a
.gcodefile with absolute moves.
- Generate G-code from an HDF5 dataset at
trajectory/position - Accept in-memory trajectory matrices with shape
N x 3or3 x N - Apply a configurable coordinate offset
- Convert positions from meters to millimeters
- Emit a simple motion program with
G21,G90, linear moves, a dwell, andM2
- Julia 1.10 or newer
- The
HDF5package
The repository includes a Project.toml and Manifest.toml, so the easiest setup is to use the project environment from the repository root.
From the repository root, start Julia and activate the project:
using Pkg
Pkg.activate(".")
Pkg.instantiate()using RobotGCode
generate_gcode(
eingabe_datei = "data/slow/MMRTrajSlow.mmr",
ausgabe_datei = "output.gcode",
frame_time = 1.0,
offset = (0.0, 0.0, 110.0),
)using RobotGCode
positions = [
0.000 0.000 0.000;
0.010 0.005 0.002;
0.020 0.010 0.004;
]
generate_gcode(
positions;
ausgabe_datei = "output.gcode",
frame_time = 1.0,
offset = (0.0, 0.0, 110.0),
)using RobotGCode
curve2d = string_curve("IMTE")
curve3d = with_z(curve2d, 0.0)
points = discretize(curve3d; npoints = 200) # Nx3The HDF5 input file must contain a dataset at:
trajectory/position
The dataset should contain 3D positions in meters. Both of the following shapes are accepted:
N x 3where each row is a point3 x Nwhere each column is a point
The generated G-code:
- switches to millimeters with
G21 - uses absolute positioning with
G90 - moves through each trajectory point with
G1 - inserts a short dwell at the end of the path
- terminates with
M2
Coordinate values are converted from meters to millimeters before writing the file. The offset parameter lets you shift the trajectory into the robot's coordinate frame.
The data/ folder contains example trajectories and generated G-code files for several motion types:
slow/spiral/circular/helix/meander/lissajous/
The file data/slow/MMRTrajSlow.mmr is a sample HDF5 trajectory file that can be used immediately with generate_gcode.
src/RobotGCode.jl # Package entry point and G-code generator
data/ # Example trajectories and generated outputs
test/ # Basic package tests
Run the test suite from the repository root:
using Pkg
Pkg.activate(".")
Pkg.test()- The generator currently writes files directly and does not provide a command-line interface.
- If your robot uses a different axis convention, adjust the
offsetvalues before generating G-code.