|
| 1 | +"""Scenic world model for robotic manipulation scenarios in ManiSkill. |
| 2 | +
|
| 3 | +Global Parameters: |
| 4 | + render (bool): Whether to render the simulation in a window. If True, it will open |
| 5 | + a window and display the simulation. If False (default), the simulation runs headless. |
| 6 | + stride (int): Number of simulation steps between action updates. Default is 1. |
| 7 | +""" |
| 8 | + |
| 9 | +try: |
| 10 | + from scenic.simulators.maniskill.simulator import ManiSkillSimulator |
| 11 | +except ModuleNotFoundError: |
| 12 | + # for convenience when testing without the mani_skill package |
| 13 | + from scenic.core.simulators import SimulatorInterfaceWarning |
| 14 | + import warnings |
| 15 | + warnings.warn('The "mani-skill" package is not installed; ' |
| 16 | + 'will not be able to run dynamic simulations', |
| 17 | + SimulatorInterfaceWarning) |
| 18 | + |
| 19 | + def ManiSkillSimulator(*args, **kwargs): |
| 20 | + """Dummy simulator to allow compilation without the 'mani-skill' package. |
| 21 | +
|
| 22 | + :meta private: |
| 23 | + """ |
| 24 | + raise RuntimeError('the "mani-skill" package is required to run simulations ' |
| 25 | + 'from this scenario') |
| 26 | + |
| 27 | +param render = False |
| 28 | +param stride = 1 |
| 29 | + |
| 30 | +simulator ManiSkillSimulator( |
| 31 | + render=bool(globalParameters.render), |
| 32 | + stride=int(globalParameters.stride), |
| 33 | +) |
| 34 | + |
| 35 | +class ManiskillObject(Object): |
| 36 | + """Base class for ManiSkill objects. |
| 37 | + |
| 38 | + Properties: |
| 39 | + visualFilename (str or None): Path to a visual mesh file (e.g., .glb, .obj, .usdz). |
| 40 | + visualScale (tuple): Scale factor for the visual mesh as (x, y, z). |
| 41 | + visualOffset (tuple): Offset for the visual mesh as (x, y, z) to match visual and collision meshes. |
| 42 | + kinematic (bool): If True, the object is kinematic (fixed in place). |
| 43 | + """ |
| 44 | + visualFilename: None |
| 45 | + visualScale: (1, 1, 1) |
| 46 | + visualOffset: (0, 0, 0) |
| 47 | + width: 1 |
| 48 | + length: 1 |
| 49 | + height: 1 |
| 50 | + color: [0.8, 0.8, 0.8, 1.0] |
| 51 | + kinematic: False |
| 52 | + |
| 53 | +class Ground(ManiskillObject): |
| 54 | + """The default ground plane from ManiSkill. |
| 55 | + |
| 56 | + This creates a large flat ground plane using ManiSkill's built-in ground builder. |
| 57 | + The ground is always kinematic (fixed in place). |
| 58 | + """ |
| 59 | + name: "ground" |
| 60 | + shape: BoxShape() |
| 61 | + width: 100 |
| 62 | + length: 100 |
| 63 | + height: 0.001 |
| 64 | + position: (0, 0, -0.0005) |
| 65 | + kinematic: True |
| 66 | + visualFilename: None |
| 67 | + isSimpleGround: True # Specify to ManiSkill that this is the ground plane |
| 68 | + |
| 69 | +class Robot(Object): |
| 70 | + """Robot object (Panda arm by default). |
| 71 | + |
| 72 | + This class represents a robot in the scene. The robot is not physically generated |
| 73 | + in the scene (skipGeneration=True) but is used to configure the robot's initial state. |
| 74 | + |
| 75 | + Properties: |
| 76 | + uuid (str): Robot type identifier. Default is "panda" for the Franka Emika Panda arm. |
| 77 | + jointAngles (list): Initial joint angles for the robot. If empty, uses a default configuration. |
| 78 | + """ |
| 79 | + position: (10, 0, 0) # Make scenic ignore it for collision checking for now |
| 80 | + name: "actor" |
| 81 | + uuid: "panda" |
| 82 | + jointAngles: [] |
| 83 | + skipGeneration: True # Don't generate this object in the scene |
| 84 | + |
| 85 | +class Camera(OrientedPoint): |
| 86 | + """Camera configuration for the scene. |
| 87 | + |
| 88 | + Cameras are not physical objects but define viewpoints for rendering and observation. |
| 89 | + |
| 90 | + Properties: |
| 91 | + img_width (int): Image width in pixels. Default is 640. |
| 92 | + img_height (int): Image height in pixels. Default is 480. |
| 93 | + fov (float): Field of view in radians. Default is 1.0. |
| 94 | + near (float): Near clipping plane distance. Default is 0.01. |
| 95 | + far (float): Far clipping plane distance. Default is 100.0. |
| 96 | + shader_pack (str): Shader pack to use for rendering. Default is "rt" (ray tracing). |
| 97 | + """ |
| 98 | + name: "camera" |
| 99 | + img_width: 640 |
| 100 | + img_height: 480 |
| 101 | + fov: 1.0 |
| 102 | + near: 0.01 |
| 103 | + far: 100.0 |
| 104 | + shader_pack: "rt" |
| 105 | + skipGeneration: True # Don't generate this as a physical object |
0 commit comments