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
@@ -353,9 +353,7 @@ mjCModel& mjCModel::operator+=(const mjCModel& other) {
|
||||
|
||||
// create global lists
|
||||
mjCBody *world = bodies_[0];
|
||||
if (compiled) {
|
||||
ResetTreeLists();
|
||||
}
|
||||
ResetTreeLists();
|
||||
MakeLists(world);
|
||||
ProcessLists(/*checkrepeat=*/false);
|
||||
|
||||
@@ -3034,11 +3032,15 @@ template <class T>
|
||||
void mjCModel::SaveState(const std::string& state_name, const T* qpos, const T* qvel, const T* act,
|
||||
const T* ctrl, const T* mpos, const T* mquat) {
|
||||
for (auto joint : joints_) {
|
||||
if (joint->qposadr_ == -1 || joint->dofadr_ == -1) {
|
||||
throw mjCError(nullptr, "SaveState: joint %s has no address", joint->name.c_str());
|
||||
if (joint->qposadr_ < -1 || joint->dofadr_ < -1) {
|
||||
throw mjCError(nullptr, "SaveState: joint %s has invalid address", joint->name.c_str());
|
||||
}
|
||||
if (qpos && joint->qposadr_ != -1) {
|
||||
mjuu_copyvec(joint->qpos(state_name), qpos + joint->qposadr_, joint->nq());
|
||||
}
|
||||
if (qvel && joint->dofadr_ != -1) {
|
||||
mjuu_copyvec(joint->qvel(state_name), qvel + joint->dofadr_, joint->nv());
|
||||
}
|
||||
if (qpos) mjuu_copyvec(joint->qpos(state_name), qpos + joint->qposadr_, joint->nq());
|
||||
if (qvel) mjuu_copyvec(joint->qvel(state_name), qvel + joint->dofadr_, joint->nv());
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<actuators_.size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user