Page 1 of 1
Trouble Accessing Elements From MatrixView (Force Reporter)
Posted: Thu Jan 09, 2020 1:15 am
by vinaym815
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
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
Posted: Thu Jan 09, 2020 8:52 am
by tkuchida
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).
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
Posted: Thu Jan 09, 2020 6:57 pm
by vinaym815
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 ?
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
Posted: Fri Jan 10, 2020 10:43 am
by aymanh
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
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
Posted: Sun Jan 12, 2020 4:08 am
by vinaym815
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()