Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong inertia values in the exported URDF #117

Open
dsubhasish09 opened this issue May 22, 2021 · 11 comments
Open

Wrong inertia values in the exported URDF #117

dsubhasish09 opened this issue May 22, 2021 · 11 comments

Comments

@dsubhasish09
Copy link

When defining links made up of multiple parts in an assembly, the respective inertia values at the centre of mass of the individual parts (after using similarity transformation to make it parallel to the joint frame) is directly added to give the net inertia matrix instead of first translating to the net centre of mass (of all parts in the link combined) and then adding. This gives the wrong inertia matrix. This issue was only spotted recently, kindly resolve it at the earliest.

@jespersmith
Copy link

jespersmith commented Jul 29, 2021

I noticed this issue years ago and left a issue report on the bitbucket. Unfortunately, I cannot pull this up anymore but this is problematic for force controlled robots. We have been updating the inertia's manually and making it a good point to do a review step in the model creation, so it is not really a blocker.

Also note that solidworks exports an inertia tensor, which differs from the inertia matrix on the off-diagonal components.

afbeelding

@dsubhasish09
Copy link
Author

Yes, we are doing the same but it's a pain to manually alter the inertia values for every link, especially if you have a large number of these. Are you automating this by any means?

@jespersmith
Copy link

We have a simple UI to edit URDF's, that can parse the data from the solidworks mass tool (copy to clipboard data) . We just picked up development on it again, and we might consider open sourcing it.

@brawner
Copy link
Collaborator

brawner commented Nov 21, 2021

That is unfortunate to hear about this bug, as I pretty much just use SW's interfaces to calculate the MOI. It sounds like it may be a bug upstream.

https://github.com/ros/solidworks_urdf_exporter/blob/master/SW2URDF/URDFExport/ExportHelperExtension.cs#L248-L260

Do either of you have representative models and a URDF to help make comparisons?

@bbokser
Copy link

bbokser commented May 3, 2022

I can provide representative models, if you would like. I would much appreciate not having to manually correct the values every time I generate a URDF. Goodness knows how many headaches this has caused over the years...

@xwavex
Copy link

xwavex commented Aug 4, 2022

This sound like something that urgently needs to be fixed

@internetKevin0
Copy link

internetKevin0 commented Jan 31, 2023

I'd like to add fuel to this fire. The inertia calculation is incorrect and needs to be fixed ASAP. Our workaround is to manually enter the correct inertia matrix values with every link that has more than two parts or bodies. The exporter only works properly if each link has a single body. Even multiple bodies within the same part will still throw off the inertia calculation, if they have different densities.

@brawner
Copy link
Collaborator

brawner commented Jan 31, 2023

This code is open source, PRs are always welcome

@luoye2333
Copy link

luoye2333 commented Jun 3, 2024

We have a simple UI to edit URDF's, that can parse the data from the solidworks mass tool (copy to clipboard data) . We just picked up development on it again, and we might consider open sourcing it.

I use chatgpt to generate a convert program in python. When use, copy the text in solidworks mass tool to the const string in the code. Then copy the output text to the original urdf file. Feel free to use.

# 原始字符串
raw_string = """
所选零部件 的质量属性
     坐标系: BCS

质量 = 5439.19 克

体积 = 2525851.14 立方毫米

表面积 = 979087.02  平方毫米

重心 : ( 毫米 )
	X = 0.00
	Y = 1.10
	Z = 7.33

惯性主轴和惯性主力矩: ( 克 *  平方毫米 )
由重心决定。
	 Ix = ( 0.00, -1.00, -0.01)   	Px = 45020646.47
	 Iy = ( 1.00,  0.00,  0.00)   	Py = 48410923.95
	 Iz = ( 0.00, -0.01,  1.00)   	Pz = 80241299.66

惯性张量: ( 克 *  平方毫米 )
由重心决定,并且对齐输出的坐标系。 (使用正张量记数法。)
	Lxx = 48410923.95	Lxy = 1.36	Lxz = -0.97
	Lyx = 1.36	Lyy = 45021610.36	Lyz = 184249.38
	Lzx = -0.97	Lzy = 184249.38	Lzz = 80240335.77

惯性张量: ( 克 *  平方毫米 )
由输出座标系决定。 (使用正张量记数法。)
	Ixx = 48709740.16	Ixy = 0.92	Ixz = -3.91
	Iyx = 0.92	Iyy = 45313794.64	Iyz = 228269.22
	Izx = -3.91	Izy = 228269.22	Izz = 80246967.70
"""

# 提取数值并除以10^9
mass = str(float(raw_string.split('质量 = ')[1].split()[0]) / 1e3)
cog_x = str(float(raw_string.split('X = ')[1].split()[0]) / 1e3)
cog_y = str(float(raw_string.split('Y = ')[1].split()[0]) / 1e3)
cog_z = str(float(raw_string.split('Z = ')[1].split()[0]) / 1e3)
ixx = str(float(raw_string.split('Lxx = ')[1].split()[0]) / 1e9)
ixy = str(-float(raw_string.split('Lxy = ')[1].split()[0]) / 1e9)
ixz = str(-float(raw_string.split('Lxz = ')[1].split()[0]) / 1e9)
iyy = str(float(raw_string.split('Lyy = ')[1].split()[0]) / 1e9)
iyz = str(-float(raw_string.split('Lyz = ')[1].split()[0]) / 1e9)
izz = str(float(raw_string.split('Lzz = ')[1].split()[0]) / 1e9)

# 输出格式
output_string = f"""
<inertial>
  <origin
    xyz="{cog_x} {cog_y} {cog_z}"
    rpy="0 0 0" />
  <mass
    value="{mass}" />
  <inertia
    ixx="{ixx}"
    ixy="{ixy}"
    ixz="{ixz}"
    iyy="{iyy}"
    iyz="{iyz}"
    izz="{izz}" />
</inertial>
"""

print(output_string)

@jespersmith
Copy link

jespersmith commented Jun 19, 2024

We have a simple UI to edit URDF's, that can parse the data from the solidworks mass tool (copy to clipboard data) . We just picked up development on it again, and we might consider open sourcing it.

I use chatgpt to generate a convert program in python. When use, copy the text in solidworks mass tool to the const string in the code. Then copy the output text to the original urdf file. Feel free to use.

Note that the off-diagonal terms need to be negated between Solidworks and URDF

From my personal docs

WARNING: SolidWorks shows the moments of inertia, URDF expects the inertia tensor matrix.

The inertia tensor matrix is defined below from the moments of inertia:

![afbeelding](https://github.com/ros/solidworks_urdf_exporter/assets/8227626/70b210a0-026c-4544-9933-1491e382c23c)


Pretty much, make the off-diagonal values negative when exporting.

@luoye2333
Copy link

Thank you jespersmith. You are right. I have edited the code #117 (comment) and added the minus symbol '-' in ixy ixz and iyz .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants