Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
hu hu
- Posts: 9
- Joined: Fri Jun 23, 2023 1:50 am
Post
by hu hu » Sat Dec 07, 2024 6:31 am
I'm trying to get the coordinates in multibody tree order (not CoordinateSet order).
coords = model.getCoordinatesInMultibodyTreeOrder()
type(coords[0])
opensim.simulation.ReferencePtrCoordinate
model.getCoordinateNamesInMultibodyTreeOrder()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[1], line 1
----> 1 model.getCoordinateNamesInMultibodyTreeOrder()
NameError: name 'model' is not defined
How to use the getCoordinatesInMultibodyTreeOrder() function and output the names of the coordinates in multibody tree order?
Tags:
-
hu hu
- Posts: 9
- Joined: Fri Jun 23, 2023 1:50 am
Post
by hu hu » Sat Dec 07, 2024 6:28 pm
Thank you for your reply, but it still doesn't seem to work. Please take a look at the following error. I am using OpenSim 4.5 installed via Conda.
opensim 4.5 py311np123 opensim-org
import opensim as osim
model = osim.Model("arm26.osim")
model.initSystem()
coordNames = model.getCoordinateNamesInMultibodyTreeOrder()
[coordNames.getElt(i) for i in range(coordNames.size())]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 4
2 model = osim.Model("arm26.osim")
3 model.initSystem()
----> 4 coordNames = model.getCoordinateNamesInMultibodyTreeOrder()
5 [coordNames.getElt(i) for i in range(coordNames.size())]
AttributeError: 'Model' object has no attribute 'getCoordinateNamesInMultibodyTreeOrder'
-
Mohammadreza Rezaie
- Posts: 412
- Joined: Fri Nov 24, 2017 12:48 am
Post
by Mohammadreza Rezaie » Sun Dec 08, 2024 2:52 am
Hi, it seems that this method has been introduced recently and doesn't exist in the official 4.5 release. Possible solutions:
1. You can wait for the next official release.
2. Try the latest artifact:
https://github.com/opensim-org/opensim- ... ldartifact
3. Use this alternative method:
Code: Select all
coordSet = model.getCoordinateSet()
test = [[c.getBodyIndex(), c.getMobilizerQIndex(), c.getName()] for c in coordSet]
multibodyTreeOrder = [i[2] for i in sorted(test)]
Hope this helps.
-
hu hu
- Posts: 9
- Joined: Fri Jun 23, 2023 1:50 am
Post
by hu hu » Sun Dec 08, 2024 6:32 pm
Thank you very much, this solved my problem.
-
Ayman Habib
- Posts: 2252
- Joined: Fri Apr 01, 2005 12:24 pm
Post
by Ayman Habib » Mon Dec 09, 2024 10:43 am
Thanks Mohammadreza,
Indeed the function was introduced post 4.5 but should be available in 4.5.1 which is also available as a conda package.
Hope this helps,
-Ayman