Contact mesh is not loading

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Aurelien Adriaenssens
Posts: 5
Joined: Tue May 19, 2020 12:17 pm

Contact mesh is not loading

Post by Aurelien Adriaenssens » Wed Jul 29, 2020 9:10 am

I am trying to load a contact mesh from a .obj file. I have edited the .osim file to include the .obj in both the <bodyset> and the <ContactGeometrySet>. When I load the model in OpenSim 4.1, nothing loads, no skeleton, no stairs, no waring/error message. Removing the contact geometry does make it load again, I can see my set of stairs (the .obj) in the visualiser window. Both the .obj in the <bodyset> and <ContactGeomterySet> are identical. My method it to design the object in SketchUp, export to .dae, load up in Blender, export to .obj.

Should there be any preproccessing done to make it an acceptable mesh?
Are there applications to generate .obj file which are compatible with OpenSim?


Loading other contact geometeries such as ContactHalfSpace seems to be ok.

I load the Contact Geometry as such:

Code: Select all

<ContactMesh name="stairs">
	<!--Body name to connect the contact geometry to-->
	<body_name>stairs</body_name>
	<!--Location of geometry center in the body frame-->
	<location>0 0 0</location>
	<!--Orientation of geometry in the body frame-->
	<orientation>0 0 0</orientation>
	<!--Filename-->
	<filename>stairs.obj</filename>
</ContactMesh>
Attachments
stairs.png
stairs.png (172.86 KiB) Viewed 506 times

Tags:

User avatar
Aurelien Adriaenssens
Posts: 5
Joined: Tue May 19, 2020 12:17 pm

Re: Contact mesh is not loading

Post by Aurelien Adriaenssens » Mon Aug 03, 2020 3:57 am

I am able to load other simple mesh files, such as the block in the image below. I can also load the soccer_ball.obj file as a contact mesh into my .osim. Everytime I try to load from my stairs.obj or ramp.obj file it fails to load with no warning messages.

The stairs and ramp files were made as follows: Sketchup export as .dae -> import into blender -> blender export as .obj
Are my mesh files too complex? I have gone through the .obj files and I cannot see any missing vertices/faces/normals. Even when I used Meshlabs to clean and repair the file, OpenSim still does not load the mesh.

Any help/tips would be greatly appreciated!
Attachments
ramp.png
ramp.png (126.35 KiB) Viewed 443 times

User avatar
Aurelien Adriaenssens
Posts: 5
Joined: Tue May 19, 2020 12:17 pm

Re: Contact mesh is not loading

Post by Aurelien Adriaenssens » Mon Aug 03, 2020 7:45 am

I tried loading in a simple triangle as a contantact mesh and it still doesn't work!!!

Here is the contents of the triangle.obj

Code: Select all

v 1.0 1.0 1.0
v 1.0 0.0 1.0
v 0.0 0.0 1.0

f 1 2 3
and here is contents of the stairs.obj

Code: Select all

v 6.250000 0.000000 -2.000000
v 6.250000 1.100000 0.000000
v 6.250000 0.000000 0.000000
v 6.250000 1.100000 -2.000000
v 3.000002 1.100000 -2.000000
v 3.000002 1.100000 0.000000
v -2.750000 0.100000 0.000000
v -2.750000 0.000000 0.000000
v 2.000001 0.100000 0.000000
v 2.250000 0.300000 0.000000
v 2.000001 0.300000 0.000000
v 2.500000 0.500000 0.000000
v 2.250000 0.500000 0.000000
v 2.750000 0.700000 0.000000
v 2.500000 0.700000 0.000000
v 3.000002 0.900000 0.000000
v 2.750000 0.900000 0.000000
v -2.750000 0.000000 -2.000000
v -2.750000 0.100000 -2.000000
v 2.000001 0.100000 -2.000000
v 2.250000 0.300000 -2.000000
v 2.000001 0.300000 -2.000000
v 2.500000 0.500000 -2.000000
v 2.250000 0.500000 -2.000000
v 2.750000 0.700000 -2.000000
v 2.500000 0.700000 -2.000000
v 3.000002 0.900000 -2.000000
v 2.750000 0.900000 -2.000000
# 28 vertices, 0 vertices normals

f 1 2 3
f 2 1 4
f 2 5 6
f 5 2 4
f 7 3 8
f 3 7 9
f 3 9 2
f 2 9 10
f 10 9 11
f 2 10 12
f 12 10 13
f 2 12 14
f 14 12 15
f 2 14 16
f 16 14 17
f 2 16 6
f 18 3 8
f 3 18 1
f 19 1 18
f 1 19 20
f 1 20 4
f 4 20 21
f 21 20 22
f 4 21 23
f 23 21 24
f 4 23 25
f 25 23 26
f 4 25 27
f 27 25 28
f 4 27 5
f 5 16 6
f 16 5 27
f 19 8 7
f 8 19 18
f 9 19 7
f 19 9 20
f 22 9 11
f 9 22 20
f 10 22 11
f 22 10 21
f 24 10 13
f 10 24 21
f 12 24 13
f 24 12 23
f 26 12 15
f 12 26 23
f 14 26 15
f 26 14 25
f 28 14 17
f 14 28 25
f 16 28 17
f 28 16 27
# 52 faces, 0 coords texture
If you get this to load a contact mesh please let me know how you did that!!
Any help would be much appreciated!!!

User avatar
Ayman Habib
Posts: 2252
Joined: Fri Apr 01, 2005 12:24 pm

Re: Contact mesh is not loading

Post by Ayman Habib » Mon Aug 03, 2020 9:08 am

Hello,

While we support obj files, it's possible that there are obj files that do not conform to our custom parsers (this is also true for .stl, .vtp files).
The code for the custom parsers is here to give you an idea of what's supported and why https://github.com/simbody/simbody/blob ... h.cpp#L151

Typically files are required to contain exactly one water-tight solid with properly aligned normals and can be used for contact/collision. Stl format maybe more forgiving for visualization but we need these conditions for contact anyways since we use simbody methods for collision/contact detection.

Let us know what you find out,
-Ayman

User avatar
Aurelien Adriaenssens
Posts: 5
Joined: Tue May 19, 2020 12:17 pm

Re: Contact mesh is not loading

Post by Aurelien Adriaenssens » Tue Aug 04, 2020 4:31 am

Hey!

Thank you for your reply!

I succeeded in getting my mesh to load as a .obj file. I figured out that if the normal of at least 1 face is pointing inwards, then the mesh will not load. I assume OpenSim will think it has a negative volume? The issue was that my mesh did have a few faces constructed with vertices in a clockwise order. This resulted in faces having an inward pointing normal. I went through the file and corrected this by hand. So now my mesh loads into OpenSim!!

However, I have come across another issue. The skeleton (right/left foot) does not contact with the mesh, it falls right through it.
I have read through the code for the parsers you sent. The .obj parser checks for the v and f line, but my .obj has a vn ... for vertex normals:

Code: Select all

v x1 y1 y2
v x2 y2 z2
v ...

vn xn1 yn1 yn2
vn xn2 yn2 zn2
vn ...

f v1//vn1 v2//vn1 v3//vn1
f ...
My question is: how does OpenSim compute the normals for the surface of contact? Is as dependent on the order of the vertices given in the f ... lines as I thought, or does the parser make use of the vn ... lines inside the .obj? I have not noticed any difference yet, but would it matter if the faces are triangles or quads?

I have tried converting my working .obj file to both .stp and .vtp, both of which do not make contact with the skeleton.

The image shows the contact geomteries in blue. Each foot has their respective heel, toe1, and toe2 as contact points. The code shows that I have included the contact mesh (ramp_c) inside the Hunt Crossley force set along side the others.

Code: Select all

<HuntCrossleyForce::ContactParameters>
	<!--Names of geometry objects affected by these parameters.-->
	<geometry>ramp_c r_heel r_toe1 r_toe2</geometry>
	<stiffness>500000</stiffness>
	<dissipation>1.0</dissipation>
	<static_friction>0.8</static_friction>
	<dynamic_friction>0.8</dynamic_friction>
	<viscous_friction>0</viscous_friction>
</HuntCrossleyForce::ContactParameters>
Attachments
ramp2.png
ramp2.png (159.3 KiB) Viewed 368 times

User avatar
Aurelien Adriaenssens
Posts: 5
Joined: Tue May 19, 2020 12:17 pm

Re: Contact mesh is not loading

Post by Aurelien Adriaenssens » Sat Aug 08, 2020 10:12 am

Unfortunatly I am still struggling to get the skeleton to contact with my meshes. I have only gotten as far as loading the mesh. The feet do not contact or act upon the mesh.

The screenshot below shows the contact meshes correctly loaded, but the skeletons just fall straight through the mesh. It is my goal to get my NN to learn to walk up/down stairs and ramps.
full_exp.png
full_exp.png (328.47 KiB) Viewed 340 times
I have added the contact and forces to what i believe are the correct places in the .osim file. I have attached the .osim file below.
transfemoral_amputee_model_customized_ramp_up.osim
(171.04 KiB) Downloaded 16 times
And here is the contents of ramp_contact.obj and ramp_geo.obj. Both files have the same contents.

Code: Select all

v 2.00000 1.000000 -1.000000 
v 2.00000 0.8500000 -1.000000
v 2.00000 1.000000 1.000000
v 2.00000 0.8500000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 0.8500000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 0.8500000 1.000000

v 8.00000 1.500000 -1.000000
v 8.000000 0.8500000 -1.000000
v 8.000000 1.500000 1.000000
v 8.000000 0.8500000 1.000000
v 5.00000 1.500000 -1.000000
v 5.00000 0.8500000 -1.000000
v 5.00000 1.500000 1.000000
v 5.00000 0.8500000 1.000000

v 2.00000 1.000000 -1.000000
v 2.000000 0.8500000 -1.000000
v 2.000000 1.000000 1.000000
v 2.000000 0.8500000 1.000000
v 5.00000 1.500000 -1.000000
v 5.00000 0.8500000 -1.000000
v 5.00000 1.500000 1.000000
v 5.00000 0.8500000 1.000000

vt 1.00000 1.00000 1.00000
vn 0.00000 1.00000 0.00000

f 1/1/1 5/1/1 7/1/1 3/1/1
f 4/1/1 3/1/1 7/1/1 8/1/1
f 8/1/1 7/1/1 5/1/1 6/1/1
f 6/1/1 2/1/1 4/1/1 8/1/1
f 2/1/1 1/1/1 3/1/1 4/1/1
f 6/1/1 5/1/1 1/1/1 2/1/1

f 16/1/1 12/1/1 11/1/1 15/1/1
f 12/1/1 10/1/1 9/1/1 11/1/1
f 14/1/1 13/1/1 9/1/1 10/1/1
f 16/1/1 15/1/1 13/1/1 14/1/1
f 15/1/1 11/1/1 9/1/1 13/1/1
f 16/1/1 14/1/1 10/1/1 12/1/1

f 17/1/1 18/1/1 20/1/1 19/1/1
f 19/1/1 20/1/1 24/1/1 23/1/1
f 21/1/1 23/1/1 24/1/1 22/1/1
f 17/1/1 21/1/1 22/1/1 18/1/1
f 18/1/1 22/1/1 24/1/1 20/1/1
f 17/1/1 19/1/1 23/1/1 21/1/1
If anyone succeeds to get their model to contact their mesh or mine, please tell me how you did it!

I have also tried this link, but to no success: https://simtk.org/projects/contact_osim_u

POST REPLY