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:
Alessio Quaglino
2024-10-15 10:23:43 -07:00
committed by Copybara-Service
parent d646ba8de1
commit 11af1e2a95
5 changed files with 80 additions and 21 deletions
+4 -2
View File
@@ -425,8 +425,6 @@ class mjCJoint_ : public mjCBase {
mjCBody* body; // joint's body
// variable used for temporarily storing the state of the joint
int qposadr_; // address of dof in data->qpos
int dofadr_; // address of dof in data->qvel
std::map<std::string, std::array<mjtNum, 7>> qpos_; // qpos at the previous step
std::map<std::string, std::array<mjtNum, 6>> qvel_; // qvel at the previous step
@@ -473,6 +471,10 @@ class mjCJoint : public mjCJoint_, private mjsJoint {
private:
int Compile(void); // compiler; return dofnum
void PointToLocal(void);
// variables that should not be copied during copy assignment
int qposadr_; // address of dof in data->qpos
int dofadr_; // address of dof in data->qvel
};