Mujoco KDL Wrapper  0.2.2
MuJoCo + KDL bridge for robot kinematics and dynamics
Loading...
Searching...
No Matches
fetch_examples.py
Go to the documentation of this file.
1"""Copy the bundled mj_kdl_wrapper example scripts to a local directory.
2
3The example scripts are shipped inside the wheel under
4``mj_kdl_wrapper/examples``. This helper copies them out as a sibling
5``examples/`` directory that you can run from directly. The scripts resolve
6Menagerie models and bundled assets (the Robotiq 2F-85 gripper, table, and mug
7MJCF files) via :mod:`mj_kdl_wrapper.menagerie`, which reads from the user
8cache populated by ``mj-kdl-fetch-menagerie`` -- not from the current working
9directory.
10"""
11
12from __future__ import annotations
13
14import argparse
15import shutil
16from importlib import resources
17from pathlib import Path
18
19
20def copy_examples(dest: Path) -> None:
21 """Copy the bundled example scripts into ``dest`` as a sibling dir."""
22 pkg_root = resources.files("mj_kdl_wrapper")
23 with resources.as_file(pkg_root / "examples") as examples_src:
24 shutil.copytree(examples_src, dest / "examples", dirs_exist_ok=True)
25
26
27def main() -> int:
28 parser = argparse.ArgumentParser(
29 description="Copy the bundled mj_kdl_wrapper example scripts to a local directory."
30 )
31 parser.add_argument(
32 "--dest",
33 default="mj_kdl_wrapper_examples",
34 help="Destination directory (default: ./mj_kdl_wrapper_examples)",
35 )
36 args = parser.parse_args()
37
38 dest = Path(args.dest)
39 copy_examples(dest)
40
41 print(f"Copied examples to {dest}/")
42 print("Run, e.g.:")
43 print(f" cd {dest}")
44 print(" mj-kdl-fetch-menagerie")
45 print(" python examples/ex_pick.py --gui")
46 return 0
47
48
49if __name__ == "__main__":
50 raise SystemExit(main())