Skip to content

Commit

Permalink
createReducedModel: switch from std::map to std::unordered_map
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro authored Apr 18, 2024
1 parent f1158d7 commit 36956df
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/model/include/iDynTree/ModelTransformers.h
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
#ifndef IDYNTREE_MODEL_TRANSFORMERS_H
#define IDYNTREE_MODEL_TRANSFORMERS_H

#include <map>
#include <unordered_map>
#include <string>
#include <vector>

@@ -80,7 +80,7 @@ bool createReducedModel(const Model& fullModel,
bool createReducedModel(const Model& fullModel,
const std::vector<std::string>& jointsInReducedModel,
Model& reducedModel,
const std::map<std::string, double>& removedJointPositions);
const std::unordered_map<std::string, double>& removedJointPositions);

/**
* @brief Given a specified base, return a model with a "normalized" joint numbering for that base.
6 changes: 3 additions & 3 deletions src/model/src/ModelTransformers.cpp
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
#include <iDynTree/SixAxisForceTorqueSensor.h>

#include <cassert>
#include <map>
#include <unordered_map>
#include <set>
#include <vector>

@@ -331,7 +331,7 @@ void reducedModelAddSolidShapes(const Model& fullModel,
bool createReducedModel(const Model& fullModel,
const std::vector< std::string >& jointsInReducedModel,
Model& reducedModel,
const std::map<std::string, double>& removedJointPositions)
const std::unordered_map<std::string, double>& removedJointPositions)
{
// We use the default traversal for deciding the base links of the reduced model
Traversal fullModelTraversal;
@@ -735,7 +735,7 @@ bool createReducedModel(const Model& fullModel,
const std::vector< std::string >& jointsInReducedModel,
Model& reducedModel)
{
std::map<std::string, double> emptyRemovedJointPositions;
std::unordered_map<std::string, double> emptyRemovedJointPositions;
return createReducedModel(fullModel, jointsInReducedModel, reducedModel, emptyRemovedJointPositions);
}

4 changes: 2 additions & 2 deletions src/model/tests/ModelUnitTest.cpp
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ void getRandomSubsetOfJoints(const Model & model,

void getRandomJointPositonsForJointsNotInReducedModels(const Model & fullModel,
const std::vector<std::string>& subsetOfJointsInReducedModel,
std::map<std::string, double>& removedJointPositions,
std::unordered_map<std::string, double>& removedJointPositions,
FreeFloatingPos& fullModelPos)
{
for(auto jntName: subsetOfJointsInReducedModel)
@@ -224,7 +224,7 @@ void checkReducedModel(const Model & model)
getRandomSubsetOfJoints(model,jnts,jointInReducedModel);

// Get random positions for reduced models
std::map<std::string, double> removedJointPositions;
std::unordered_map<std::string, double> removedJointPositions;
getRandomJointPositonsForJointsNotInReducedModels(model, jointInReducedModel, removedJointPositions, fullPos);

Model reducedModel;
8 changes: 4 additions & 4 deletions src/model_io/codecs/include/iDynTree/ModelLoader.h
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
#include <iDynTree/Model.h>
#include <iDynTree/Sensors.h>

#include <map>
#include <unordered_map>
#include <memory>
#include <string>
#include <vector>
@@ -222,7 +222,7 @@ class ModelLoader
*/
bool loadReducedModelFromFullModel(const Model& fullModel,
const std::vector<std::string> & consideredJoints,
const std::map<std::string, double>& removedJointPositions,
const std::unordered_map<std::string, double>& removedJointPositions,
const std::string filetype="");

/**
@@ -249,7 +249,7 @@ class ModelLoader
*/
bool loadReducedModelFromString(const std::string modelString,
const std::vector<std::string> & consideredJoints,
const std::map<std::string, double>& removedJointPositions,
const std::unordered_map<std::string, double>& removedJointPositions,
const std::string filetype="",
const std::vector<std::string>& packageDirs = {});

@@ -276,7 +276,7 @@ class ModelLoader
*/
bool loadReducedModelFromFile(const std::string filename,
const std::vector<std::string> & consideredJoints,
const std::map<std::string, double>& removedJointPositions,
const std::unordered_map<std::string, double>& removedJointPositions,
const std::string filetype="",
const std::vector<std::string>& packageDirs = {});

12 changes: 6 additions & 6 deletions src/model_io/codecs/src/ModelLoader.cpp
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ namespace iDynTree
const std::vector< std::string >& consideredJoints,
const std::string filetype)
{
std::map<std::string, double> emptyRemovedJointPositions;
std::unordered_map<std::string, double> emptyRemovedJointPositions;
return this->loadReducedModelFromFullModel(fullModel, consideredJoints, emptyRemovedJointPositions, filetype);
}

@@ -138,7 +138,7 @@ namespace iDynTree
const std::string filetype,
const std::vector<std::string>& packageDirs /*= {}*/)
{
std::map<std::string, double> emptyRemovedJointPositions;
std::unordered_map<std::string, double> emptyRemovedJointPositions;
return this->loadReducedModelFromString(modelString, consideredJoints, emptyRemovedJointPositions, filetype, packageDirs);
}

@@ -147,13 +147,13 @@ namespace iDynTree
const std::string filetype,
const std::vector<std::string>& packageDirs /*= {}*/)
{
std::map<std::string, double> emptyRemovedJointPositions;
std::unordered_map<std::string, double> emptyRemovedJointPositions;
return this->loadReducedModelFromFile(filename, consideredJoints, emptyRemovedJointPositions, filetype, packageDirs);
}

bool ModelLoader::loadReducedModelFromFullModel(const Model& fullModel,
const std::vector< std::string >& consideredJoints,
const std::map<std::string, double>& removedJointPositions,
const std::unordered_map<std::string, double>& removedJointPositions,
const std::string /*filetype*/)
{
Model _modelReduced;
@@ -170,7 +170,7 @@ namespace iDynTree

bool ModelLoader::loadReducedModelFromString(const std::string modelString,
const std::vector< std::string >& consideredJoints,
const std::map<std::string, double>& removedJointPositions,
const std::unordered_map<std::string, double>& removedJointPositions,
const std::string filetype,
const std::vector<std::string>& packageDirs /*= {}*/)
{
@@ -192,7 +192,7 @@ namespace iDynTree

bool ModelLoader::loadReducedModelFromFile(const std::string filename,
const std::vector< std::string >& consideredJoints,
const std::map<std::string, double>& removedJointPositions,
const std::unordered_map<std::string, double>& removedJointPositions,
const std::string filetype,
const std::vector<std::string>& packageDirs /*= {}*/)
{

0 comments on commit 36956df

Please sign in to comment.