Sconpy apply external force

SCONE is a software tool for predictive simulations of biomechanical movement. It uses OpenSim for modeling and simulation, and performs optimization using various control strategies, including feed-forward control, proprioceptic feedback control, and bal
POST REPLY
User avatar
Sophie Fleischmann
Posts: 3
Joined: Tue Feb 15, 2022 6:58 am

Sconpy apply external force

Post by Sophie Fleischmann » Wed Jul 12, 2023 12:08 pm

Hi Thomas,
I am trying to add an external force to my model in sconepy, however, I can't find a way to make it work:
When I try to call body.set_external_force(sconepy.Vec3(1, 0, 0)) on my body object, I get the error that no constructor is defined for sconepy.Vec3.
I tried to work around this by getting the current force as a Vec3 by calling f=body.external_force(). I then set f.x = 1, which gave me a new force vector. In a third step I wanted to apply the force to the body using the set_external_force(f) command, which seemed to work at first. However, when I called body.external_force() directly afterwards, it gave me the original force and not the one that I just set.

Can you tell me if I am doing something wrong, or what would be the correct way to apply an external force in sconepy?

Thanks in advance and best regards,
Sophie

User avatar
Thomas Geijtenbeek
Posts: 445
Joined: Wed Mar 12, 2014 8:08 am

Re: Sconpy apply external force

Post by Thomas Geijtenbeek » Thu Jul 27, 2023 10:46 am

My apologies for the slow response. I will have to look into this. Can you send me the files I need to reproduce the issue?

User avatar
Mustafa Kamal
Posts: 1
Joined: Wed Mar 20, 2024 7:25 am

Re: Sconpy apply external force

Post by Mustafa Kamal » Mon Sep 30, 2024 3:14 am

Hi Thomas,

I'm encountering the same issue while trying to initialize a Vec3 vector in SconePy. I'm attempting to apply an external force to a body, but I keep getting the following error:
TypeError: sconepy.Vec3: No constructor defined!

The error occurs when I use the following code:
force = sconepy.Vec3(0.5, 0, 0)

Heres the relevant section of my code where the issue arises:
if t == 5:
pelvic_body = model.bodies()[1]
force = sconepy.Vec3(0.5, 0, 0)
pelvic_body.set_external_force(force)

What is the correct way to initialize a Vec3 vector in SconePy? Am I missing something here? Is there an alternative method for correctly initializing the Vec3 object?

Thanks in advance for your help!

User avatar
Thomas Geijtenbeek
Posts: 445
Joined: Wed Mar 12, 2014 8:08 am

Re: Sconpy apply external force

Post by Thomas Geijtenbeek » Mon Sep 30, 2024 5:32 am

This has been fixed for a while, but unfortunately the fix is not yet included in an official release.

If you contact me via email, I can send you a link to a preview release that includes the fix.

POST REPLY