Page 1 of 1

Accessing states during a forward dynamic simulation

Posted: Sat Jul 07, 2018 3:24 am
by peterbishop
Hello,
I have been running forward dynamic simulations via the API through MATLAB. I wish to access the states of a model during a forward dynamic simulation in real-time (i.e., at the end of each integration time-step), so that I can use this information to update the model (e.g., modify applied forces) or decide wether to stop a simulation or not (e.g., if the body COM has fallen below a certain height, the simulation should abort).

I am aware of the "TriggeredEventHandler", "PeriodicEventReporter" and "Controller" classes in C++, but am not sure how to access and use these via the MATLAB interface.

Many thanks in advance for any suggestions!

Peter Bishop.

Re: Accessing states during a forward dynamic simulation

Posted: Mon Jul 09, 2018 12:50 am
by mitkof6
The proper way to implement this is by a custom C++ controller. Alternatively, you can call the integrate function incrementally, however this approach will inherit a piecewise constant (discontinuity) response in the applied forces.

Re: Accessing states during a forward dynamic simulation

Posted: Mon Jul 09, 2018 1:20 am
by peterbishop
Thanks Dimitar. So just to clarify, there's no way that I can do this through just the MATLAB interface? I'm a novice when it comes to C++, and my ultimate intention is to make my models and simulations accessible to other MATLAB users.

Re: Accessing states during a forward dynamic simulation

Posted: Mon Jul 09, 2018 11:35 pm
by mitkof6
You can do it but the result will not be so good, because you will update the input force every dt keeping the value constant between the integration steps.