GLFW window management and the real-time render/tick loop.
More...
|
| bool | mj_kdl::init_window (Viewer *v, Robot *r, const char *title="MuJoCo", int width=1280, int height=720) |
| |
| bool | mj_kdl::init_window_sim (Viewer *v, Robot *r, const char *title="MuJoCo") |
| |
| void | mj_kdl::cleanup (Viewer *v) |
| |
| bool | mj_kdl::step (Viewer *v, mjModel *m, mjData *d) |
| |
| bool | mj_kdl::is_running (const Viewer *v) |
| |
| bool | mj_kdl::render (Viewer *v, const Robot *r) |
| |
| bool | mj_kdl::render (Viewer *v, mjModel *m, mjData *d) |
| |
| bool | mj_kdl::use_camera (Viewer *v, const mjModel *model, const char *name) |
| |
GLFW window management and the real-time render/tick loop.
Use init_window_sim() + step() for the full simulate UI with physics panels. Use init_window() + render() for a lightweight manual render loop.
◆ cleanup()
| void mj_kdl::cleanup |
( |
Viewer * |
v | ) |
|
Release the GLFW window and MuJoCo visualization contexts owned by v.
- Parameters
-
| [in,out] | v | Viewer to tear down; all pointers set to null afterwards. |
◆ init_window()
| bool mj_kdl::init_window |
( |
Viewer * |
v, |
|
|
Robot * |
r, |
|
|
const char * |
title = "MuJoCo", |
|
|
int |
width = 1280, |
|
|
int |
height = 720 |
|
) |
| |
Open a GLFW window and initialise MuJoCo visualization contexts. Must be called after init_robot() or init_from_mjcf().
- Parameters
-
| [out] | v | Viewer to initialise; must be zero-initialised before call. |
| [in] | r | Robot whose model drives the rendering context. |
| [in] | title | Window title string. |
| [in] | width | Window width in pixels. |
| [in] | height | Window height in pixels. |
- Returns
- true on success, false if GLFW or MuJoCo context creation fails.
◆ init_window_sim()
| bool mj_kdl::init_window_sim |
( |
Viewer * |
v, |
|
|
Robot * |
r, |
|
|
const char * |
title = "MuJoCo" |
|
) |
| |
Open the full MuJoCo simulate UI (panels, physics controls, joint viewer) in a background render thread, then return so the caller can drive the physics loop with tick().
Use this instead of init_window() when you want the simulate UI panels alongside a user-owned loop. tick() automatically acquires the render mutex, steps physics, and handles pause / perturbation / speed controls.
Note: the render thread owns the GLFW window; on Linux (X11 / Wayland) this works correctly. Not supported on macOS.
- Parameters
-
| [out] | v | Viewer to initialise; freed by cleanup(Viewer *). |
| [in] | r | Robot to simulate. r is registered globally; pass the same Robot to every subsequent step() call so that keyboard and mouse perturbation callbacks operate on the correct model. Only one (Viewer, Robot) pair may be active at a time. |
| [in] | title | Label shown in the window title bar (default "MuJoCo"). |
- Returns
- true on success.
Referenced by main(), and main().
◆ is_running()
| bool mj_kdl::is_running |
( |
const Viewer * |
v | ) |
|
Returns true if the viewer window is open and not scheduled for closing.
- Parameters
-
◆ render() [1/2]
Render the current simulation frame to the viewer window.
- Parameters
-
- Returns
- true if the window is still open after rendering.
◆ render() [2/2]
| bool mj_kdl::render |
( |
Viewer * |
v, |
|
|
mjModel * |
m, |
|
|
mjData * |
d |
|
) |
| |
Render the current simulation frame to the viewer window. Model/data overload – use when no single Robot owns the scene (e.g. multi-robot).
- Parameters
-
- Returns
- true if the window is still open after rendering.
◆ step()
| bool mj_kdl::step |
( |
Viewer * |
v, |
|
|
mjModel * |
m, |
|
|
mjData * |
d |
|
) |
| |
Model/data overload of step() for multi-robot or no-robot GUI loops. Equivalent to the former tick(Viewer*, mjModel*, mjData*).
- Parameters
-
- Returns
- true while the window is open; false once the user closes it.
◆ use_camera()
| bool mj_kdl::use_camera |
( |
Viewer * |
v, |
|
|
const mjModel * |
model, |
|
|
const char * |
name |
|
) |
| |
Switch the viewer to a named fixed camera defined in the model. Works for both init_window() and init_window_sim() paths. Pass nullptr or an empty string to return to the free camera.
- Returns
- true if the camera name was found; false if not found (viewer unchanged).