Skip to main content

basic/
basic.rs

1//I borrowed this mujoco xml from the mujoco-rs readme.
2const EXAMPLE: &str = "
3<mujoco>
4  <worldbody>
5    <light ambient=\"0.2 0.2 0.2\"/>
6    <body name=\"ball\">
7        <geom name=\"green_sphere\" size=\".1\" rgba=\"0 1 0 1\" solref=\"0.004 1.0\"/>
8        <joint name=\"ball_joint\" type=\"free\"/>
9    </body>
10
11    <geom name=\"floor1\" type=\"plane\" size=\"10 10 1\" euler=\"15 4 0\" solref=\"0.004 1.0\"/>
12    <geom name=\"floor2\" type=\"plane\" pos=\"15 -20 0\" size=\"10 10 1\" euler=\"-15 -4 0\" solref=\"0.004 1.0\"/>
13
14  </worldbody>
15</mujoco>
16";
17
18fn main() {
19    let model = evomujoco::MjModel::from_xml_string(EXAMPLE).unwrap();
20    let mut mujoco = evomujoco::Mujoco::new(model);
21
22    loop {
23        mujoco.update();
24    }
25}