Mujoco KDL Wrapper  0.2.2
MuJoCo + KDL bridge for robot kinematics and dynamics
Loading...
Searching...
No Matches
basic_scene.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2"""Minimal headless mj_kdl_wrapper Python example."""
3
4from __future__ import annotations
5
6import mj_kdl_wrapper as mjk
7
8
9def main() -> int:
10 model_path = mjk.menagerie.model_path("kinova_gen3", env_var="MJ_KDL_MODEL")
11
12 spec = mjk.SceneSpec()
13 spec.timestep = 0.002
14 spec.add_floor = True
15 spec.add_skybox = True
16 robot_spec = mjk.RobotSpec()
17 robot_spec.path = model_path
18 spec.robots = [robot_spec]
19
20 scene = mjk.Scene.build(spec)
21 try:
22 robot = mjk.Robot.from_scene(scene, "base_link", "bracelet_link")
23 robot.jnt_pos_cmd = [0.0] * robot.n_joints
24
25 for _ in range(10):
26 robot.update()
27 robot.step()
28
29 print(f"joints: {robot.n_joints}")
30 print(f"joint_names: {robot.joint_names}")
31 print(f"q: {[round(x, 6) for x in robot.jnt_pos_msr]}")
32 print(f"cameras: {scene.camera_names()}")
33 finally:
34 scene.close()
35
36 return 0
37
38
39if __name__ == "__main__":
40 raise SystemExit(main())