Assembly4: Strange behaviour when rotating LCS about Y axis

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
heron
Posts: 307
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by heron »

Hello keithp,
Very strange :?:
keithp wrote: Wed May 19, 2021 8:51 am I unzipped the AngleTest2 file and I see that the properties Animation Hints/Animation Hint List and Base/Expression Engine are both present in the file. They only appear in the Property pane if the Show all option is ticked (right click in the Property pane to see/change this).

Is it possible that you have Show all turned on for one document and not for the other? Another possibility is that these properties are only written to the file when it is saved, so if you hadn't saved your file after running Animate Assembly, they may not have been present.
Ok, Now I can watch them in my file too. I did the previous test in other PC, but with the same SO and Freecad and Assy4 versions. I don't know what's hapenning. This night will come back to test.
keithp wrote: Wed May 19, 2021 8:51 am I've tried different ways of creating and attaching the LCS, but I always get the strange Y axis behaviour.
My way:
- Create a new Assembly Model
- Create a new Coordinate system in a Part (LCS_1) and attach to LCS_Origin with mode XY on plane
- Add Variable -> Type : Float -> Name : rot -> Value : 0
- Select LCS_1 in model tree, select Attachment Offset/Angle field in Property View and introduce the Expression -> Variables.rot
- Set manually the Attachment Offset/Axis -> [0,00 1,00 0,00]
- Run Animate Assembly
simple_rot.png
simple_rot.png (106.56 KiB) Viewed 2419 times
- Everything is OK, File attached
keithp wrote: Wed May 19, 2021 8:51 am It would be very helpful if you could point me to the part of the manual which explains how you created your file.
For example in this tutorial: https://github.com/Zolko-123/FreeCAD_Ex ... /README.md
keithp wrote: Wed May 19, 2021 8:51 am I agree. I don't understand it either!
Are you kidding me? :lol:
I can't create 3 Variables (AngleX, AngleY, AngleZ) and without setting any expression simply by executing Animate Assembly they change the axis of rotation automatically and at the same time increase the angle attachment offset.
It would be great if you could show me your way of doing this.

Cheers!!!
Attachments
AngleTest3.FCStd
(7.56 KiB) Downloaded 64 times
heron
Posts: 307
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by heron »

Hello again,
.
keithp wrote: Wed May 19, 2021 8:51 am I unzipped the AngleTest2 file and I see that the properties Animation Hints/Animation Hint List and Base/Expression Engine are both present in the file. They only appear in the Property pane if the Show all option is ticked (right click in the Property pane to see/change this).

Is it possible that you have Show all turned on for one document and not for the other? Another possibility is that these properties are only written to the file when it is saved, so if you hadn't saved your file after running Animate Assembly, they may not have been present.
Yes, I can see the Animation Hints/Animation Hint List field of Variables, is there, and the Base/Expression Engine of LCS_1 is there also. I promise that yesterday I couldn't see it. Above all, I would swear that the Base/Expression Engine of LCS_1 box was blank, there were only the brackets, in which I tried to write without success. Ok, let's forget this :?

Moreover, I want to attach a gif exported with the new tool of Assembly 4, because the last I was not very good.
lcs_rot_y.gif
lcs_rot_y.gif (162.95 KiB) Viewed 2392 times
My apologies for the offtopic, How is it done to reduce the size of the gifs here in the forum?

Cheers!!!
keithp
Posts: 7
Joined: Fri May 14, 2021 1:42 pm

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by keithp »

Hi heron,

Thank you for your explanation. I think I now see the difference between the way we've done things.

FreeCAD has two ways of referring to angles: a) specifying the axis of rotation and the angle to rotate about that axis, and b) specifying the angle to rotate about each of the X, Y and Z axes (called Euler angles). Your file uses the first, while mine uses the second.

The first representation can use quaternions, which are mathematically robust, but generally not easy to visualise. I understand FreeCAD uses this representation internally. In contrast, Euler angles are intuitive (they correspond to roll, pitch and yaw of an aircraft, for example), but they have a problem called gimbal lock, which means they don't work correctly in certain circumstances.

Zolko mentioned in an earlier comment that he suspects the strange Y axis behaviour is due to gimbal lock.

For rotations about a single axis, the axis of rotation / rotation angle representation is fine, and is always well behaved. Where it is necessary to represent something with more axes of rotation, such as the attitude of an aircraft or the pose of the end effector on a robot arm, the Euler angle representation may be more useful.

FreeCAD allows you to set expressions for either the angle of rotation about an axis (your rot variable) or the three Euler angles (my AngleX, AngleY, AngleZ variables), but the ways of doing each are different and it does not appear to be possible to use both options together.

As you show in your screenshot, expanding Attachment Offset in the Properties pane shows Angle (set to rot by an expression), along with Axis and Position. There's no sign of the Euler angles. If you now click in the Value field of Attachment Offset, a button with three dots appears on the right. Clicking that opens a dialog with a menu with two options for rotation: Rotation axis with angle and Euler angles. Choosing Rotation axis with angle allows you to specify both, but only as values; the little function icon which allows you to enter an expression is absent. Choosing Euler angles gives fields for angles around each axis, and you can enter expressions for them. This is what I did to get AngleX, AngleY and AngleZ to work.

In summary, it appears that my Y axis behaves strangely because I use Euler angles and yours behaves properly because you use rotation axis with angle.
heron
Posts: 307
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by heron »

Hello keithp,

Now, I understand it also. I didn't know were you introduced the expressions of variables angles. Thank you very much for your explanations.

By the way, the robotic leg is very cool.

Cheers!!!
jtucker
Posts: 1
Joined: Tue Dec 28, 2021 9:04 pm

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by jtucker »

I know I am opening an older thread, but is there any resolution or work around for this? It is very frustrating to have parts of my assembly model flip when rotating. It seems it does not occur, for me at least, if the master sketch is in the XY plane. Same construction of master sketch in the XZ plane causes the issue to occur. I can post some files, but I think the examples here already.

OS: macOS 10.16
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24366 (Git)
Build type: Release
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: C/Default (C)

Should be the latest version of Assembly 4
User avatar
Zolko
Veteran
Posts: 2213
Joined: Mon Dec 17, 2018 10:02 am

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by Zolko »

jtucker wrote: Tue Jan 25, 2022 10:13 pm I know I am opening an older thread, but is there any resolution or work around for this ? It is very frustrating to have parts of my assembly model flip when rotating.
this is a guimbal lock, it's a mathematical issue. It's not even TNP, it's geometric. You must build your model differently.

Create a new Coordinate system in a Part (LCS_1) and attach to LCS_Origin with mode XY on plane
why would anyone do that ? If you attach an LCS to another LCS, do it with "Object's XYZ". And then, do the rotation in the AttachmentOffset.
try the Assembly4 workbench for FreCAD — tutorials here and here
heron
Posts: 307
Joined: Mon Apr 20, 2020 5:32 pm

Re: Assembly4: Strange behaviour when rotating LCS about Y axis

Post by heron »

If you attach an LCS to another LCS, do it with "Object's XYZ"
Thanks for the tip
Post Reply