Dear all,
For the subject specific models that we are creating using the geometry of the subject I want to change the range of conditional pathpoint using the matlab opensim api. So the muscle attachment sites on the patella but also the gastocnemius muscle are using conditional pathpoints that are active in a certain range of the knee flexion angle. So I calculated a the angle on which all three points are on one line and now I want to set this value using the OpenSim API. So I made a loop through all the muscle attachment points in the model and if it is a conditional pathpoint in the list I use the following code to set the 'new' maximal range. Unfortunately it is not working
LocationPathPoint = char(CurrentPathPoint.getLocation);
LocationPathPoint2 = str2num(LocationPathPoint(3:end-1));
P=LocationPathPoint2;
ConditionalPathPoint= ConditionalPathPoint.safeDownCast(CurrentPathPoint);
range=char(ConditionalPathPoint.getRange());
range2=str2num(range);
ConditionalPathPoint.setRangeMax(State,params.CPangle_rad(t))
Matlab gives me an error in the last step
K>> ConditionalPathPoint.setRangeMax(State,params.CPangle_rad(t))
No appropriate method, property, or field setRangeMax for class
org.opensim.modeling.ConditionalPathPoint.
So I tried a couple of things but I cannot figure out what is going wrong...
Any help with it would be highly appreciated The other solution is to change them manually
Matlab api ConditionalPathPoint
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Matlab api ConditionalPathPoint
Hi,
When you do methodsview on the ConditionalPathPoint object, what method signatures so you get? Do you see a setRangeMax? If so, what parameter-types does it have? I'm asking because the functionality has changed over time and I don't know what version of the code are you using.
Best regards,
-Ayman
When you do methodsview on the ConditionalPathPoint object, what method signatures so you get? Do you see a setRangeMax? If so, what parameter-types does it have? I'm asking because the functionality has changed over time and I don't know what version of the code are you using.
Best regards,
-Ayman
- Pim Pellikaan
- Posts: 2
- Joined: Fri Oct 11, 2013 8:11 am
Re: Matlab api ConditionalPathPoint
Dear Ayman,
Thanks for your reply!
I did the methodsview on the ConditiionalPathPoint and unfortunately setRangeMax is not there... So that means probably that the function does not exist in the Matlab Api or at least in the version I have which is OpenSim 3.3.
I don't know if the function exists in future or older versions of OpenSim? So for now I changed the range manually for a view models, but to create subject-specific models it would we really helpfull if the range could be changed automatically.
Kind regards,
Pim
Thanks for your reply!
I did the methodsview on the ConditiionalPathPoint and unfortunately setRangeMax is not there... So that means probably that the function does not exist in the Matlab Api or at least in the version I have which is OpenSim 3.3.
I don't know if the function exists in future or older versions of OpenSim? So for now I changed the range manually for a view models, but to create subject-specific models it would we really helpfull if the range could be changed automatically.
Kind regards,
Pim
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Matlab api ConditionalPathPoint
Hi Pim,
I looked over the source of OpenSim 3.3 and indeed the methods to get/setRange were not exposed to the Matlab interface, however there's likely a workaround by using the method getRange() which returns a "reference" to the range maintained by the ConditionalPathPoint. Then you can modify it using the ArrayDouble methods directly.
In general, "get" methods usually return const reference that you shouldn't modify to avoid side-effects but that may be ok as a workaround in this case.
Please let me know if that works for you,
-Ayman
I looked over the source of OpenSim 3.3 and indeed the methods to get/setRange were not exposed to the Matlab interface, however there's likely a workaround by using the method getRange() which returns a "reference" to the range maintained by the ConditionalPathPoint. Then you can modify it using the ArrayDouble methods directly.
In general, "get" methods usually return const reference that you shouldn't modify to avoid side-effects but that may be ok as a workaround in this case.
Please let me know if that works for you,
-Ayman
- Pengfei Liu
- Posts: 15
- Joined: Tue Sep 20, 2022 8:15 am
Re: Matlab api ConditionalPathPoint
Hi, I have troubled with the BIClong_point9 below for weeks, do you know how to add ConditionalPathPoint to muscle,it didn't work at Matlab, and i need insure that i connect socket coordinate correctly so that finalizeconnection can worked.
//..........
BIClong.addNewPathPoint('BIClong_point7', humerus, Vec3(0.0228,-0.1754,-0.0063));
BIClong.addNewPathPoint('BIClong_point8', radius, Vec3(-0.002,-0.0375,-0.002));
coord = osimModel.updCoordinateSet().get('elbow_flextion');
BIClong_point9 = ConditionalPathPoint();
BIClong_point9.setName('BIClong_point9');
BIClong_point9.connectSocket_coordinate(coord);
BIClong_point9.setRangeMax(1.570796326795);
BIClong_point9.setRangeMin(-0.63879050623);
BIClong.updGeometryPath.updPathPointSet.cloneAndAppend(BIClong_point9);
osimModel.addForce(BIClong);
//..............
Thanks!
//..........
BIClong.addNewPathPoint('BIClong_point7', humerus, Vec3(0.0228,-0.1754,-0.0063));
BIClong.addNewPathPoint('BIClong_point8', radius, Vec3(-0.002,-0.0375,-0.002));
coord = osimModel.updCoordinateSet().get('elbow_flextion');
BIClong_point9 = ConditionalPathPoint();
BIClong_point9.setName('BIClong_point9');
BIClong_point9.connectSocket_coordinate(coord);
BIClong_point9.setRangeMax(1.570796326795);
BIClong_point9.setRangeMin(-0.63879050623);
BIClong.updGeometryPath.updPathPointSet.cloneAndAppend(BIClong_point9);
osimModel.addForce(BIClong);
//..............
Thanks!