getting full path for component in C++
Posted: Tue Sep 18, 2018 3:07 am
Hi all,
I'm working on implementing a simulation tool in C++ (OpenSim 4.0) that treats coordinates in the model differently.
So I have an .xml file with list properties of "Primary" coordinates and "Secondary" coordinates that I read in as strings.
I need to get the value of each of the Secondary components so I have a loop:
for (int i = 0; i < n_secondary_coord; ++i){
std::string name = get_secondary_coordinates(i);
values(i) = _model.getComponent<Coordinate>(name).getValue(state);
}
I am getting the error:
Component 'FBKNEE' could not find 'knee_add_r' of type Coordinate. Make sure a component exists at this path and that it is of the correct type.
because in the input .xml file I only list the names of the coordinates rather than the full path.
https://github.com/opensim-org/opensim-core/issues/1025
I read through this issue ^.
Is there a way to use _model.findComponent() (I get an error, because it is protected) or _model.printComponentsMatching (returns an unsigned int, not a std::string needed for getComponent) to get the full path for _model.getComponent()?
Or should I require the user to put a full path in the input file? This feels clunkier to me, but maybe you are necessitating it so you can have coordinates with the same name?
Thanks,
Colin
I'm working on implementing a simulation tool in C++ (OpenSim 4.0) that treats coordinates in the model differently.
So I have an .xml file with list properties of "Primary" coordinates and "Secondary" coordinates that I read in as strings.
I need to get the value of each of the Secondary components so I have a loop:
for (int i = 0; i < n_secondary_coord; ++i){
std::string name = get_secondary_coordinates(i);
values(i) = _model.getComponent<Coordinate>(name).getValue(state);
}
I am getting the error:
Component 'FBKNEE' could not find 'knee_add_r' of type Coordinate. Make sure a component exists at this path and that it is of the correct type.
because in the input .xml file I only list the names of the coordinates rather than the full path.
https://github.com/opensim-org/opensim-core/issues/1025
I read through this issue ^.
Is there a way to use _model.findComponent() (I get an error, because it is protected) or _model.printComponentsMatching (returns an unsigned int, not a std::string needed for getComponent) to get the full path for _model.getComponent()?
Or should I require the user to put a full path in the input file? This feels clunkier to me, but maybe you are necessitating it so you can have coordinates with the same name?
Thanks,
Colin