1from __future__
import annotations
3from typing
import Any, Callable, ClassVar, Optional, Sequence, Union
7import numpy.typing
as npt
10_JointValues = Union[Sequence[float], npt.NDArray[np.float64]]
14 """A pybind11 enum: members are class attributes, not an enum.Enum."""
15 __members__: ClassVar[dict[str, Any]]
26 """Log threshold: messages at or above it print; NONE prints nothing."""
27 INFO: ClassVar[LogLevel]
28 WARN: ClassVar[LogLevel]
29 ERROR: ClassVar[LogLevel]
30 NONE: ClassVar[LogLevel]
34 World: ClassVar[AttachKind]
35 Body: ClassVar[AttachKind]
36 Site: ClassVar[AttachKind]
37 Frame: ClassVar[AttachKind]
41 Unspecified: ClassVar[Shape]
43 SPHERE: ClassVar[Shape]
44 CYLINDER: ClassVar[Shape]
48 Tangential: ClassVar[Condim]
49 Torsional: ClassVar[Condim]
50 Rolling: ClassVar[Condim]
54 POSITION: ClassVar[CtrlMode]
55 TORQUE: ClassVar[CtrlMode]
56 VELOCITY: ClassVar[CtrlMode]
60 R360p: ClassVar[VideoResolution]
61 R480p: ClassVar[VideoResolution]
62 R720p: ClassVar[VideoResolution]
63 R1080p: ClassVar[VideoResolution]
64 R2K: ClassVar[VideoResolution]
65 R4K: ClassVar[VideoResolution]
69 """A control mode build_scene adds to a robot, on its own actuator group."""
74 self, mode: CtrlMode = CtrlMode.TORQUE, joints: Sequence[str] = (), kv: float = 0.0
79 """Placement target in an accumulated scene spec."""
82 def __init__(self, kind: AttachKind = AttachKind.World, name: str =
"") ->
None: ...
86 """MJCF attachment applied to a robot root or prior attachment."""
88 attach_to: AttachTarget
92 modes: list[CtrlModeSpec]
93 """Control modes for its own joints; [] = native only."""
94 contact_exclusions: list[tuple[str, str]]
99 """Robot root MJCF plus placement and ordered attachment specs."""
102 attach_to: AttachTarget
105 attachments: list[AttachmentSpec]
106 modes: list[CtrlModeSpec]
107 """Extra control modes; default [TORQUE], [] = native only."""
112 """MJCF asset or primitive object. A primitive needs size, rgba and friction, and mass
113 unless fixed; rgba on an asset recolors its geoms."""
117 attach_to: AttachTarget
119 size: Optional[list[float]]
122 rgba: Optional[list[float]]
124 mass: Optional[float]
126 friction: Optional[list[float]]
131 """A frame marked on a body of the assembled scene."""
140 """Named camera on a body, or in the world when body is empty. pos and fovy are required."""
143 pos: Optional[list[float]]
145 fovy: Optional[float]
150 """Full scene description. timestep, add_floor, and add_skybox are required."""
151 robots: list[RobotSpec]
152 timestep: Optional[float]
154 add_floor: Optional[bool]
156 add_skybox: Optional[bool]
157 objects: list[SceneObject]
158 sites: list[SiteSpec]
159 cameras: list[CameraSpec]
164 """Logical FT sensor backed by MuJoCo force and torque sensors."""
173 """Optional tool mass/TCP description for building the robot KDL chain."""
176 ft_sensors: list[ForceTorqueSensorSpec]
194 """A copy of the reset's options and result, passed to Env.on_reset."""
198 def info(self) -> ResetInfo: ...
202 """Robot registered with an Env (Env.create_robot) and backed by a wrapper-built KDL chain.
203 Env.update() reads and commands it; Env.close() closes it."""
240 """Switch mode without a jump: seeds the new mode's commands from the current state."""
242 """Write MuJoCo joint positions; frames read afterwards follow them."""
244 """The robot's own chain as a PyKDL.Chain, valid while the robot lives."""
248 """Return the latest measured force-torque sensor value as a PyKDL.Wrench."""
256 """Per-joint force/torque limit of the active mode's actuators; fallback where
261 """The simulate UI of an Env, opened by Env.open_viewer(); inert while closed."""
262 realtime_factor: float
265 """True while the GLFW key code is held; False headless."""
267 """Claim a GLFW key so the UI does not act on it; capture=False gives it back."""
273 rgba: Optional[Sequence[float]] =
None,
281 lookat: Sequence[float] = (0.0, 0.0, 0.0),
286 """Offscreen MuJoCo video recorder for an Env."""
294 ) -> VideoRecorder: ...
299 resolution: VideoResolution = VideoResolution.R720p,
301 ) -> VideoRecorder: ...
304 """Open an offscreen renderer (no video file) for render_rgb()."""
306 """The Env's current state as a (height, width, 3) array, top row first."""
316 lookat: Sequence[float] = (0.0, 0.0, 0.0),
322 """The simulation: compiled scene, its robots and viewer. The loop is step(), then
323 update() (read every robot, apply its commands), then pace()."""
324 on_reset: Optional[Callable[[ResetContext],
None]]
325 """Called by reset() after every robot is re-seeded; its exception comes out of reset() or
329 """A copy of the SceneSpec the Env runs, with objects added or removed since build()."""
332 """The live mujoco.MjModel; a new object after add_object()/remove_object()."""
334 def data(self) -> mujoco.MjData:
335 """The live mujoco.MjData; a new object after add_object()/remove_object(). The viewer
336 thread reads it too: call mujoco functions on it only while the viewer is closed or
339 def build(spec: SceneSpec) -> Env: ...
341 """Close the viewer and free the model; robots become closed."""
349 tool: Optional[ToolFrameSpec] =
None,
354 joint_names: Sequence[str],
356 tool: Optional[ToolFrameSpec] =
None,
358 """Register a robot driven by chain; joint_names are the MuJoCo joints in chain order."""
360 """Advance one timestep; False once the viewer window is closed."""
362 """Read every robot, then apply its commands."""
364 """Sleep out this step's share of wall time; no-op headless. step() never sleeps."""
366 """Open the simulate UI; step() drives it, close() closes it."""
369 def reset(self, options: Optional[ResetOptions] =
None) -> ResetInfo:
370 """Reset MuJoCo state, re-seed every robot, then call on_reset; what it moves is read
373 """Rebuild with an added object; robots and the viewer follow the new model."""
375 """Switch robot (its SceneSpec.robots index) to mode, for robots driven without a
378 """Rebuild without the named object; robots and the viewer follow the new model."""
384 pos: Sequence[float],
385 quat: Optional[Sequence[float]] =
None,
387 """Set a free body pose. quat is xyzw when provided."""
392__mujoco_version__: str
395 """Print wrapper messages at level and above; NONE prints nothing."""
None __init__(self, AttachKind kind=AttachKind.World, str name="")
None __init__(self, CtrlMode mode=CtrlMode.TORQUE, Sequence[str] joints=(), float kv=0.0)
kdl.Frame site_frame(self, str name)
mujoco.MjModel model(self)
None open_viewer(self, str title="MuJoCo")
None set_control_mode(self, int robot, CtrlMode mode)
kdl.Frame body_frame(self, str name)
ResetInfo reset(self, Optional[ResetOptions] options=None)
Robot create_robot_from_chain(self, kdl.Chain chain, Sequence[str] joint_names, str prefix="", Optional[ToolFrameSpec] tool=None)
None add_object(self, SceneObject object)
Robot create_robot(self, str base_body, str tip_body, str prefix="", Optional[ToolFrameSpec] tool=None)
Env build(SceneSpec spec)
None save_model_xml(self, str path)
None __exit__(self, *object args)
None remove_object(self, str name)
None set_body_pose(self, str name, Sequence[float] pos, Optional[Sequence[float]] quat=None)
ResetOptions options(self)
list[str] ft_sensor_names(self)
npt.NDArray[np.float64] jnt_pos_cmd(self)
list[tuple[float, float]] joint_limits(self)
npt.NDArray[np.float64] jnt_vel_msr(self)
kdl.Chain kdl_chain(self)
npt.NDArray[np.float64] jnt_trq_cmd(self)
npt.NDArray[np.float64] jnt_vel_cmd(self)
list[str] joint_names(self)
None set_control_mode(self, CtrlMode mode)
npt.NDArray[np.float64] jnt_trq_msr(self)
kdl.Frame tip_T_tcp(self)
npt.NDArray[np.bool_] jnt_saturated(self)
npt.NDArray[np.float64] jnt_pos_msr(self)
kdl.Wrench ft_sensor(self, str name)
npt.NDArray[np.float64] joint_force_limits(self, float fallback=1e6)
None set_joint_pos(self, Union[_JointValues, kdl.JntArray] q)
None set_free_camera(self, float distance, float azimuth, float elevation, Sequence[float] lookat=(0.0, 0.0, 0.0))
VideoRecorder open_preset(Env env, str out_path, VideoResolution resolution=VideoResolution.R720p, int fps=60)
VideoRecorder __enter__(self)
None __exit__(self, *object args)
VideoRecorder open(Env env, str out_path, int width=1280, int height=720, int fps=60)
bool use_camera(self, str name="")
npt.NDArray[np.uint8] render_rgb(self)
VideoRecorder open_offscreen(Env env, int width, int height)
None add_trace_segment(self, Sequence[float] a, Sequence[float] b, Optional[Sequence[float]] rgba=None)
bool use_camera(self, str name="")
None set_free_camera(self, float distance, float azimuth, float elevation, Sequence[float] lookat=(0.0, 0.0, 0.0))
bool key_pressed(self, int key)
None capture_key(self, int key, bool capture=True)
None __init__(self, int value)
None set_log_level(LogLevel level)