Extend iDynTree::ModelLoader::loadReducedModelFromFullModel method to optionally take a given value for fixed joints
The request for this came out recently with both @francesco-romano and @VenusPasandi .
Something like:
/**
* Load reduced model from another model, specifying only the desired joints in the model.
*
* All other joints will be considered to be fixed to their position specified in the jointPos argument
* and their child links will be lumped together.
*
* @note the order of the degreee of freedom of the newly loaded model
* will be the one specified by the input joints serialization, i.e. consideredJoints
* @note for consistency, the jointPos contains position **all the dofs** of the model, not only the one
* that are not contained in **consideredJoints**.
*
* @param[in] fullModel Full model from which the reduced models is extracted.
* @param[in] consideredJoints list of joints to consider in the model.
* @param[in] jointPos vector of (internal) joint position of the model, to specify the value of the joints that re going to be removed, must be of size fullModel.getNrOfDOFs()
* @return true if all went well, false otherwise.
*
*/
bool loadReducedModelFromFullModel(const Model& fullModel, const std::vector<std::string> & consideredJoints, const VectoDynSize& jointPos);
this method can be easily implemented, it is only necessary to modify the createReducedModelAndSensors and the createReducedModel functions to take a jointPos vector of (internal) joint position from outside instead of creating an internal one filled with zero as in https://github.com/robotology/idyntree/blob/c8bf721b771fa4b1e7c3a940632e121060719a19/src/model/src/ModelTransformers.cpp#L366 .
When loading a model from string or file, the serialization of joints is still not defined, so it may be more convenient a method like:
/**
* Load a reduced model from a string, specifying only the desired joints in the model.
*
* All other joints will be considered to be fixed to their position specified in the fixedJointPos argument
* and their child links will be lumped together.
*
* @note the order of the degreee of freedom of the newly loaded model
* will be the one specified by the input joints serialization, i.e. consideredJoints
*
* @param[in] modelString string of the model to load
* @param[in] consideredJoints list of joints to consider in the model.
* @param[in] removedJointPositions map between the dof name of the dof no in consideredJoints and their (fixed) position in the reduced model
* @param[in] filetype (optional) explicit definiton of the filetype to load.
* Only "urdf" is supported at the moment.
* @return true if all went well (files were correctly loaded and consistent), false otherwise.
*
*/
bool loadReducedModelFromFullModel(const std::string& modelString, const std::vector<std::string> & consideredJoints, const std::map<std::string, double>& removedJointPositions, const std::string filetype = "urdf");
This is a bit more complex to implement, but it can be easily implemented once the previous one has been implemented.
cc @GiulioRomualdi @isorrentino
This was fixed in https://github.com/robotology/idyntree/issues/495, at least for the C++ api. I opened https://github.com/robotology/idyntree/issues/1179 to track adding/testing this for SWIG Python bindings (that I guess is desirable).