MATLAB API bindings for SimTK classes
Posted: Sun Jan 10, 2021 11:23 pm
Hi OpenSim team,
Recently, I've been looking to utilise Opensim 4.1 with the MATLAB bindings. I'm in the process of converting some prior C++ code acting as a makeshift wrapper for MATLAB using mex functions for OpenSim 3.3. Given that OpenSim 4 has MATLAB bindings I was hoping to convert those old mex functions into pure MATLAB functions.
During this process, the MATLAB bindings seem to be unable to find functionality which belong to SimTK libraries, specifically for the MultibodySystem class object instance:
In C++:
In MATLAB, I've created a class to embed the model and the state. When attempting to run a function using the same project() and realize() functions from SimTK::getMultibodySystem, it throws an exception.
The respective exceptions thrown are
Using methodsview, the functions available using the MATLAB bindings are:
Other SimTK functionality like Vector and Stage, and parent classes like Body are all working fine without issues.
Are there limitations in the MATLAB bindings for functions for specific classes from SimTK?
The functionalities from SimTK::SimbodyMatterSubSystem are all available in MATLAB making it seem like the specific MultibodySystem class is the potential problem.
Thanks for your time in advance. Any insight into this and/or other users with the same issue would be welcome since I have no other information indicating that this should happen.
FYI: I'm on Ubuntu 18.04 with MATLAB R2019b. The 4.1 release source code builds completely (but ctests for some MATLAB didn't work - I'm flagging this on github itself separately).
Kind regards,
Yujun
Recently, I've been looking to utilise Opensim 4.1 with the MATLAB bindings. I'm in the process of converting some prior C++ code acting as a makeshift wrapper for MATLAB using mex functions for OpenSim 3.3. Given that OpenSim 4 has MATLAB bindings I was hoping to convert those old mex functions into pure MATLAB functions.
During this process, the MATLAB bindings seem to be unable to find functionality which belong to SimTK libraries, specifically for the MultibodySystem class object instance:
In C++:
Code: Select all
si = model.initSystem();
// other parts of codebase - si remains as the latest state
model.getMultibodySystem().project(si, 1e-12); //,1e-14);
model.getMultibodySystem().realize(si,SimTK::Stage::Velocity);
Code: Select all
self.mdl.getMultibodySystem().project(self.state,1e-10);
self.mdl.getMultibodySystem().realize(self.state,Stage(6)); % to set it as SimTK::Stage::Velocity
Code: Select all
Undefined function 'project' for input arguments of type 'org.opensim.modeling.SWIGTYPE_p_SimTK__MultibodySystem'.
Unrecognized function or variable 'realize'.
Code: Select all
Methods for class org.opensim.modeling.SWIGTYPE_p_SimTK__MultibodySystem:
equals getClass hashCode notify notifyAll toString wait
Are there limitations in the MATLAB bindings for functions for specific classes from SimTK?
The functionalities from SimTK::SimbodyMatterSubSystem are all available in MATLAB making it seem like the specific MultibodySystem class is the potential problem.
Code: Select all
Methods for class org.opensim.modeling.SimbodyMatterSubsystem:
SimbodyMatterSubsystem calcMotionErrors calcSystemMassPropertiesInGround multiplyByM
calcAcceleration calcMotionPower calcSystemMomentumAboutGroundOrigin multiplyByMInv
calcAccelerationIgnoringConstraints calcP calcTreeEquivalentMobilityForces multiplyByN
calcBiasForAccelerationConstraints calcPq delete multiplyByNDot
calcBiasForFrameJacobian calcPqTranspose downcast multiplyByNInv
calcBiasForMultiplyByG calcProjectedMInv equals multiplyByPq
calcBiasForMultiplyByPq calcPt findConstraintForces multiplyByPqTranspose
calcBiasForStationJacobian calcQDot findMotionForces multiplyByStationJacobian
calcBiasForSystemJacobian calcQDotDot getCPtr multiplyByStationJacobianTranspose
calcBodyAccelerationFromUDot calcResidualForce getClass multiplyBySystemJacobian
calcConstraintForcesFromMultipliers calcResidualForceIgnoringConstraints getConstraintMultipliers multiplyBySystemJacobianTranspose
calcConstraintPower calcStationJacobian getMotionMultipliers notify
calcFrameJacobian calcSystemCentralInertiaInGround getRep notifyAll
calcG calcSystemCentralMomentum hashCode solveForConstraintImpulses
calcGTranspose calcSystemJacobian isInstanceOf toString
calcKineticEnergy calcSystemMass multiplyByFrameJacobian updDowncast
calcM calcSystemMassCenterAccelerationInGround multiplyByFrameJacobianTranspose updRep
calcMInv calcSystemMassCenterLocationInGround multiplyByG wait
calcMobilizerReactionForces calcSystemMassCenterVelocityInGround multiplyByGTranspose
FYI: I'm on Ubuntu 18.04 with MATLAB R2019b. The 4.1 release source code builds completely (but ctests for some MATLAB didn't work - I'm flagging this on github itself separately).
Kind regards,
Yujun