Force on PointConstraint

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Andrew Lai
Posts: 5
Joined: Fri Mar 23, 2012 5:28 pm

Force on PointConstraint

Post by Andrew Lai » Wed Dec 26, 2012 10:09 am

I'd like to optimize (maximize) force pushing against a constraint. My thought was to create a PointConstraint at the endpoint, and link it to ground so it does not move. I was thinking of using the reaction force of the PointConstraint on the limb as my objective function, but I haven't found much on how to access that value from the API. Is this possible, and if so, is it a good way to calculate maximum endpoint force?
Thanks,
Andrew

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

Re: Force on PointConstraint

Post by Ayman Habib » Mon Jan 07, 2013 11:49 am

Hi Andrew,

You'll need to decide which constraint to use (Weld vs. Point vs. ...) but your method seems reasonable. There's a method to report forces from a constraint (used by ForceReporter). Please consult the method

Code: Select all

Constraint::getRecordValues(const SimTK::State& state) 
if you have the source around.

Are you using the API from C++, Matlab or Jython?

Best regards,
-Ayman

User avatar
Andrew Lai
Posts: 5
Joined: Fri Mar 23, 2012 5:28 pm

Re: Force on PointConstraint

Post by Andrew Lai » Mon Jan 07, 2013 1:09 pm

Ayman,
I plan on following the C++ code example given on the documentation website below to create my optimization:
http://simtk-confluence.stanford.edu:80 ... timization
Would this be significantly easier to perform this optimization in Matlab? I'm currently trying to learn C++ so I can follow the example, but I am more familiar with Matlab. I hadn't even considered the possibility of working in another language, since I was following the website's instructions.
Thank you very much for your help,
Andrew

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

Re: Force on PointConstraint

Post by Ayman Habib » Mon Jan 07, 2013 2:05 pm

Hi Andrew,

Once you learn C++ and setup your environment it would be easier to develop in C++ since there're more examples to follow. The Matlab interface is a bit more limited (e.g. limited access to low level SimTK classes as of now) but is easier to setup since you're more familiar with the language/environment and you don't need to deal with cross-platform issues. You can go either way but it'd be more flexible if you follow the more traveled C++ route in your specific case.

Best of luck and please let us know if you have any questions.
-Ayman

User avatar
Andrew Lai
Posts: 5
Joined: Fri Mar 23, 2012 5:28 pm

Re: Force on PointConstraint

Post by Andrew Lai » Fri Feb 01, 2013 2:13 pm

Ayman,
I'm having some trouble with the visualizer and a weldconstraint.
I set up the constraint in C++ code and loaded the model with the constraint in place. I confirmed that the constraint is in effect by opening the .osim file.
The model loads to a specified position, but the coordinates slider still allows me to move the model (in a smaller workspace, but it still allows motion). Based on the weldconstraint, I believe there should be no freedom for the model to move.
What is happening here? Is the visualizer simply minimizing constraint errors, so that motion is allowed in a limited range? Or is my constraint not implemented correctly?

Andrew

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

Re: Force on PointConstraint

Post by Ayman Habib » Mon Feb 04, 2013 11:14 am

Hi Andrew,

What version of OpenSim are you using? I'd recommend using version 3.0.1 (beta) to test the bhavior as it contained a fix to a similar issue that was reported in version 3.0.

Please let me know what you find out,
-Ayman

POST REPLY