C++ API Visualizer

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Dimitra Blana
Posts: 17
Joined: Thu Jul 24, 2008 11:59 am

C++ API Visualizer

Post by Dimitra Blana » Tue Mar 20, 2018 3:03 am

Hello,

I was wondering if you could help me with the API visualizer. I have used it through the Matlab API before, but I now need it in C++ and I can't get it to work...

Here are the relevant steps in Matlab:

Code: Select all

osimModel = Model('my_model.osim');
osimModel.setUseVisualizer(true);

state = osimModel.initSystem;
osim_viz = osimModel.updVisualizer;
osim_viz.show(state);
Then I have a loop where I update the coordinate values and muscle activations in the state (based on an external device), and I call
osim_viz.show(state);
at every iteration to display the new model position + colour of muscles. It works fine.

In C++, I've done:

Code: Select all

Model osimModel("my_model.osim");
osimModel.setUseVisualizer(true);
osimModel.buildSystem();

SimTK::State& state = osimModel.initializeState();
OpenSim::ModelVisualizer& osim_viz = osimModel.updVisualizer();
osim_viz.show(state);
If I run that, a visualizer window opens and closes very quickly, and I get a very polite message (not an error message) that says: "simbody-visualizer: received Shutdown message. Goodbye."

Any help would be greatly appreciated!

Best wishes,
Dimitra

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: C++ API Visualizer

Post by Christopher Dembia » Tue Mar 20, 2018 8:27 am

Add the following to the end of your code:

Code: Select all

std::cin.get()

User avatar
Dimitra Blana
Posts: 17
Joined: Thu Jul 24, 2008 11:59 am

Re: C++ API Visualizer

Post by Dimitra Blana » Thu Mar 22, 2018 7:42 am

Thank you very much Chris! :D

POST REPLY