Mujoco KDL Wrapper  0.2.2
MuJoCo + KDL bridge for robot kinematics and dynamics
Loading...
Searching...
No Matches
custom_ui_scene.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2"""Launch the mj_kdl_wrapper custom Simulate UI from Python."""
3
4from __future__ import annotations
5
6import mj_kdl_wrapper as mjk
7
8TITLE = "mj_kdl_wrapper Python UI"
9
10
11def main() -> int:
12 model_path = mjk.menagerie.model_path("kinova_gen3", env_var="MJ_KDL_MODEL")
13
14 spec = mjk.SceneSpec()
15 spec.timestep = 0.002
16 spec.add_floor = True
17 spec.add_skybox = True
18 robot_spec = mjk.RobotSpec()
19 robot_spec.path = model_path
20 spec.robots = [robot_spec]
21
22 scene = mjk.Scene.build(spec)
23 try:
24 robot = mjk.Robot.from_scene(scene, "base_link", "bracelet_link")
25 robot.jnt_pos_cmd = [0.0] * robot.n_joints
26
27 viewer = mjk.SimulateViewer.open(robot, TITLE)
28 try:
29 while viewer.is_running():
30 robot.update()
31 if not viewer.step():
32 break
33 finally:
34 viewer.close()
35 finally:
36 scene.close()
37
38 return 0
39
40
41if __name__ == "__main__":
42 raise SystemExit(main())