Add recompilation test to user_api_test.

PiperOrigin-RevId: 613192683
Change-Id: Ibb44e1c2d63ac0afb7b5f3a15dff26378deb6c82
This commit is contained in:
Alessio Quaglino
2024-03-06 06:26:26 -08:00
committed by Copybara-Service
parent a00f1b5f30
commit 9ac048e262
8 changed files with 160 additions and 23 deletions
+11 -6
View File
@@ -100,7 +100,6 @@ mjCModel::mjCModel() {
center_auto[0] = center_auto[1] = center_auto[2] = 0;
#endif
nmocap = 0;
nplugin = 0;
//------------------------ private variables
cameras.clear();
@@ -326,6 +325,7 @@ void mjCModel::Clear(void) {
nB = 0;
njmax = -1;
nconmax = -1;
nmocap = 0;
// pointer lists created by Compile
bodies.clear();
@@ -2734,6 +2734,16 @@ static void warninghandler(const char* msg) {
// compiler
mjModel* mjCModel::Compile(const mjVFS* vfs) {
if (compiled) {
// clear kinematic tree
for (int i=0; i<bodies.size(); i++) {
bodies[i]->subtreedofs = 0;
}
mjCBody* world = bodies[0];
Clear();
bodies.push_back(world);
}
CopyFromSpec();
// The volatile keyword is necessary to prevent a possible memory leak due to
@@ -2799,11 +2809,6 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
throw mjCError(0, "NaN test does not work for present compiler/options");
}
// check for repeated compilation
if (compiled) {
throw mjCError(0, "model already compiled");
}
// check for joints in world body
if (!bodies[0]->joints.empty()) {
throw mjCError(0, "joint found in world body");