Fix a bug in mj_recompile.
The qposadr_ and dofadr_ variables of the joints were not being reset to -1 when a joint is copied. This could lead to errors when calling mj_recompile after attaching a compiled spec. PiperOrigin-RevId: 686152004 Change-Id: I9e058089ce87ea0d8e51a7f43475bc48c6527a26
This commit is contained in:
committed by
Copybara-Service
parent
d646ba8de1
commit
11af1e2a95
+17
-12
@@ -96,21 +96,26 @@ mjModel* mj_compile(mjSpec* s, const mjVFS* vfs) {
|
||||
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||
std::string state_name = "state";
|
||||
mjtNum time = 0;
|
||||
if (d) {
|
||||
time = d->time;
|
||||
modelC->SaveState(state_name, d->qpos, d->qvel, d->act, d->ctrl, d->mocap_pos, d->mocap_quat);
|
||||
}
|
||||
if (!modelC->Compile(vfs, &m)) {
|
||||
try {
|
||||
if (d) {
|
||||
mj_deleteData(d);
|
||||
time = d->time;
|
||||
modelC->SaveState(state_name, d->qpos, d->qvel, d->act, d->ctrl, d->mocap_pos, d->mocap_quat);
|
||||
}
|
||||
if (!modelC->Compile(vfs, &m)) {
|
||||
if (d) {
|
||||
mj_deleteData(d);
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
if (d) {
|
||||
modelC->MakeData(m, &d);
|
||||
modelC->RestoreState(state_name, m->qpos0, m->body_pos, m->body_quat, d->qpos, d->qvel,
|
||||
d->act, d->ctrl, d->mocap_pos, d->mocap_quat);
|
||||
d->time = time;
|
||||
}
|
||||
} catch (mjCError& e) {
|
||||
modelC->SetError(e);
|
||||
return -1;
|
||||
};
|
||||
if (d) {
|
||||
modelC->MakeData(m, &d);
|
||||
modelC->RestoreState(state_name, m->qpos0, m->body_pos, m->body_quat, d->qpos, d->qvel,
|
||||
d->act, d->ctrl, d->mocap_pos, d->mocap_quat);
|
||||
d->time = time;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user