Add map from objects names to their index.

Also some minor cleanup of repeated code in user_model.

PiperOrigin-RevId: 589135294
Change-Id: I16f22c4dbdde961cedc042af3bdc9d3577d33459
This commit is contained in:
Alessio Quaglino
2023-12-08 08:13:17 -08:00
committed by Copybara-Service
parent 623201ec76
commit a006b15958
2 changed files with 88 additions and 69 deletions
+9
View File
@@ -15,6 +15,8 @@
#ifndef MUJOCO_SRC_USER_USER_MODEL_H_
#define MUJOCO_SRC_USER_USER_MODEL_H_
#include <functional>
#include <map>
#include <string>
#include <utility>
#include <vector>
@@ -30,6 +32,10 @@ typedef enum _mjtInertiaFromGeom {
mjINERTIAFROMGEOM_AUTO // use only if inertial element is missing
} mjtInertiaFromGeom;
// TODO: convert mjListKeyMap to mjKeyMap[mjNOBJECT] by adding mjNOBJECT to mjtObj
typedef std::map<std::string, int, std::less<> > mjKeyMap;
typedef std::map<std::string, mjKeyMap, std::less<> > mjListKeyMap;
//---------------------------------- class mjCModel ------------------------------------------------
@@ -286,6 +292,9 @@ class mjCModel {
std::vector<mjCCamera*> cameras; // list of cameras
std::vector<mjCLight*> lights; // list of lights
// map from object names to ids
mjListKeyMap ids;
//------------------------ internal variables
bool hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator
bool compiled; // already compiled flag (cannot be compiled again)