How to use the BodyActuator?
Posted: Fri Dec 01, 2023 5:46 am
I want to apply 6d forces/torques on a body using the BodyActuator in C++.
Usually, when applying forces through i.e. the PointActuator or the CoordinateActuator, I would use the PrescribedController and the function prescribeControlForActuator() to generate a force to be applied. However, the documentation clearly states, that the BodyActuator can apply a spatial force (6D vector), while the PrescribedController uses the Function class, which generates 1D values, as far as I am aware.
Can I use the PrescribedController to set control values for the BodyActuator? If so, how? If not, how else can I apple values?
I have already tried applying the forces manually to the model like this:
However when looking at the output of the ForceReporter, the desired forces don't exist.
Usually, when applying forces through i.e. the PointActuator or the CoordinateActuator, I would use the PrescribedController and the function prescribeControlForActuator() to generate a force to be applied. However, the documentation clearly states, that the BodyActuator can apply a spatial force (6D vector), while the PrescribedController uses the Function class, which generates 1D values, as far as I am aware.
Can I use the PrescribedController to set control values for the BodyActuator? If so, how? If not, how else can I apple values?
I have already tried applying the forces manually to the model like this:
Code: Select all
void applyBodyActuatorToModel(OpenSim::Model *model, const SimTK::State &state,
OpenSim::BodyActuator &body_actuator,
SimTK::Vector force) {
auto modelControls = model->getDefaultControls();
body_actuator.addInControls(force, modelControls);
model->setDefaultControls(modelControls);
model->computeStateVariableDerivatives(state);
}