Open siddancha opened 3 weeks ago
Oops, thanks for reporting. The documentation says that it should "throws std::exception if called pre-finalize". Looks like we forgot to actually check and throw.
@jwnimmer-tri Oh! I didn't realize that throwing an exception was the intended behavior (should've checked the docs!). I'm trying to remove joints (and therefore joint actuators) of a given model instance pre-finalize here. What would be the best way to go about this?
It seems like plant.GetJointActuatorIndices()
works, so you can walk that list and decide what to remove (or not remove). I assume you'll want to remove any actuators where actuator.joint()
refers to a joint that's on the way out.
@jwnimmer-tri I don't fully understand why GetJointActuatorIndices()
is supposed to work pre-finalize but GetJointActuatorIndices(model_instance)
isn't. But given that's the way it is, you're solution works great for me!
It's mostly just an accident of history. Efficiently returning the per-model-instance list takes a bit of extra logic and careful bookkeeping, which was just never implemented. Possibly we should just implement a slow version now (scan all actuators in the plant and accumulate those which patch) instead of implementing throwing. Either way, quietly returning an empty list is terrible!
Problem
GetJointActuatorIndices(model_instance)
seems to return an empty list even when joint actuators are present in the model instance. As a sanity check, bothGetJointActuatorByName()
andGetJointActuatorIndices()
(without any arguments) both correctly return the actuators/indices.This seems to happen pre-finalize and works fine after the plant is finalized. Maybe I'm missing something?
Reproduction
The corresponding outputs are included as comments.
Version
1.29.0
What operating system are you using?
Ubuntu 22.04
What installation option are you using?
pip install drake