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

Problem with biorbd.VecBiorbdMuscleStateDynamics.setActivation() income #96

Closed
Kilperic13 opened this issue Mar 10, 2020 · 4 comments
Closed

Comments

@Kilperic13
Copy link

Hi !

I installed the last version of rbdl with Casadi and biorbdl too (branch master and branch casadi. The two version are update with the version on github). I work on PyCharm editor (version 2019.3.3).

With this version, I can manipulate some function with MX argument, like the function biorbd.Model.ForwardDynamics(), which take in argument my state and my torque (in MX type), and give me back the derivation of my state.

I would like to use the function biorbd.VecBiorbdMuscleStateDynamics.setActivation() with MX argument too. But my editor send me this Error Message : "Wrong number or type of arguments for overloaded function 'StateDynamics_setActivation'." It is waiting for a double argument.

So, I look at in " biorbd/include/Muscles/StateDynamics.h " on github in Casadi branch for the setActivation function. It is waiting for " biorbd::utils::Scalar val ". In " biorbd/include/Utils/Scalar.h " (Casadi branch) the type of Scalar is define like this : "RigidBodyDynamics::Math::Scalar Scalar". In " rbdl-casadi/include/rbdl/rbdl_math.h " (branch master), the Scalar is define like this : "Vector1_t Scalar" and Vector1_t is define like this : "RBDLCasadiMath::MX_Xd_scalar Vector1_t".

So, logicaly, setActivation function can use MX argument. I think there is a problem so.

@pariterre
Copy link
Member

Hi @Kilperic13

Since you are using PyCharm, I assume you are using the Python binder? What operating system are you using? What do you call the "last version"?

It seems strange to me that you would use directly biorbd.VecBiorbdMuscleStateDynamics.setActivation(). Don't you declare it to a variable and then call the setActivation method? setActivation is not static therefore can't be call directly as is.
Could you provide a minimal example of a non working code in the following formating :

My non working code here

Thanks!

@Kilperic13
Copy link
Author

Kilperic13 commented Mar 11, 2020

Hi @pariterre ,

Yes, I am using the Python 3.7.6 binder. My operating system is Ubuntu (Linux).
The "last version" is, like I said, the update version on github. (Check with my terminal, "git fetch" and "git branch").

You are exactly right, I declare it to a variable and then call the setActivation method.
I would like to declare the activation of my muscles model. For this, I create a loop 'for'. An exemple of a non working code :

model = biorbd.Model("/home/path_model")
Nb_Muscles = model.nbMuscleTotal()
Act = MX.sym('Act', Nb_Muscles)
w = [Act]
ubw = [1] * Nb_Muscles
lbw = [0] * Nb_Muscles
w0 = [0.5] * Nb_Muscles
VecSDyn = biorbd.VecBiorbdMuscleStateDynamics(model.nbMuscleTotal())
act = MX.sym('act', 1, 1)
setAct = lambda vec,act : vec.setActivation(act)
for k in range(model.nbMuscleTotal()):
setAct(VecSDyn[k], Act[k])

But if you replace the 'for' loop by this, it doesn't work too :

setAct(VecSDyn[0], Act[0])

Thank you for your answers and help

@pariterre
Copy link
Member

Hi there,
I tried something, but for some reason it seems that I have a SegFault when using setActivation. Could you have a try before I merge? (#97 )

@Kilperic13
Copy link
Author

Hello,

Thank you for the problem, this function is work for me.

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

2 participants