Page 1 of 1

MocoAccelerationTrackingGoal & MocoAngularVelocityTrackingGoal Failing to Transfer Reference DataTable to Solver

Posted: Tue Sep 27, 2022 11:22 am
by opearl
Hi,

My name is Owen. I hope you are all doing well!

I have been messing around with tracking some higher order terms through the MATLAB scripting environment with MOCO's API, and haven't been able to find a file type/format or TimeSeriesTableVec3 that either the MocoAccelerationTrackingGoal or the MocoAngularVelocityTrackingGoal can load without running into the following error:

Java exception occurred:
java.lang.RuntimeException: Invalid Argument. DataTable 'that' has zero
rows/columns.
Thrown at DataTable.h:178 in DataTable_().


I have tried using the SetAccelerationReferenceFile with .trc files formatted to read properly as a TimeSeriesTableVec3, as well as .sto files that are formatted other ways. I have also tried to manually create a TimeSeriesTableVec3 to make sure that the column labels are correct and there isn't any issue on the file reading side.

In both circumstances (loading the .trc and loading the manual TimeSeriesTableVec3), somewhere in the transition the solver drops the ball on transferring the references and they end up empty. Could you possibly provide an example file or .sto for which the formatting of the acceleration and angular velocity references can load properly via MATLAB? I also find that the documentation on these goals is quite vague, since I haven't seen another context besides marker files where a file is read directly into a vec3 table. The documentation also doesn't specifically say it has to be able to do that either, or whether there can be one column per 3 entries, etc. More details on the formatting will probably be necessary here so users can implement those methods properly.

Let me know if you need more info or if you have a sufficient understanding of the predicament.

Thanks so much for the help :D
Owen

Code snippet just so people understand what I am describing above:
accelTracking = org.opensim.modeling.MocoAccelerationTrackingGoal('accel_tracking');
accelTracking.setAccelerationReference(accelTimeSeriesTableVec3);
accelTracking.setWeight(10);
problem.addGoal(accelTracking);

angVelTracking = org.opensim.modeling.MocoAngularVelocityTrackingGoal('angvel_tracking');
angVelTracking.setAngularVelocityReference(angvelTimeSeriesTableVec3);
angVelTracking.setWeight(10);
problem.addGoal(angVelTracking);

Re: MocoAccelerationTrackingGoal & MocoAngularVelocityTrackingGoal Failing to Transfer Reference DataTable to Solver

Posted: Tue Sep 27, 2022 12:05 pm
by nbianco
Hi Owen,

Could you try setting the 'frame_paths' property (using setFramePaths, as in this example). Leaving 'frame_paths' empty should select all the columns in the data by default, but I suspect there might be a bug here.

-Nick

Re: MocoAccelerationTrackingGoal & MocoAngularVelocityTrackingGoal Failing to Transfer Reference DataTable to Solver

Posted: Tue Sep 27, 2022 1:58 pm
by opearl
Nick,

Thank you so much for the super speedy reply and for pointing to that helpful example. I followed the example more closely and got things working. I think the issue was that my pathing was a bit strange because I was trying to access a PhysicalOffsetFrame in a weld joint rather than in a body.

So, in the end it is appearing the setReferenceFile methods are working as desired :) I'll follow up on this later when I stress test it. If my current understanding is correct that means that a provided reference file would have to be in a format similar to what is normally done for markers files.

Thanks again so much for the help! Regardless, your comment helped me get things working properly so I really appreciate it.

Sincerely,
Owen

Re: MocoAccelerationTrackingGoal & MocoAngularVelocityTrackingGoal Failing to Transfer Reference DataTable to Solver

Posted: Wed Sep 28, 2022 9:30 am
by nbianco
Hi Owen,

You're welcome!
If my current understanding is correct that means that a provided reference file would have to be in a format similar to what is normally done for markers files.
Not sure exactly what you mean, but as long as the columns in the reference file have labels that match paths to components in the model that have body accelerations, then you should be fine.

-Nick

Re: MocoAccelerationTrackingGoal & MocoAngularVelocityTrackingGoal Failing to Transfer Reference DataTable to Solver

Posted: Tue Apr 02, 2024 1:56 pm
by schnemik
Hello! Thank you all so much for your hard work on Moco.

I am joining this thread because I have a very similar question and Owen's setup of the problem was very clear. However, I am a step further behind Owen and am struggling to figure out the format for acceleration reference data. I am trying to create fabricated zero acceleration reference data to constrain the motion of a torso but have not been able to create a .sto or .trc file that is accepted by the "setAccelerationReferenceFile" command.

Below is a snippet of my code. I am trying to add an IMU frame at zero offset and (0,0,0) reference coordinate system and then track fabricated reference data that is essentially an acceleration of (0,0,0) for the entire time series. I also looked at the forum thread from Grace M titled "Fabricating and tracking IMU signals," which is where I got the basic format for the "imu_tracking.sto" file that I also attached (the .txt ending is only so I could save it and upload here). The error I am currently getting is pasted below-- essentially DataType:Quaternion is not recognized. If you have any advice on how to format acceleration reference data or an example file, that would be greatly appreciated.


% Acceleration Tracking
addIMUFrame(model, 'torso', Vec3(0, 0, 0), Vec3(0, 0, 0));
imuFramePaths = StdVectorString();
imuFramePaths.add('/bodyset/torso/torso_imu_offset');
OpenSenseUtilities().addModelIMUs(model, imuFramePaths);
model.initSystem();

tracking = MocoAccelerationTrackingGoal('acceleration_tracking');
tracking.setFramePaths(imuFramePaths);
tracking.setAccelerationReference("imu_tracking.sto");
tracking.setGravityOffset(false);
tracking.setExpressAccelerationsInTrackingFrames(false);
problem.addGoal(tracking);


Java exception occurred:
java.lang.RuntimeException: Datatype 'Quaternion ' is not supported.
Thrown at STOFileAdapter.cpp:77 in createSTOFileAdapterForReading().

at org.opensim.modeling.opensimMocoJNI.MocoSolver_resetProblem(Native Method)

at org.opensim.modeling.MocoSolver.resetProblem(MocoSolver.java:72)

Re: MocoAccelerationTrackingGoal & MocoAngularVelocityTrackingGoal Failing to Transfer Reference DataTable to Solver

Posted: Wed Apr 03, 2024 9:46 am
by nbianco
Hi Mikayla,

You're trying to use MocoAccelerationTrackingGoal which accepts a TimeSeriesTableVec3, so tables constructed using type Quaternion won't be supported (the format from the other thread by Grace M was probably for MocoOrientationTrackingGoal, which does support Quaternion types).

Try constructing a TimeSeriesTableVec3 for your reference zero acceleration (i.e., columns of Vec3 types) and try that instead.

-Nick