Set value of AbstractProperty

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Adam Yoder
Posts: 16
Joined: Thu Jul 19, 2012 4:24 pm

Set value of AbstractProperty

Post by Adam Yoder » Tue Jan 28, 2020 9:49 pm

I need to change the value of an object's property programmatically using MATLAB API

The object is a custom controller defined in a plugin dll, so I can't use safeDownCast to use concrete methods, as explained here:
viewtopicPhpbb.php?f=91&t=7281&p=19121&start=0&view=

I can load a model containing the custom controller just fine and access the gain I want to adjust as an AbstractProperty

Code: Select all

controller=model.getControllerSet.get('CustomReflexController');
gain=controller.updPropertyByName('gain');
The only two relevant AbstractProperty methods i see in methodsview() are updValueAsObject(index) and setValueAsObject(index) neither of which seem to work:

Code: Select all

gain.updValueAsObject(0)=5

Unrecognized property 'updValueAsObject' for class 'org.opensim.modeling.AbstractProperty'.
Doesnt look like correct MATLAB syntax, but was suggested in another post
viewtopicPhpbb.php?f=91&t=10913&p=30255&start=0&view=

Code: Select all

gain.updValueAsObject(0)

Java exception occurred:
java.lang.RuntimeException: SimpleProperty<T>::updValueAsObject(): property gain is not an Object property.
at org.opensim.modeling.opensimModelJNI.AbstractProperty_updValueAsObject__SWIG_0(Native Method)
at org.opensim.modeling.AbstractProperty.updValueAsObject(AbstractProperty.java:96)
The "Container Interface" section here
https://simtk.org/api_docs/opensim/api_ ... perty.html

Thanks in advance!

Tags:

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

Re: Set value of AbstractProperty

Post by Thomas Uchida » Wed Jan 29, 2020 8:46 am

Please see the Matlab code I posted in Topic 9609: viewtopicPhpbb.php?f=91&t=9609

User avatar
Adam Yoder
Posts: 16
Joined: Thu Jul 19, 2012 4:24 pm

Re: Set value of AbstractProperty

Post by Adam Yoder » Thu Jan 30, 2020 10:16 am

awesome that works (using osim3.3)

for those wondering PropertyHelper was deprecated in osim3.1 but doc can be found here:
https://simtk.org/api_docs/opensim/api_ ... elper.html

User avatar
Bryce Killen
Posts: 104
Joined: Mon Nov 24, 2014 7:12 pm

Re: Set value of AbstractProperty

Post by Bryce Killen » Mon May 04, 2020 5:12 am

HI Tom,

I followed the link you have provided and as posted above this work for 3.3 implementation, but in 4.0 PropertyHelper seems to be Depricated. Is there a OpenSim4.0 equivalent ?

The only property class I have been able to access is PropertyString - which helps when I am trying to access information - but writing, for example, a double does not work using this class. There is apparently PropertyDbl - but I cannot seem to access it, and it is not even listed in the OpenSim API class list.

Thank you in advance for any information you can provide

Bryce

POST REPLY