Page 1 of 1

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

Posted: Fri Feb 10, 2023 5:38 am
by ostr1969
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?

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

Posted: Sat Feb 11, 2023 9:41 pm
by nbianco
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

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

Posted: Tue Feb 14, 2023 9:24 am
by ostr1969
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 .