Closed itbellix closed 12 months ago
Hi @itbellix, thanks for the bug report. Not sure where the segfault is without setting up a build, but if you're looking for a way to add a set of CoordinateActuators
s to a model, you could use a ModelProcessor
with ModOpAddReserves
:
import opensim as osim
modelProcessor = osim.ModelProcessor(pathOpenSimModel)
optimalForce = 1
modelProcessor.append(osim.ModOpAddReserves(optimalForce))
model = modelProcessor.process()
This simply adds a set of CoordinateActuator
s to the model (for coordinates that do not already have an actuator associated with it), and doesn't mess around with ForceSet
ownership or invalidating the system like CreateForceSetOfCoordinateActuatorsForModel
does.
Hi @nickbianco, thank you very much for your quick reply! Indeed, the code you provided has the behavior that I was trying to get, without resulting in errors :)
Great! We can hold on to this issue to decide what to do with CreateForceSetOfCoordinateActuatorsForModel
. My preference would be to remove it, but we'd need to discuss if that would break a lot of legacy code.
It turns out CreateForceSetOfCoordinateActuatorsForModel
is used by InverseDynamics
and StaticOptimization
, so we can't outright remove it without modifying those tools.
@itbellix you were probably getting a segfault because that function returns a raw pointer to a new ForceSet
objects and the memory was not handled properly.
Hi, I am running into troubles when using the method CreateForceSetOfCoordinateActuatorsForModel for a
CoordinateActuator
object in the Python API.The script that reproduces the error for me is the following:
I have tested it with the
arm26.osim
model, but also with other models that I have, and the last line appears problematic (even when changing theincludeLockedAndConstr
toTrue
). When running the the provided script, I have a segmentation fault error. However, this does not happen always (i.e., I was able to run the provided code once or twice, but not consistently).I am using OpenSim in Ubuntu 20.04, through Python, and I see the same problem if I use a custom build of OpenSim, or if I use the conda package.