I am in need of bending a wire to a spiral shape defined by
$$ r(\phi)=a + b\phi + c\phi^2+d\phi^3 $$
My bending machine is capable of bending circle segments with a constant radius $R$ and angle $\alpha=n\cdot \alpha_0$ and feeding straight wire with the length $l=n\cdot l_0$ where $n$ is an integer number and $\alpha_0,l_0$ are machine parameters.
Another constraint is that every straight line needs to be tangent to the next circle segment and that every circle segment needs to be followed by a straight segment, and vice versa.
Below is an image of a circle approximated by this method, but I am not sure how it would relate to a spiral path.
Does anybody have an idea how I could generate a series of circle segments and straight lines that approximates my curve with above constraints (i.e. $n\in \mathbb{N}$) such that the area integral between the original curve and the approximate path is minimized?
Ideally I would want a matlab or python script that outputs LRA (or YBC) coordinate data which is what a typical bending machine takes. ( LRA stands for length, rotation, angle for every segment where rotation would be required for a 3D shape but is not used in this case.)

I ended up writing the following script. Unfortunately, I did not get the chance to test it as my priorities shifted, and I did not figure out the springback and clearance compensations yet, but the bending commands look realistic for the spiral shape I generated for.
You can find the code and the files for my bender in my github repository https://github.com/michox/Wire-Bender/blob/main/generate_g_code.py