Trouble Accessing Elements From MatrixView (Force Reporter)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Vinay Kumar
Posts: 34
Joined: Thu Nov 08, 2018 6:50 am

Trouble Accessing Elements From MatrixView (Force Reporter)

Post by Vinay Kumar » Thu Jan 09, 2020 1:15 am

Hello everyone,

I am trying to access (using getAntElt()) specific elements from a MatrixView generated using a force reporter. With larger simulation times I end up with errors.

Please suggest a solution. The code is available at https://github.com/vinaym815/OpenSimExa ... re.cpp#L90

Thank You

Tags:

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

Re: Trouble Accessing Elements From MatrixView (Force Reporter)

Post by Thomas Uchida » Thu Jan 09, 2020 8:52 am

On line 90, I think you should just be getting a reference to the TimeSeriesTable (forceReporter->getForcesTable()). The TimeSeriesTable class provides an interface for accessing data in the underlying SimTK structure (https://simtk.org/api_docs/opensim/api_ ... ble__.html).

User avatar
Vinay Kumar
Posts: 34
Joined: Thu Nov 08, 2018 6:50 am

Re: Trouble Accessing Elements From MatrixView (Force Reporter)

Post by Vinay Kumar » Thu Jan 09, 2020 6:57 pm

Thank you for your quick reply.

Getting reference to TimeSeriesTable worked for me. However, I am still using getMatrix() and getAnyElt() function to access the data. Were talking about some other interfaces in your last comment ?

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

Re: Trouble Accessing Elements From MatrixView (Force Reporter)

Post by Ayman Habib » Fri Jan 10, 2020 10:43 am

Hi Vinay,

I suggest you print the table to a file first before trying to access elements programmatically in order to see if the contents are what your code expects.

Looking at the code it appears you have contact in the model, it's possible the simulation has the contact disengaged at some point, not sure what you'd expect to be in the table then. If the file looks fine and the accessor doesn't work let us know as it would be a separate more isolated issue that you/we can investigate easily.

Hope this helps,
-Ayman

User avatar
Vinay Kumar
Posts: 34
Joined: Thu Nov 08, 2018 6:50 am

Re: Trouble Accessing Elements From MatrixView (Force Reporter)

Post by Vinay Kumar » Sun Jan 12, 2020 4:08 am

Hi Ayman,

I am able to save ".mot" having valid numerical values in all cases using the forceReporter->getForceStorage().print("fileName.mot");

The following commands work for smaller integration times but not for longer ones:

Code: Select all

SimTK::MatrixView forceMatrix = forceReporter->getForcesTable().getMatrix();
SimTK::MatrixView &forceMatrix = forceReporter->getForcesTable().getMatrix();
The following commands works for smaller as well as longer intergration times.

Code: Select all

OpenSim::TimeSeriesTable forceTimeSeries = forceReporter->getForcesTable();
const SimTK::MatrixView forceMatrix = forceTimeSeries.getMatrix();

Code: Select all

OpenSim::TimeSeriesTable &forceTimeSeries = forceReporter->getForcesTable();
const SimTK::MatrixView &forceMatrix = forceTimeSeries.getMatrix()

POST REPLY