-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a helper class to make loading in Groovy easier
- Loading branch information
1 parent
60f5119
commit ebacbf7
Showing
2 changed files
with
87 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.mujoco; | ||
|
||
import java.io.File; | ||
|
||
import org.mujoco.MuJoCoLib.mjData; | ||
import org.mujoco.MuJoCoLib.mjData_; | ||
import org.mujoco.MuJoCoLib.mjModel; | ||
import org.mujoco.MuJoCoLib.mjModel_; | ||
import org.mujoco.MuJoCoLib.mjVFS; | ||
|
||
public class MuJoCoModelManager { | ||
MuJoCoLib lib = new MuJoCoLib(); | ||
|
||
private mjModel m; | ||
private mjData d; | ||
private mjModel_ maccessable; | ||
private mjData_ daccessable; | ||
|
||
public MuJoCoModelManager(File config){ | ||
byte[] error = new byte[1000]; | ||
int error_sz = 0; | ||
m = MuJoCoLib.mj_loadXML( | ||
config.getAbsolutePath(),(mjVFS) null, error, | ||
error_sz); | ||
if(m==null) | ||
throw new RuntimeException("Model File Failed to load "+new String(error)); | ||
System.out.println("Humanoid model loaded " + m); | ||
d = MuJoCoLib.mj_makeData(m); | ||
setModel(new mjModel_(m)); | ||
setData(new mjData_(d)); | ||
} | ||
|
||
public void close() { | ||
MuJoCoLib.mj_deleteData(d); | ||
MuJoCoLib.mj_deleteModel(m); | ||
} | ||
|
||
/** | ||
* @return the maccessable | ||
*/ | ||
public mjModel_ getModel() { | ||
return maccessable; | ||
} | ||
|
||
/** | ||
* @param maccessable the maccessable to set | ||
*/ | ||
private void setModel(mjModel_ maccessable) { | ||
this.maccessable = maccessable; | ||
} | ||
|
||
/** | ||
* @return the daccessable | ||
*/ | ||
public mjData_ getData() { | ||
return daccessable; | ||
} | ||
|
||
/** | ||
* @param daccessable the daccessable to set | ||
*/ | ||
public void setData(mjData_ daccessable) { | ||
this.daccessable = daccessable; | ||
} | ||
|
||
public void stepOne() { | ||
MuJoCoLib.mj_step1(m, d); | ||
} | ||
public void stepTwo() { | ||
MuJoCoLib.mj_step2(m, d); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters