Skip to content

WangY18/NEPath

Repository files navigation

NEPath

A Classical Toolpath and Optimization-Based Non-Equidistant Toolpath Planning Library (C++ / Python)

License

The NEPath library plans toolpaths for additive manufacturing (AM, 3D printing) and CNC milling. Toolpath planning is to generate some 1D toolpaths to filling given 2D slices. The NEPath library is able to plan the following toolpaths: (See the end of the document for visualized examples.)

  • Optimization-based non-equidistant toolpath:
    • Isoperimetric-Quotient-Optimal Toolpath (IQOP). (Recommended)
    • Variants of IQOP, like toolpaths that minimizing the perimeter, the isoperimetric quotient, and the area.
  • Classical toolpath:
    • Contour-Parallel Toolpath (CP).
    • Zigzag Toolpath.
    • Raster Toolpath.
  • Toolpath connection:
    • Connected Fermat Spiral (CFS). (Recommended)
    • Depth First Search (DFS).
  • Other functions:
    • Tool Compensating.
    • Calculating underfill rate.
    • Determining sharp corners.

Citing

If you need to use the NEPath project, please cite the following article. (Our RCIM journal paper proposed optimization-based non-equidistant toolpaths including IQOP.)

Wang Y, Hu C, Wang Z, et al. Optimization-based non-equidistant toolpath planning for robotic additive manufacturing with non-underfill orientation[J]. Robotics and Computer-Integrated Manufacturing, 2023, 84: 102599.

or in BiBTeX:

@article{wang2023optimization,
  title={Optimization-based non-equidistant toolpath planning for robotic additive manufacturing with non-underfill orientation},
  author={Wang, Yunan and Hu, Chuxiong and Wang, Ze and Lin, Shize and Zhao, Ziyan and Zhao, Wenxiang and Hu, Kehui and Huang, Zhongyi and Zhu, Yu and Lu, Zhigang},
  journal={Robotics and Computer-Integrated Manufacturing},
  volume={84},
  pages={102599},
  year={2023},
  publisher={Elsevier}
}

Statement and Dependence

  • This project cites AngusJohnson/Clipper1 as a dependent package.

  • This project depends on Gurobi OR Ipopt optimizer for solving quadratically constrained quadratic program with second-order cone constraints. If you don't need IQOP and other optimization-based toolpaths, you can unable the modules to avoid the dependence of Gurobi and Ipopt. Please refer to the tutorials for specified languages for details. We also welcome pull request if you achieve IQOP based on other optimizers.

  • The authors would like to sincerely thank Jelle Feringa for his significant contribution, providing a Python wrapper and a version that generates non-equidistant paths using IPOPT. We plan to refactor and properly repackage this library in the near future.

Supported Languages and Tutorials

The source of NEPath is achieved in C++. Based on some bindings, the supported languages include:

Introduction to IQOP

Framework

IQOP is an optimization-based non-equidistant toolpath planning method for AM and CNC milling. IQOP tries to optimize the smoothness and material cost of the child toolpath from a parent toolpath. IQOP has the following advantages:

  • Compared with the equidistant toolpath, i.e., CP, IQOP can generate smooth toolpaths. Specially, toolpaths insides tends to transform into a smooth circle.
  • IQOP can be applied for slices with arbitrary shapes and topological holes. Extra toolpaths would be added if underfill with large area exists.
  • IQOP achieves obviously lower underfill rates, higher printing efficiency, and higher toolpath smoothness than CP.
  • A general framework of non-equidistant toolpath planning for complex slices is provided.

gallery

Figure. Some demos of IQOP.

different_object_functions

Figure. Toolpaths generated by different object functions. (a) Minimize the isoperimetric-quotient to improve smoothness and obtain circles. (b) Minimize the perimeter to concentrate the vertex angles and obtain a convex polygon. (c) Minimize the area to reduce material cost to obtain equidistant toolpaths.

different_weight

Figure. Toolpaths generated by different weighting coefficient λ. The objective is to minimize Q+λS.

More details of IQOP would be provided after the article is published.

Optimization Problem of IQOP

The toolpaths can be planned by offsetting non-equidistantly. The offsetting distances $(\delta_i)_{i=1}^n$ can be seen as optimization variables. $\delta_i$ is the offsetting distance at $(x_i,y_i)$.

Underfill

Figure. Optimization variables.

Given $l$, the optimization problem for generating $\tilde{l}$ can be written as:

optimization_problem

In our paper [`Optimization-Based Non-Equidistant Toolpath Planning for Robotic Additive Manufacturing with Non-Underfill Orientation`](https://doi.org/10.1016/j.rcim.2023.102599), the above optimization problem is convexified, and the problem of self-intersection is solved. The above method can be applied for slices with arbitrary shapes and topological structures.

What can NEPath Library do?

Toolpath Generation

You can plan non-equidistant toolpaths based on different optimizer.

Based on Gurobi

IQOP-gurobi

Figure. IQOP toolpath minimizing Q based on gurobi.

IQSOP-gurobi

Figure. IQOP toolpath minimizing Q+1.0S based on gurobi.

IQLOP-gurobi

Figure. IQOP toolpath minimizing L based on gurobi.

Based on Ipopt

The IQOP paths generated by IPOPT often fail to achieve the near-perfect circularity that can be attained by Gurobi.

IQOP-ipopt

Figure. IQOP toolpath minimizing Q based on ipopt.

CP (Contour-Parallel)

You can plan traditional contour-parallel (equidistant) toolpaths.

CP

Figure. CP toolpath.

Zigzag

You can plan Zigzag toolpaths.

zigzag

Figure. Zigzag toolpath.

Raster

You can plan Raster toolpaths.

raster

Figure. Raster toolpath.

Toolpath Connection

CFS Connector

The Connected Fermat Spiral (CFS) can connect separate IQOP toolpaths into a single one. CP can be connected by CFS in the same way.

iqop_cfs

Figure. IQOP connected by CFS.

DFS Connector

The Depth First Search (DFS) approach can connect separate IQOP toolpaths into a single one. CP can be connected by DFS in the same way.

iqop_dfs

Figure. IQOP connected by DFS.

Others

Tool compensate

We recommend that the tool compensate function should be called before planning toolpaths to avoid overfill at edges of slices. Both outside and inside contours are supported.

Tool compensate

Figure. Tool compensate.

Underfill

You can determine the underfill pixel and compute the underfill rate, which are defined as follows.

optimization_problem

Underfill

Figure. Underfill. The underfill rate is 1.2401% in this example.

#### Sharp corner

You can determine sharp corners .To avoid computational sensitivity, sharp corners are determined by the area invariant defined in Helmut Pottmann, et al. 2009.

Underfill

Figure. Sharp corners. There exist 44 sharp corners in this example.