can i save initial value from moco state to use forward on?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
barak ostraich
Posts: 42
Joined: Thu Apr 12, 2018 12:17 am

can i save initial value from moco state to use forward on?

Post by barak ostraich » Fri Feb 10, 2023 5:38 am

I need to save some state value got by the moco at initial time, and use it forward at time.
for example: an actuator that initialized by the initial angle and forward at time the force relative
to the initial angle.
so i need a discretevariable that is saved at t=0 (not the default initial pose)

i thought i can use a discrete variable but i cant find a function at Actuator.h that can modify a state, every functions are for const state

can it be done?

Tags:

User avatar
Nicholas Bianco
Posts: 1050
Joined: Thu Oct 04, 2012 8:09 pm

Re: can i save initial value from moco state to use forward on?

Post by Nicholas Bianco » Sat Feb 11, 2023 9:41 pm

Hi Barak,

Are you trying to run a forward simulation? It would be helpful if you provided a code example of what you are trying to accomplish.

Best,
Nick

User avatar
barak ostraich
Posts: 42
Joined: Thu Apr 12, 2018 12:17 am

Re: can i save initial value from moco state to use forward on?

Post by barak ostraich » Tue Feb 14, 2023 9:24 am

Im trying to build a custom actuator which whold remember the initial angle and use it for all other collocation nodes as a limit.
This will be used in a moco run with effort goal.
the actuator would return actuation value something like this:

Code: Select all

    double computeActuation(const SimTK::State& s) const override {
      const double initAngle=getDiscreteVariableValue(s, "initialkneeangle");
        string coordRef=get_coordinate();
        const Coordinate& aCoord = getModel().getCoordinateSet().get(coordRef);
        if (aCoord.getValue(s)<initAngle)
                return -get_stiffness()* aCoord.getValue(s);
        else
                return get_stiffness()*initAngle;
                												}
The discrete variable initAngle must get its value at the initial time because its changing with the moco iterations . The use of discreate variable is idea of mine, maybe its not the way .

POST REPLY