Page 1 of 1

Code is not running due to inertia values

Posted: Tue Nov 08, 2022 8:34 am
by harshal3099
Greetings Everyone,

I am new to SimBody and thus learning SimBody with basic examples.
In one such example, I have defined a body that rotates freely with a motor attached to it via a Pin Mobilizer.

I have successfully attached a motor with the body using the Pin Mobilizer and the simulation runs fine in my system. However, once I transfer and try running the code in the PC of my fellow enthusiast, I face the following error.
simbody1.png
simbody1.png (78.4 KiB) Viewed 3723 times
Please Note: I do not get any error and thus my code compiles successfully in my personal laptop. I am using a virtual-box for Linux Ubuntu and my colleague has root Linux Ubuntu installation.

Please find the inertia definition of the body in the below image. Please note: No inertia values are defined any where else in the code.
simbody2.PNG
simbody2.PNG (201.61 KiB) Viewed 3723 times
Request for help on the same.

Also I was thinking of rotating the body along the Y axis instead of the Z axis(default axis with the Pin Mobilizer). I understand that I need to rotate the Mobilizer axis using Transform() function and thus I went through the documentation but could not figure out the implementation of the same.

Re: Code is not running due to inertia values

Posted: Tue Nov 08, 2022 9:45 am
by sherm
Hi, Harshal.

An important thing to know is that Simbody expects inertias to be provided taken about the body origin, NOT the body mass center. I suspect your specification of the motor inertia was intended to be about the COM (0,0,.4) but Simbody interpreted it about (0,0,0) which, when shifted to (0,0,.4) is non-physical. The Inertia class provides functions for shifting inertias to and from COM; in this case you should take your central motor inertia (taken about (0,0,.4) and shift it from the COM to (0,0,0) before passing it to MassProperties.

See Inertia::shiftFromMassCenter

My guess is that the "works on one machine but not the other" is a red herring -- if I'm correct that the inertia was non-physical it didn't work anywhere but on your machine you didn't see the error message (maybe a Release vs. Debug difference?).

Let me know whether that addresses the problem.

Regards,
Sherm

Re: Code is not running due to inertia values

Posted: Wed Nov 23, 2022 10:32 am
by harshal3099
Greetings Sherman,
Apologies for the late reply.
Yes, it was the "release vs debug" that was letting the code run on my system.
Also I have understood the inertia definition criteria.
Thank you very much for your reply.

However, I am facing issues while trying to attach a pin mobilizer to rotate my body along the Y/X axis. Since the mobilizer by default provides mobility along the Z-Axis, I tried rotating the axis using Transform() function but I am getting pretty weird results. Can you please point me to a few examples or a documentation that I can refer to rectify this problem?

Thanks & Regards.

Re: Code is not running due to inertia values

Posted: Thu Nov 24, 2022 11:34 am
by sherm
This diagram may help (scroll down to "Mobilizer Terminology and Notation") -- notice that a mobilizer is a relationship between two frames. One (F) is on the parent (inboard) body and the other (M) is on the child (outboard) body. A Pin mobilizer aligns the Z axes of those two frames. Each frame can be repositioned separately, but in the end the two Z axes will be aligned. The two transforms in the MobilizedBody::Pin constructor are repositioning F and M with respect to their bodies.

An example where a Pin mobilizer rotates around the X axis is given here (in ExampleClosedTopologyMechanism). The ZtoX transform is defined here.

Regards,
Sherm

Re: Code is not running due to inertia values

Posted: Mon Dec 05, 2022 11:20 am
by harshal3099
Thank you very much Sherman! It helped me a lot.

Re: Code is not running due to inertia values

Posted: Mon Dec 05, 2022 11:28 am
by sherm
You're welcome!