ScaleTool object constructing problem in OpenSim API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jack Zhao
Posts: 94
Joined: Thu Jul 24, 2014 7:15 am

ScaleTool object constructing problem in OpenSim API

Post by Jack Zhao » Sun Jul 23, 2017 4:30 am

Dear All:
I try to use OpenSim API ScaleTool to scale models.The code is as:

ScaleTool scl_tol();
scl_tol.setSubjectMass(72.6);

There is unhandled exception in VC++ when "scl_tol.setSubjectMass" is being executed. Maybe due to the ScaleTool is not successfully constructed?
Even if I add a xml scale setting file (proved ok to use in OpenSim GUI) as a parameter to construct the ScaleTool object, the unhandled exception problem is still the same when executing setSubjectMass!

Thank you for anyone who can help!

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: ScaleTool object constructing problem in OpenSim API

Post by Thomas Uchida » Sun Jul 23, 2017 5:24 pm

I haven't worked with the ScaleTool in the API, but it's used in testScale.cpp (https://github.com/opensim-org/opensim- ... tScale.cpp). Following that example, I would try the following:

Code: Select all

std::unique_ptr<ScaleTool> scl_tol(new ScaleTool());
scl_tol->setSubjectMass(72.6);

User avatar
Jack Zhao
Posts: 94
Joined: Thu Jul 24, 2014 7:15 am

Re: ScaleTool object constructing problem in OpenSim API

Post by Jack Zhao » Sun Jul 23, 2017 8:38 pm

tkuchida wrote:I haven't worked with the ScaleTool in the API, but it's used in testScale.cpp (https://github.com/opensim-org/opensim- ... tScale.cpp). Following that example, I would try the following:

Code: Select all

std::unique_ptr<ScaleTool> scl_tol(new ScaleTool());
scl_tol->setSubjectMass(72.6);
Dear Dr Uchida:
Thank you so much for your kind reply!
The problem is still the same when I use "std::unique_ptr<ScaleTool>". I am not sure why the object construction has such issue and cannot perform the method function.

Thanks & Regards,
Jack

User avatar
Thomas Uchida
Posts: 1792
Joined: Wed May 16, 2012 11:40 am

Re: ScaleTool object constructing problem in OpenSim API

Post by Thomas Uchida » Mon Jul 24, 2017 11:12 am

Based on your other recent post, I'm guessing that you're using 3.2. In the 3.2 distribution, the analogous code in testScale.cpp would be something like the following:

Code: Select all

ScaleTool* scaleTool = new ScaleTool("scale_tool_setup_file.xml");
Model* model = scaleTool->createModel();
scaleTool->setSubjectMass(72.6);
delete model;
delete scaleTool;
Depending on what you're trying to accomplish, you might consider using the GUI to create an initial setup file and modifying only the necessary fields in MATLAB—either using the OpenSim API or by editing the .xml as a text file.

POST REPLY