Mujoco KDL Wrapper  0.2.2
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 euler: 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 euler: 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 rgba: Optional[list[float]]
88 fixed: bool
89 mass: Optional[float]
90 condim: Condim
91 friction: Optional[list[float]]
92 def __init__(self) -> None: ...
93
94
96 """Named fixed world camera. pos and fovy are required."""
97 name: str
98 pos: Optional[list[float]]
99 euler: list[float]
100 fovy: Optional[float]
101 def __init__(self) -> None: ...
102
103
105 """Full scene description. timestep, add_floor, and add_skybox are required."""
106 robots: list[RobotSpec]
107 timestep: Optional[float]
108 gravity_z: float
109 add_floor: Optional[bool]
110 add_skybox: Optional[bool]
111 objects: list[SceneObject]
112 cameras: list[CameraSpec]
113 def __init__(self) -> None: ...
114
115
117 """Logical FT sensor backed by MuJoCo force and torque sensors."""
118 name: str
119 force_sensor: str
120 torque_sensor: str
121 frame_site: str
122 def __init__(self) -> None: ...
123
124
126 """Optional tool mass/TCP description for building the robot KDL chain."""
127 tool_body: str
128 tcp_site: str
129 ft_sensors: list[ForceTorqueSensorSpec]
130 def __init__(self) -> None: ...
131
132
134 keyframe: int
135 use_keyframe: bool
136 def __init__(self) -> None: ...
137
138
140 used_keyframe: bool
141 keyframe: int
142
143
145 """Context passed to Env.on_reset after MuJoCo data is reset."""
146 @property
147 def options(self) -> ResetOptions: ...
148 @property
149 def info(self) -> ResetInfo: ...
150
151
152class Scene:
153 """Owned MuJoCo model/data built from SceneSpec."""
154 spec: SceneSpec
155 @staticmethod
156 def build(spec: SceneSpec) -> "Scene": ...
157 """Build and compile a MuJoCo scene."""
158 def close(self) -> None: ...
159 def save_xml(self, path: str) -> None: ...
160 def save_binary(self, path: str) -> None: ...
161 def time(self) -> float: ...
162 def timestep(self) -> float: ...
163 def step(self) -> None: ...
164 def step_n(self, n: int) -> None: ...
165 def camera_names(self) -> list[str]: ...
166 def body_frame(self, name: str) -> kdl.Frame: ...
167 """Return a body world pose as PyKDL.Frame."""
168 def site_frame(self, name: str) -> kdl.Frame: ...
169 """Return a site world pose as PyKDL.Frame."""
171 self,
172 name: str,
173 pos: Sequence[float],
174 quat: Optional[Sequence[float]] = None,
175 ) -> None: ...
176 """Set a free body pose. quat is xyzw when provided."""
177 def set_actuator_ctrl(self, name: str, value: float) -> None: ...
179 self,
180 name: str,
181 force: Sequence[float],
182 torque: Sequence[float] = (0.0, 0.0, 0.0),
183 ) -> None: ...
184 """Set a world-frame external body wrench."""
185 def actuator_ctrl(self, name: str) -> float: ...
186 def has_actuator(self, name: str) -> bool: ...
187 def add_object(self, object: SceneObject) -> None: ...
188 """Rebuild the scene with an added object and rebind existing Robot handles."""
189 def remove_object(self, name: str) -> None: ...
190 """Rebuild the scene without the named object and rebind existing Robot handles."""
191
192
193class Robot:
194 """Robot handle synchronized with a Scene or Env and backed by a wrapper-built KDL chain."""
195 ctrl_mode: CtrlMode
196 paused: bool
197 n_joints: int
198 joint_names: list[str]
199 joint_limits: list[tuple[float, float]]
200 jnt_pos_msr: list[float]
201 jnt_vel_msr: list[float]
202 jnt_trq_msr: list[float]
203 jnt_pos_cmd: list[float]
204 jnt_trq_cmd: list[float]
205 @staticmethod
207 scene: Scene,
208 base_body: str,
209 tip_body: str,
210 prefix: str = "",
211 tool: Optional[ToolFrameSpec] = None,
212 ) -> "Robot": ...
213 def update(self) -> None: ...
214 def step(self) -> bool: ...
215 def step_n(self, n: int) -> bool: ...
217 self,
218 q: Union[Sequence[float], kdl.JntArray],
219 call_forward: bool = True,
220 ) -> None: ...
221 def gravity_torques(self, gravity_z: float = -9.81) -> list[float]: ...
222 def kdl_chain(self) -> kdl.Chain: ...
223 """Return the wrapper-built chain as a PyKDL.Chain."""
224 @property
225 def ft_sensor_names(self) -> list[str]: ...
226 def ft_sensor(self, name: str) -> kdl.Wrench: ...
227 """Return the latest measured force-torque sensor value as a PyKDL.Wrench."""
228 def ft_sensor_frame(self, name: str) -> kdl.Frame: ...
229 """Return the configured FT sensor frame_site pose as a PyKDL.Frame."""
231 self,
232 q: Optional[Union[Sequence[float], kdl.JntArray]] = None,
233 ) -> kdl.Frame: ...
234 """Return FK terminal pose as PyKDL.Frame."""
235 @property
236 def has_tcp_frame(self) -> bool: ...
237 @property
238 def tcp_site(self) -> str: ...
239 @property
240 def tip_to_tcp(self) -> kdl.Frame: ...
241
242
244 """Wrapper for the custom MuJoCo simulate UI."""
245 realtime_factor: float
246 @staticmethod
247 @overload
248 def open(robot: Robot, title: str = "MuJoCo") -> "SimulateViewer": ...
249 @staticmethod
250 @overload
251 def open(scene: "Scene", title: str = "MuJoCo") -> "SimulateViewer": ...
252 def close(self) -> None: ...
253 def is_running(self) -> bool: ...
254 def step(self) -> bool: ...
255 def step_n(self, n: int) -> bool: ...
256 def clear_trace(self) -> None: ...
258 self,
259 a: Sequence[float],
260 b: Sequence[float],
261 rgba: Optional[Sequence[float]] = None,
262 ) -> None: ...
263 def use_camera(self, name: str = "") -> bool: ...
265 self,
266 distance: float,
267 azimuth: float,
268 elevation: float,
269 lookat: tuple[float, float, float] = (0.0, 0.0, 0.0),
270 ) -> None: ...
271
272
274 """Offscreen MuJoCo video recorder for a Scene or Env."""
275 @staticmethod
276 def open(
277 scene: Union["Scene", "Env"],
278 out_path: str,
279 width: int = 1280,
280 height: int = 720,
281 fps: int = 60,
282 ) -> "VideoRecorder": ...
283 @staticmethod
285 scene: Union["Scene", "Env"],
286 out_path: str,
287 resolution: VideoResolution = VideoResolution.R720p,
288 fps: int = 60,
289 ) -> "VideoRecorder": ...
290 def record_frame(self) -> bool: ...
291 def use_camera(self, name: str = "") -> bool: ...
293 self,
294 distance: float,
295 azimuth: float,
296 elevation: float,
297 lookat: tuple[float, float, float] = (0.0, 0.0, 0.0),
298 ) -> None: ...
299 def close(self) -> None: ...
300
301
302class Env:
303 """Resettable scene environment that keeps registered Robot handles synchronized."""
304 spec: SceneSpec
305 on_reset: Optional[Callable[[ResetContext], None]]
306 @staticmethod
307 def build(spec: SceneSpec) -> "Env": ...
308 def close(self) -> None: ...
310 self,
311 base_body: str,
312 tip_body: str,
313 prefix: str = "",
314 tool: Optional[ToolFrameSpec] = None,
315 ) -> Robot: ...
316 def reset(self, options: Optional[ResetOptions] = None) -> ResetInfo: ...
317 def add_object(self, object: SceneObject) -> None: ...
318 """Rebuild the environment with an added object and rebind existing Robot handles."""
319 def remove_object(self, name: str) -> None: ...
320 """Rebuild the environment without the named object and rebind existing Robot handles."""
321 def camera_names(self) -> list[str]: ...
322 def time(self) -> float: ...
323 def timestep(self) -> float: ...
324 def body_frame(self, name: str) -> kdl.Frame: ...
325 def site_frame(self, name: str) -> kdl.Frame: ...
327 self,
328 name: str,
329 pos: Sequence[float],
330 quat: Optional[Sequence[float]] = None,
331 ) -> None: ...
332 def set_actuator_ctrl(self, name: str, value: float) -> None: ...
334 self,
335 name: str,
336 force: Sequence[float],
337 torque: Sequence[float] = (0.0, 0.0, 0.0),
338 ) -> None: ...
339 def actuator_ctrl(self, name: str) -> float: ...
340 def has_actuator(self, name: str) -> bool: ...
341 def save_xml(self, path: str) -> None: ...
342 def save_binary(self, path: str) -> None: ...
343
344
345__version__: str
346__mujoco_version__: str
347
348def set_log_level(level: LogLevel) -> None: ...
349def get_log_level() -> LogLevel: ...
350def mujoco_version() -> str: ...
351def 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)