Skip to content

Commit

Permalink
correcting the indexes for joints and bodys
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jan 2, 2024
1 parent 0d74277 commit cdb4ebb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/mujoco/MuJoCoModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public double getCurrentSimulationTimeSeconds() {
return data.time();
}
public int getNumberOfJoints() {
return model.nu();
return model.njnt();
}
public String getJointName(int i) {
if(i<0)
Expand All @@ -79,12 +79,14 @@ public int getNumberOfBodys() {
public String getBodyName(int i) {
if(i<0)
throw new IndexOutOfBoundsException("Body index must be positive or zero");
if(i>=getNumberOfJoints()) {
if(i>=getNumberOfBodys()) {
throw new IndexOutOfBoundsException("Body index must be less than "+i);
}
BytePointer byp = modelNames.getPointer(bodyNameIndex.getPointer(i).get());
return byp.getString();
}


public double getTimestepSeconds() {
return getOpt().timestep();
}
Expand Down

0 comments on commit cdb4ebb

Please sign in to comment.