Skip to content

Commit cdb4ebb

Browse files
committed
correcting the indexes for joints and bodys
1 parent 0d74277 commit cdb4ebb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/org/mujoco/MuJoCoModelManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public double getCurrentSimulationTimeSeconds() {
6262
return data.time();
6363
}
6464
public int getNumberOfJoints() {
65-
return model.nu();
65+
return model.njnt();
6666
}
6767
public String getJointName(int i) {
6868
if(i<0)
@@ -79,12 +79,14 @@ public int getNumberOfBodys() {
7979
public String getBodyName(int i) {
8080
if(i<0)
8181
throw new IndexOutOfBoundsException("Body index must be positive or zero");
82-
if(i>=getNumberOfJoints()) {
82+
if(i>=getNumberOfBodys()) {
8383
throw new IndexOutOfBoundsException("Body index must be less than "+i);
8484
}
8585
BytePointer byp = modelNames.getPointer(bodyNameIndex.getPointer(i).get());
8686
return byp.getString();
8787
}
88+
89+
8890
public double getTimestepSeconds() {
8991
return getOpt().timestep();
9092
}

0 commit comments

Comments
 (0)