idyntree
idyntree copied to clipboard
ModelLoader: add the possibility to compute the reduced model passing a lambda
The ModelLoader gives the possibility to compute a reduced model specifying a list of joints to consider, a file or a string.
It would be nice if it would be possible to pass a lambda that express a predicate that if for a joint it returns true it would be considered in the computation of the reduced model.
Something like this:
std::vector<std::string> considered_joints;
for (int j_id=0; j< model.getNrOfJoints(); j_id) {
auto joint = model.getJoint(j_id);
joint_name = model.getJointName(j_id);
if (joint->getNrOfDOFs() == 0) {
continue;
}
considered_joints.push_back(joint_name);
}
mdlLoader.loadReducedModelFromFullModel(model, considered_joints);
Will become something:
mdlLoader.loadReducedModelFromFullModel(model, [](IJointPtr joint){ return joint->getNrOfDOFs() != 0; });
(This code is for exclude the fixed joints from the model)