Page 1 of 2

Model conversion from OpenSim4 to Hyfydy

Posted: Wed Sep 01, 2021 6:19 am
by mn13rt
Hi Thomas,

Thank you in advance for your help.

I am trialling the hyfydy licence and am excited to see what it can do. I am trying to convert my model to the correct format using the conversion tool built into SCONE. The model I am hoping to run is built on top of the H0918M in OpenSim 4.

Unfortunately, I was unable to get it to work converting the H0918M_osim4.osim model to the .hfd file type. The error does not appear when converting the OpenSim 3 version of the file (H0918M_osim3.osim) which it converts without a problem.

The error is as follows:


Invalid body (Unassigned) specified in contact geometry platform
Invalid body (Unassigned) specified in contact geometry platform


Following a short investigation, it appears to relate to the calcn left and right bodies. Any ideas what I can do to fix this?


Best wishes,
Rory Turnbull

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Thu Sep 02, 2021 1:27 am
by tgeijten
Unfortunately, converting OpenSim4 models to Hyfydy is not yet supported. This feature will be added in an upcoming version.

Until then, you can try to apply your changes to an OpenSim3 model and convert that, or (better) apply your changes directly to the H0918.hfd model that is supplied in the examples. You will find that the .hfd model is rather straightforward and easy to edit in a text editor.

If you are willing to email me the model, or details on the changes you've made, then I'd be more than happy to assist you in the model conversion process.

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Thu Sep 02, 2021 2:56 am
by mn13rt
Thank you for your response.

I will have a crack at it myself and send an email if I get stuck anywhere. I will directly apply the changes to the .hfd through the text editor.

The main question I have for the hfd format, does it support PointOnLineConstraints? and how would I go about adding that to the .hfd file as there is not something similar already formatted on the file.

Cheers,
Rory

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Thu Sep 02, 2021 4:29 am
by tgeijten
Unfortunately, the OpenSim PointLineContraint is not supported by Hyfydy. The best alternative I can think of is to apply forces directly to the point on the body, based on the distance and relative velocity to the line. Whether this is a suitable approach really depends on what you are trying to accomplish.

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Thu Sep 02, 2021 6:52 am
by mn13rt
I am looking at exoskeleton design where the ankle joint is effectively used as the end of a closed kinematic chain. I achieved this in OpenSim4 using the PointLineContraint between the exoskeleton shank body and the calcn body. The offsets were done so that the constraint lined up with the ankle joint. It has worked well so far with SCONE driving the simulations.

Code: Select all

% Point on a line
lineDirection = Vec3(0,0,1); % z direction
exoJoint{9} = PointOnLineConstraint(exoBody{4},lineDirection,jointOffset{6},BodyList{4},jointOffset{7});
exoJoint{9}.setName('PointOnLineConstraintAnkleR');
model.addConstraint(exoJoint{9});
where
exoJoint{9} = point on line constraint
exoBody{4} = exo shank
BodyList{4} = calcn_r

I am interested to see the effect of what you have suggested. Would that be implemented using a lua based function similar to the perturbation example?

Cheers,
Rory

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Thu Sep 02, 2021 7:25 am
by tgeijten
That's interesting -- if I understand correctly what you need is an additional joint connecting the calcaneus to your exoskeleton body? If that is the case, then the solution would be to simply add another joint, since Hyfydy has no issues with closed kinematic chains. I will need to make some adjustments to the model loader to allow for this, but this should be relatively straightforward.

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Thu Sep 02, 2021 11:51 pm
by mn13rt
That is correct. So a joint would definitely be much easier yes! I shall implement that in the hfd file I am editing and look forward to trying it out!!

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Fri Sep 03, 2021 1:11 am
by tgeijten
Great! I just checked and creating a closed kinematic indeed loop works as expected, but it did require a small modification to the .hfd model loader to support it. I will put up a new SCONE release that includes that modification, either later today or early next week.

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Fri Sep 03, 2021 3:36 am
by mn13rt
Perfect! Thank you very much!

As I have been working through the text file I have come across what is probably a syntax issue. For a body you can set the pos_in_parent, is it possible to set the orientation as well?

I tried using ori_in_parent like this but it has not had the desired effect.

Code: Select all

body {
		name = Cradle_S1_V1
		mass = 1
		inertia { x = 1 y = 1 z = 1 }
		joint {
			name = cuffCradle_S1_V1
			parent = RightThighExo
			pos_in_parent { x = 0 y = -0.1288 z = 0.11 }
			ori_in_parent { x = 0 y = 0 z = 0 }
			pos_in_child { x = 0 y = 0 z = 0 }
			ori_in_child { x = 0 y = 0 z = 0 }
			stiffness = $stiffness
			limit_stiffness = $limit_stiffness
			limits { x = 0..0 y = 0..0 z = 0..0 }
		}
		mesh { file = Thigh1.STL pos { x = 0..0 y = 0..0 z = 0..0 } 	}

I noticed under geometry there are "pos" and "ori" fields that are entered, is this a parameter that can be changed for a joint?

Re: Model conversion from OpenSim4 to Hyfydy

Posted: Fri Sep 03, 2021 4:53 am
by tgeijten
You're looking for ref_ori, which is the reference orientation of the child body wrt the parent body:

Code: Select all

joint {
	...
	ref_ori [ 0 0 90 ] # 90 degree rotation along the Z axis
}