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?
can i save initial value from moco state to use forward on?
- barak ostraich
- Posts: 42
- Joined: Thu Apr 12, 2018 12:17 am
- 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?
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
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
- 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?
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:
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 .
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;
}