ebertolazzi / Clothoids

Other
106 stars 50 forks source link

idea for 3d clothoid creation. #45

Open krcwrhvgyxzqelljes opened 1 month ago

krcwrhvgyxzqelljes commented 1 month ago

Hi,

I have a idea worked out how to create a 3d non-planar clothoid using your clothoid library. I thought maybe it's worth to post it here.

To build a 3d clothoid, it projects 2 clothoids. One on the xy plane, One on the xz plane. Then it interpolates the first clothoid in t=0-1. Then for the second clothoid the x is found and the z value is the interpolation solution.

It's not a time optimal solution, but that's no problem for me as the path optimalisation is done offline. Once we have the 3d polyline, we are master kenobi.

https://github.com/krcwrhvgyxzqelljes/hal-core/blob/de4aab0b6b7ef48bc815cb4f5208e2fbc1c7bcf7/vendor/occ_draw/draw_clothoids.h#L36

The source, you only need the last pvec, as the first 2 are the projections of xy & xz clothoids. https://github.com/krcwrhvgyxzqelljes/hal-core/blob/de4aab0b6b7ef48bc815cb4f5208e2fbc1c7bcf7/vendor/occ_draw/draw_clothoids.cpp#L436

https://youtu.be/YozKQWVP-Hg

I hope you like this solution? Greetings.

ebertolazzi commented 1 month ago

Hello there, thank you for your message. What you are proposing is not a real clothoid, because you lose the linearity of curvature and torsion, which are the main point in using clothoids.

Moreover, Marco Frego has already developed 3d clothoids, see the link or the attached paper.

If you have linear curvature and torsion (e.g. k= dks, tau = dtaus), you can use the closed-form solution given by Theorem 5. If you have general affine expressions for k and tau, e.g., k= dks+k0, tau = dtaus+tau0, then there is a numerical solution given by either the Magnus integrator MG4 (Algorithm 1) or , alternatively, the symplectic commutator free Gauss-Legendre method (CF4GL) in Algorithm 2.

We haven't integrated this functions in the library yet, but we can give you a matlab code, if you cannot implement it by yourself (it is very easy and few lines).

You have to start specifying a starting point Y0 = (x0,y0,z0) and a starting tangent (t0), normal (n0), binormal (b0) vectors and then integrate the ODE, as explained in the paper.

Here is the link to the paper, or see the attached pdf https://www.sciencedirect.com/science/article/pii/S0096300321009905 1-s2.0-S0096300321009905-main.pdf

krcwrhvgyxzqelljes commented 1 month ago

Hi,

Many thanks for your responce !

Please provide the matlab code or any code related to 3d clothoids, My math level is so low i don't understand the science papers yet. I can try to translate the matlab code into c++.

In the open source cnc program i am creating, we have to produce 3d fillets for toolpath blending.

For now i use a combination of 3-arc clothoids & bspline's for 3d fillets, because we have no 3d clothoid algo that suits out of plane solutions.

80% of the time the 2d 3-arc clothoids on plane algo is valid for gcode. but in some cased a 3d clothoid is needed.

I would be very happy to get a 3d clothoid algo !! In return i can make a clothoid simulator app for you shipped as appimage, then you can run it directly on linux without any dependencies.

This looks interesting, it's a 4 segment 3d clothoid. Made by 3 chineze people with phd's. But i have no clue how to start making c++ code from this paper. https://github.com/krcwrhvgyxzqelljes/hal-core/blob/master/documents/space_corner_smoothing_3d_general_clothoid.pdf