FrenetTB Attachment: which curve types are allowed?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
mfro
Posts: 45
Joined: Sat Sep 23, 2017 8:15 am

FrenetTB Attachment: which curve types are allowed?

Postby mfro » Wed Sep 23, 2020 8:46 am

OS: Debian GNU/Linux 10 (buster) (GNOME/gnome)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22474 (Git) AppImage
Build type: Release
Branch: master
Hash: a44f8ffd427fa9b23b1f00dbf62d66cd152cd774
Python version: 3.8.5
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: German/Germany (de_DE)

This is my first post to the forum. I'm playing with FreeCAD for quite some time (and several releases) already and recently started to make myself familiar with the Assembly 4 module.

Let me first state that I'm really impressed about the progress FreeCAD made during the last years.

My problem: I'm trying to animate parts along a path. For now, the path is a sketch (consisting of just lines and circles) and I'm working with the Frenet attachment. See attached simplified animation (the real thing is supposed to become a roller chain drive train in the end):
Peek 2020-09-23 10-22.gif
Peek 2020-09-23 10-22.gif (295.75 KiB) Viewed 346 times
Obviously, this works fine for a single arc segment of the sketch, but I would like to see part move around the whole sketch. So the question appears to be: what type of curves does the Frenet attachment accept (I only managed to use this attachment to B-splines and arcs/circles)? Is there any "compound curve" type I could use or am I expected to convert the sketch into one single B-spline?

Or is there a better approach to what I want to achieve?
Cheers,
Markus
User avatar
DeepSOIC
Posts: 7829
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: FrenetTB Attachment: which curve types are allowed?

Postby DeepSOIC » Wed Sep 23, 2020 11:16 am

Frenet-Serret coordinate system requires curvature, thus it can't work with lines.

I think you should try to apply Draft PathArray, extract placements, and use SCLERP interpolation between occurrences for smooth motion. SCLERP interpolation is available as sclerp method of App.Placement.

Code: Select all

                    sclerp(placement2, t, shorten = True): interpolate between self and placement2.
                    Interpolation is a continuous motion along a helical path, made of equal transforms if discretized.
                    t = 0.0 - return self. t = 1.0 - return placement2. t can also be outside of 0..1 range, for extrapolation.
                    If quaternions of rotations of the two placements differ in sign, the interpolation will 
                     take a long path. If 'shorten' is true, the signs are harmonized before interpolation, and the 
                     interpolation takes the shorter path.
To extract placements from Draft Arrays, use:

Code: Select all

plms = [child.Placement for child in App.ActiveDocument.Array.Shape.childShapes()]
mfro
Posts: 45
Joined: Sat Sep 23, 2017 8:15 am

Re: FrenetTB Attachment: which curve types are allowed?

Postby mfro » Wed Sep 23, 2020 5:15 pm

DeepSOIC wrote:
Wed Sep 23, 2020 11:16 am
Frenet-Serret coordinate system requires curvature, thus it can't work with lines.
Thank you, but I think this isn't really the the problem. It's that Frenet attachments appear to not accept more than one single basic curve segment. I could easily replace the straight lines with arcs with a very large radius.

I guess what I'm missing is some kind of a compound curve that the attachment would accept (tried upgrading the sketch to a wire, but FreeCAD just reports an error, even after replacing the lines with arcs)?
Cheers,
Markus
User avatar
DeepSOIC
Posts: 7829
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: FrenetTB Attachment: which curve types are allowed?

Postby DeepSOIC » Wed Sep 23, 2020 5:28 pm

mfro wrote:
Wed Sep 23, 2020 5:15 pm
Thank you, but I think this isn't really the the problem. It's that Frenet attachments appear to not accept more than one single basic curve...
Yes, it only accepts one edge. Wire support was planned, but never happened.
mfro
Posts: 45
Joined: Sat Sep 23, 2017 8:15 am

Re: FrenetTB Attachment: which curve types are allowed?

Postby mfro » Sat Sep 26, 2020 5:30 pm

DeepSOIC wrote:
Wed Sep 23, 2020 5:28 pm
mfro wrote:
Wed Sep 23, 2020 5:15 pm
Thank you, but I think this isn't really the the problem. It's that Frenet attachments appear to not accept more than one single basic curve...
Yes, it only accepts one edge. Wire support was planned, but never happened.
Thank you.

Sad, I thought.

And fixed it.
Peek 2020-09-26 19-27.gif
Peek 2020-09-26 19-27.gif (495.17 KiB) Viewed 206 times
Wasn't that difficult, actually. At least for my specific case. Need to check if I have broken any other attachment cases and will likely create a pull request soon.
Cheers,
Markus
aapo
Posts: 213
Joined: Mon Oct 29, 2018 6:41 pm

Re: FrenetTB Attachment: which curve types are allowed?

Postby aapo » Wed Oct 07, 2020 11:10 am

mfro wrote:
Sat Sep 26, 2020 5:30 pm
Sad, I thought.

And fixed it.
Hey, that's a great job! :D I stumbled upon this problem a few months ago, and the only way to get a workaround solution was to use a single B-spline, which was clearly a sub-optimal solution as you pointed out. I really hope your pull request will be accepted, there are a lot of use cases for this!
Olav
Posts: 81
Joined: Sun Nov 27, 2016 7:58 pm
Location: .nl

Re: FrenetTB Attachment: which curve types are allowed?

Postby Olav » Wed Oct 07, 2020 1:58 pm

aapo wrote:
Wed Oct 07, 2020 11:10 am
mfro wrote:
Sat Sep 26, 2020 5:30 pm
Sad, I thought.

And fixed it.
Hey, that's a great job! :D
+1. That animation looks very satisfying as well.