Mujoco KDL Wrapper  0.3.18
MuJoCo + KDL bridge for robot kinematics and dynamics
Loading...
Searching...
No Matches
_mj_kdl_wrapper.pyi
Go to the documentation of this file.
1from __future__ import annotations
2
3from enum import Enum
4from typing import Callable, Optional, Sequence, Union, overload
5
6import PyKDL as kdl
7
8
9class LogLevel(Enum):
10 NONE: "LogLevel"
11 INFO: "LogLevel"
12 WARN: "LogLevel"
13 ERROR: "LogLevel"
14
15
16class AttachKind(Enum):
17 World: "AttachKind"
18 Body: "AttachKind"
19 Site: "AttachKind"
20 Frame: "AttachKind"
21
22
23class Shape(Enum):
24 Unspecified: "Shape"
25 BOX: "Shape"
26 SPHERE: "Shape"
27 CYLINDER: "Shape"
28
29
30class Condim(Enum):
31 Tangential: "Condim"
32 Torsional: "Condim"
33 Rolling: "Condim"
34
35
36class CtrlMode(Enum):
37 POSITION: "CtrlMode"
38 TORQUE: "CtrlMode"
39
40
41class VideoResolution(Enum):
42 R360p: "VideoResolution"
43 R480p: "VideoResolution"
44 R720p: "VideoResolution"
45 R1080p: "VideoResolution"
46 R2K: "VideoResolution"
47 R4K: "VideoResolution"
48
49
51 """Placement target in an accumulated scene spec."""
52 kind: AttachKind
53 name: str
54 def __init__(self, kind: AttachKind = AttachKind.World, name: str = "") -> None: ...
55
56
58 """MJCF attachment applied to a robot root or prior attachment."""
59 mjcf_path: str
60 attach_to: AttachTarget
61 prefix: str
62 pos: list[float]
63 quat: list[float]
64 contact_exclusions: list[tuple[str, str]]
65 def __init__(self) -> None: ...
66
67
69 """Robot root MJCF plus placement and ordered attachment specs."""
70 path: str
71 prefix: str
72 attach_to: AttachTarget
73 pos: list[float]
74 quat: list[float]
75 attachments: list[AttachmentSpec]
76 def __init__(self) -> None: ...
77
78
80 """MJCF asset or primitive object. Primitive size, rgba, mass, and friction are required."""
81 name: str
82 mjcf_path: str
83 attach_to: AttachTarget
84 shape: Shape
85 size: Optional[list[float]]
86 pos: list[float]
87 quat: list[float]
88 rgba: Optional[list[float]]
89 fixed: bool
90 mass: Optional[float]
91 condim: Condim
92 friction: Optional[list[float]]
93 def __init__(self) -> None: ...
94
95
97 """Named camera on a body, or in the world when body is empty. pos and fovy are required."""
98 name: str
99 body: str
100 pos: Optional[list[float]]
101 quat: list[float]
102 fovy: Optional[float]
103 def __init__(self) -> None: ...
104
105
107 """Full scene description. timestep, add_floor, and add_skybox are required."""
108 robots: list[RobotSpec]
109 timestep: Optional[float]
110 gravity_z: float
111 add_floor: Optional[bool]
112 floor_z: float
113 add_skybox: Optional[bool]
114 objects: list[SceneObject]
115 cameras: list[CameraSpec]
116 def __init__(self) -> None: ...
117
118
120 """Logical FT sensor backed by MuJoCo force and torque sensors."""
121 name: str
122 force_sensor: str
123 torque_sensor: str
124 frame_site: str
125 def __init__(self) -> None: ...
126
127
129 """Optional tool mass/TCP description for building the robot KDL chain."""
130 tool_body: str
131 tcp_site: str
132 ft_sensors: list[ForceTorqueSensorSpec]
133 def __init__(self) -> None: ...
134
135
137 keyframe: int
138 use_keyframe: bool
139 def __init__(self) -> None: ...
140
141
143 used_keyframe: bool
144 keyframe: int
145
146
148 """Context passed to Env.on_reset after MuJoCo data is reset."""
149 @property
150 def options(self) -> ResetOptions: ...
151 @property
152 def info(self) -> ResetInfo: ...
153
154
155class Scene:
156 """Owned MuJoCo model/data built from SceneSpec."""
157 spec: SceneSpec
158 @staticmethod
159 def build(spec: SceneSpec) -> "Scene": ...
160 """Build and compile a MuJoCo scene."""
161 def close(self) -> None: ...
162 def save_xml(self, path: str) -> None: ...
163 def save_binary(self, path: str) -> None: ...
164 def time(self) -> float: ...
165 def timestep(self) -> float: ...
166 def step(self) -> None: ...
167 def step_n(self, n: int) -> None: ...
168 def camera_names(self) -> list[str]: ...
169 def body_frame(self, name: str) -> kdl.Frame: ...
170 """Return a body world pose as PyKDL.Frame."""
171 def site_frame(self, name: str) -> kdl.Frame: ...
172 """Return a site world pose as PyKDL.Frame."""
174 self,
175 name: str,
176 pos: Sequence[float],
177 quat: Optional[Sequence[float]] = None,
178 ) -> None: ...
179 """Set a free body pose. quat is xyzw when provided."""
180 def set_actuator_ctrl(self, name: str, value: float) -> None: ...
182 self,
183 name: str,
184 force: Sequence[float],
185 torque: Sequence[float] = (0.0, 0.0, 0.0),
186 ) -> None: ...
187 """Set a world-frame external body wrench."""
188 def actuator_ctrl(self, name: str) -> float: ...
189 def has_actuator(self, name: str) -> bool: ...
190 def add_object(self, object: SceneObject) -> None: ...
191 """Rebuild the scene with an added object and rebind existing Robot handles."""
192 def remove_object(self, name: str) -> None: ...
193 """Rebuild the scene without the named object and rebind existing Robot handles."""
194
195
196class Robot:
197 """Robot handle synchronized with a Scene or Env and backed by a wrapper-built KDL chain."""
198 ctrl_mode: CtrlMode
199 paused: bool
200 n_joints: int
201 joint_names: list[str]
202 joint_limits: list[tuple[float, float]]
203 jnt_pos_msr: list[float]
204 jnt_vel_msr: list[float]
205 jnt_trq_msr: list[float]
206 jnt_pos_cmd: list[float]
207 jnt_trq_cmd: list[float]
208 @staticmethod
210 scene: Scene,
211 base_body: str,
212 tip_body: str,
213 prefix: str = "",
214 tool: Optional[ToolFrameSpec] = None,
215 ) -> "Robot": ...
216 def update(self) -> None: ...
217 def step(self) -> bool: ...
218 def pace(self) -> None: ...
219 def step_n(self, n: int) -> bool: ...
221 self,
222 q: Union[Sequence[float], kdl.JntArray],
223 call_forward: bool = True,
224 ) -> None: ...
225 def gravity_torques(self, gravity_z: float = -9.81) -> list[float]: ...
226 def kdl_chain(self) -> kdl.Chain: ...
227 """Return the wrapper-built chain as a PyKDL.Chain."""
228 @property
229 def ft_sensor_names(self) -> list[str]: ...
230 def ft_sensor(self, name: str) -> kdl.Wrench: ...
231 """Return the latest measured force-torque sensor value as a PyKDL.Wrench."""
232 def ft_sensor_frame(self, name: str) -> kdl.Frame: ...
233 """Return the configured FT sensor frame_site pose as a PyKDL.Frame."""
235 self,
236 q: Optional[Union[Sequence[float], kdl.JntArray]] = None,
237 ) -> kdl.Frame: ...
238 """Return FK terminal pose as PyKDL.Frame."""
239 @property
240 def has_tcp_frame(self) -> bool: ...
241 @property
242 def tcp_site(self) -> str: ...
243 @property
244 def tip_to_tcp(self) -> kdl.Frame: ...
245
246
248 """Wrapper for the custom MuJoCo simulate UI."""
249 realtime_factor: float
250 @staticmethod
251 @overload
252 def open(robot: Robot, title: str = "MuJoCo") -> "SimulateViewer": ...
253 @staticmethod
254 @overload
255 def open(scene: "Scene", title: str = "MuJoCo") -> "SimulateViewer": ...
256 def close(self) -> None: ...
257 def is_running(self) -> bool: ...
258 def step(self) -> bool: ...
259 def pace(self) -> None: ...
260 def step_n(self, n: int) -> bool: ...
261 def clear_trace(self) -> None: ...
263 self,
264 a: Sequence[float],
265 b: Sequence[float],
266 rgba: Optional[Sequence[float]] = None,
267 ) -> None: ...
268 def use_camera(self, name: str = "") -> bool: ...
270 self,
271 distance: float,
272 azimuth: float,
273 elevation: float,
274 lookat: tuple[float, float, float] = (0.0, 0.0, 0.0),
275 ) -> None: ...
276
277
279 """Offscreen MuJoCo video recorder for a Scene or Env."""
280 @staticmethod
281 def open(
282 scene: Union["Scene", "Env"],
283 out_path: str,
284 width: int = 1280,
285 height: int = 720,
286 fps: int = 60,
287 ) -> "VideoRecorder": ...
288 @staticmethod
290 scene: Union["Scene", "Env"],
291 out_path: str,
292 resolution: VideoResolution = VideoResolution.R720p,
293 fps: int = 60,
294 ) -> "VideoRecorder": ...
295 def record_frame(self) -> bool: ...
296 def use_camera(self, name: str = "") -> bool: ...
298 self,
299 distance: float,
300 azimuth: float,
301 elevation: float,
302 lookat: tuple[float, float, float] = (0.0, 0.0, 0.0),
303 ) -> None: ...
304 def close(self) -> None: ...
305
306
307class Env:
308 """Resettable scene environment that keeps registered Robot handles synchronized."""
309 spec: SceneSpec
310 on_reset: Optional[Callable[[ResetContext], None]]
311 @staticmethod
312 def build(spec: SceneSpec) -> "Env": ...
313 def close(self) -> None: ...
315 self,
316 base_body: str,
317 tip_body: str,
318 prefix: str = "",
319 tool: Optional[ToolFrameSpec] = None,
320 ) -> Robot: ...
321 def reset(self, options: Optional[ResetOptions] = None) -> ResetInfo: ...
322 def add_object(self, object: SceneObject) -> None: ...
323 """Rebuild the environment with an added object and rebind existing Robot handles."""
324 def remove_object(self, name: str) -> None: ...
325 """Rebuild the environment without the named object and rebind existing Robot handles."""
326 def camera_names(self) -> list[str]: ...
327 def time(self) -> float: ...
328 def timestep(self) -> float: ...
329 def body_frame(self, name: str) -> kdl.Frame: ...
330 def site_frame(self, name: str) -> kdl.Frame: ...
332 self,
333 name: str,
334 pos: Sequence[float],
335 quat: Optional[Sequence[float]] = None,
336 ) -> None: ...
337 def set_actuator_ctrl(self, name: str, value: float) -> None: ...
339 self,
340 name: str,
341 force: Sequence[float],
342 torque: Sequence[float] = (0.0, 0.0, 0.0),
343 ) -> None: ...
344 def actuator_ctrl(self, name: str) -> float: ...
345 def has_actuator(self, name: str) -> bool: ...
346 def save_xml(self, path: str) -> None: ...
347 def save_binary(self, path: str) -> None: ...
348
349
350__version__: str
351__mujoco_version__: str
352
353def set_log_level(level: LogLevel) -> None: ...
354def get_log_level() -> LogLevel: ...
355def mujoco_version() -> str: ...
356def scene_object_site_name(object: SceneObject, site_name: str) -> str: ...
None __init__(self, AttachKind kind=AttachKind.World, str name="")
kdl.Frame site_frame(self, str name)
None set_actuator_ctrl(self, str name, float value)
None set_body_wrench(self, str name, Sequence[float] force, Sequence[float] torque=(0.0, 0.0, 0.0))
kdl.Frame body_frame(self, str name)
ResetInfo reset(self, Optional[ResetOptions] options=None)
None add_object(self, SceneObject object)
Robot create_robot(self, str base_body, str tip_body, str prefix="", Optional[ToolFrameSpec] tool=None)
None set_body_pose(self, str name, Sequence[float] pos, Optional[Sequence[float]] quat=None)
None set_joint_pos(self, Union[Sequence[float], kdl.JntArray] q, bool call_forward=True)
"Robot" from_scene(Scene scene, str base_body, str tip_body, str prefix="", Optional[ToolFrameSpec] tool=None)
kdl.Frame ft_sensor_frame(self, str name)
kdl.Wrench ft_sensor(self, str name)
kdl.Frame fk_frame(self, Optional[Union[Sequence[float], kdl.JntArray]] q=None)
list[float] gravity_torques(self, float gravity_z=-9.81)
None set_actuator_ctrl(self, str name, float value)
kdl.Frame body_frame(self, str name)
kdl.Frame site_frame(self, str name)
None set_body_pose(self, str name, Sequence[float] pos, Optional[Sequence[float]] quat=None)
None add_object(self, SceneObject object)
None set_body_wrench(self, str name, Sequence[float] force, Sequence[float] torque=(0.0, 0.0, 0.0))
None set_free_camera(self, float distance, float azimuth, float elevation, tuple[float, float, float] lookat=(0.0, 0.0, 0.0))
None add_trace_segment(self, Sequence[float] a, Sequence[float] b, Optional[Sequence[float]] rgba=None)
"SimulateViewer" open(Robot robot, str title="MuJoCo")
"VideoRecorder" open_preset(Union["Scene", "Env"] scene, str out_path, VideoResolution resolution=VideoResolution.R720p, int fps=60)
None set_free_camera(self, float distance, float azimuth, float elevation, tuple[float, float, float] lookat=(0.0, 0.0, 0.0))
"VideoRecorder" open(Union["Scene", "Env"] scene, str out_path, int width=1280, int height=720, int fps=60)
str scene_object_site_name(SceneObject object, str site_name)
None set_log_level(LogLevel level)