Simbody Visualizer and OpenSim in Python

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Markus Peters
Posts: 2
Joined: Tue May 15, 2018 11:29 pm

Simbody Visualizer and OpenSim in Python

Post by Markus Peters » Fri Oct 15, 2021 6:34 am

Hello,

I'm currently working with the OpenSens interface to run simulations in OpenSim driven by IMU data. I try to change the settings of the visualiser from the 'GroundAndSky' setting to the 'SolodColor' because it always starts with this nasty setup but somehow I miss the point. I have no idea how i can change the settings from python. Anyone out there having an idea?

Best regards,

Markus

Tags:

User avatar
Ayman Habib
Posts: 2243
Joined: Fri Apr 01, 2005 12:24 pm

Re: Simbody Visualizer and OpenSim in Python

Post by Ayman Habib » Mon Oct 18, 2021 1:41 pm

Hi Markus,

Looking at the code, it appears you can indeed change the visualizer background to solid color using the call to

Code: Select all

setBackgroundType()
. Can you clarify how you're calling it and what are you passing as input, and whether you're getting an error message back?

Best regards,
-Ayman

User avatar
Markus Peters
Posts: 2
Joined: Tue May 15, 2018 11:29 pm

Re: Simbody Visualizer and OpenSim in Python

Post by Markus Peters » Wed Oct 20, 2021 5:12 am

Thanks Ayman for your reply,

Yes indeed I found that argument as well in the "simbody.py" file. The problem is that I don't know what I should put into the function. In the simbody.py file it is wirtten:

Code: Select all

setBackgroundType(self, background: "SimTK::Visualizer::BackgroundType") -> "SimTK::Visualizer &":
The error I get, when I try to change the background with:

Code: Select all

SolidColor = osim._simbody.SimTKVisualizer_SolidColor
osim.SimTKVisualizer.setBackgroundType(SolidColor)
is: TypeError: setBackgroundType() missing 1 required positional argument: 'background'

When I add another argument e.g. "background" the error is:
TypeError: in method 'SimTKVisualizer_setBackgroundType', argument 1 of type 'SimTK::Visualizer *'

Basically, I do not understand the term background: SimTK::Visualizer::BackgroundType

Best regards

Markus

User avatar
Ayman Habib
Posts: 2243
Joined: Fri Apr 01, 2005 12:24 pm

Re: Simbody Visualizer and OpenSim in Python

Post by Ayman Habib » Wed Oct 20, 2021 10:37 am

Hi Markus,

You can call

Code: Select all

setBackgroundTypeByInt
instead so you don't have to define an object/instance of type Background as suggested. The tricky part is that you get access to the visualizer only after it has been created so it's not clear when the change takes effect.

If that doesn't seem to work please open an issue/bug-report and we'll see what it takes to expose/feed parameters to the visualizer creation functionality.

Best regards,
-Ayman

POST REPLY