-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMuJoCoBasicDemo.lf
43 lines (38 loc) · 1.21 KB
/
MuJoCoBasicDemo.lf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file Basic Hello World program for Mujoco.
*
* This program uses the default physical model of the MuJoCoBase base class, which consists of a
* rectangular object that starts above a plane and falls down to the plane. This program adds very
* basic responses to keyboard commands. Specifically, _backspace_ or _delete_ will restart the
* simulation from its initial conditions, and `q` or `Q` will quit the simulation.
*
* See [README.md](../README.md) for prerequisites and installation instructions.
*
* @author Edward A. Lee
*/
target C {
keepalive: true // Because of physical action.
}
import MuJoCoAdvance from "lib/MuJoCoAdvance.lf"
main reactor(period: time = 16666667 ns) {
timer t(0, period)
m = new MuJoCoAdvance()
reaction(startup) {=
lf_print("\n*** Backspace to reset.");
lf_print("*** Type q to quit.");
=}
reaction(t) -> m.advance {=
lf_set(m.advance, true);
=}
reaction(m.key) -> m.restart {=
// If backspace: reset simulation
// If q or Q: quit
if (m.key->value.act==GLFW_PRESS) {
if (m.key->value.key==GLFW_KEY_BACKSPACE) {
lf_set(m.restart, true);
} else if (m.key->value.key==GLFW_KEY_Q) {
lf_request_stop();
}
}
=}
}