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
Trouble Accessing Elements From MatrixView (Force Reporter)
- Vinay Kumar
- Posts: 34
- Joined: Thu Nov 08, 2018 6:50 am
- Thomas Uchida
- Posts: 1800
- Joined: Wed May 16, 2012 11:40 am
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
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).
- Vinay Kumar
- Posts: 34
- Joined: Thu Nov 08, 2018 6:50 am
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
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 ?
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 ?
- Ayman Habib
- Posts: 2254
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
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
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
- Vinay Kumar
- Posts: 34
- Joined: Thu Nov 08, 2018 6:50 am
Re: Trouble Accessing Elements From MatrixView (Force Reporter)
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:
The following commands works for smaller as well as longer intergration times.
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();
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()