Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8cfbfe4
code_optimized
sahil-tgs Jul 28, 2025
8ec7beb
Joint Space Controll
sahil-tgs Aug 4, 2025
bde69a3
Robosuite Pre-config env only
sahil-tgs Aug 7, 2025
9641225
import fix.scenic
sahil-tgs Aug 7, 2025
d8dfc69
Robosuite Pre-config env only fixed
sahil-tgs Aug 7, 2025
6ba582d
Custom Env
sahil-tgs Sep 4, 2025
4ea472f
removed redundant class attributes
sahil-tgs Sep 7, 2025
70272a4
removed suite.make integration
sahil-tgs Sep 8, 2025
4ea382c
basic xml integration
sahil-tgs Sep 8, 2025
e164c52
checkpoint(xml): prototype XML integration (supports predefined forma…
sahil-tgs Sep 13, 2025
a3eff35
feat(xml): add full MJCF support
sahil-tgs Sep 15, 2025
f6f5ab2
feat(robosuite): Enable MJCF XML to MeshShape conversion for geometry…
sahil-tgs Sep 26, 2025
e3b7185
Merge pull request #2 from sahil-tgs/feature/mesh-extraction
sahil-tgs Sep 27, 2025
207afe8
fix: table renderd as block in robosuite
sahil-tgs Sep 28, 2025
9a8a329
fix: robosuite import warning printing without -S flag
sahil-tgs Sep 29, 2025
6909844
fix: Object Factory handelling
sahil-tgs Sep 29, 2025
2331eb9
Fix: robot positioning to fail explicitly on count mismatch instead o…
sahil-tgs Sep 29, 2025
f5085d8
fix: Removed redundent method
sahil-tgs Sep 29, 2025
cdb8e55
docs: add docstrings for <RobosuiteSimulator> Args
sahil-tgs Sep 29, 2025
5863aea
Refactor: Pass simulation object directly to env instead of dict packing
sahil-tgs Sep 29, 2025
97ddd08
Refactor: remove unused SetJointPositions, add proper validation with…
sahil-tgs Sep 29, 2025
283c454
Merge pull request #3 from sahil-tgs/feature/mesh-extraction
sahil-tgs Sep 29, 2025
df5e895
fix: Fetch dynamic properties from RoboSuite during simulation
sahil-tgs Sep 29, 2025
2f69a59
doc: documented major known issues and project status
sahil-tgs Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions examples/robosuite/custom_mjcf_table.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# examples/robosuite/custom_mjcf_table.scenic
"""Test with two XML tables and XML cubes on top, positioned in front of robot."""
model scenic.simulators.robosuite.model

# Get the directory of this scenic file for relative paths
param scenic_file_dir = localPath(".")

# Table 1 XML - a manipulable table object
table_xml = """
<mujoco model="table">
<worldbody>
<body>
<body name="object">
<!-- Table top -->
<geom name="table_top_visual"
type="box"
size="0.4 0.3 0.025"
pos="0 0 0"
rgba="0.6 0.3 0.1 1"
group="1"/>

<!-- Table legs -->
<geom name="leg1_visual" type="cylinder" pos="0.35 0.25 -0.4" size="0.02 0.4" rgba="0.5 0.25 0.05 1" group="1"/>
<geom name="leg2_visual" type="cylinder" pos="-0.35 0.25 -0.4" size="0.02 0.4" rgba="0.5 0.25 0.05 1" group="1"/>
<geom name="leg3_visual" type="cylinder" pos="0.35 -0.25 -0.4" size="0.02 0.4" rgba="0.5 0.25 0.05 1" group="1"/>
<geom name="leg4_visual" type="cylinder" pos="-0.35 -0.25 -0.4" size="0.02 0.4" rgba="0.5 0.25 0.05 1" group="1"/>
</body>
</body>
</worldbody>
</mujoco>
"""

# Red cube XML
red_cube_xml = """
<mujoco model="red_cube">
<worldbody>
<body>
<body name="object">
<geom name="cube_visual"
type="box"
size="0.03 0.03 0.03"
pos="0 0 0"
rgba="0.9 0.1 0.1 1"
group="1"/>
</body>
</body>
</worldbody>
</mujoco>
"""

# Green cube XML
green_cube_xml = """
<mujoco model="green_cube">
<worldbody>
<body>
<body name="object">
<geom name="cube_visual"
type="box"
size="0.03 0.03 0.03"
pos="0 0 0"
rgba="0.1 0.9 0.1 1"
group="1"/>
</body>
</body>
</worldbody>
</mujoco>
"""


# Create the first table (brown) - closer to robot
table1 = new CustomObject on arena_floor,
with mjcfXml table_xml

# Create the second table (blue) - farther from robot
table2 = new CustomObject on arena_floor,
with mjcfXml table_xml


red_cube = new CustomObject on table1,
with mjcfXml red_cube_xml

# Place green cube on second table
green_cube = new CustomObject on table2,
with mjcfXml green_cube_xml

# Robot at origin
ego = new Panda at (0, 0, 0)
Binary file added examples/robosuite/custom_object/bread.stl
Binary file not shown.
18 changes: 18 additions & 0 deletions examples/robosuite/custom_object/bread.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- examples/robosuite/custom_object/bread.xml -->
<mujoco model="bread">
<asset>
<mesh file="bread.stl" name="bread_mesh" scale="2 2 2"/>
<texture file="textures/bread.png" type="2d" name="tex-bread" />
<material name="bread" reflectance="0.7" texrepeat="15 15" texture="tex-bread" texuniform="true"/>
</asset>
<worldbody>
<body>
<body name="object">
<geom pos="0 0 0" mesh="bread_mesh" type="mesh" solimp="0.998 0.998 0.001" solref="0.001 1" density="50" friction="0.95 0.3 0.1" material="bread" group="0" condim="4"/>
</body>
<site rgba="0 0 0 0" size="0.005" pos="0 0 -0.045" name="bottom_site"/>
<site rgba="0 0 0 0" size="0.005" pos="0 0 0.03" name="top_site"/>
<site rgba="0 0 0 0" size="0.005" pos="0.03 0.03 0" name="horizontal_radius_site"/>
</body>
</worldbody>
</mujoco>
Binary file added examples/robosuite/custom_object/dragon.stl
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions examples/robosuite/dual_table_workspace.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# examples/robosuite/dual_table_workspace.scenic
model scenic.simulators.robosuite.model

# Arena Setup
back_table = new Table at (-0.6, 0, 0.8)
front_table = new Table at (0.6, 0, 0.8)

# OBJECTS
red_cube = new Box at (Range(-0.7, -0.5), Range(-0.1, 0.1), 0.83),
with color (1, 0, 0, 1),


green_cube = new Box at (Range(0.5, 0.7), Range(-0.1, 0.1), 0.83),
with color (0, 1, 0, 1),
with width 0.05, with length 0.05, with height 0.05

# ROBOT
ego = new Panda at (0, 0, 0)
16 changes: 16 additions & 0 deletions examples/robosuite/file_xml.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# examples/robosuite/file_xml.scenic
"""Test loading CustomObjects from XML files with mesh and texture assets."""
model scenic.simulators.robosuite.model

param scenic_file_dir = localPath(".")

# Robot at origin
ego = new Panda on (0, 0, 0)

# Use built-in Table object
table1 = new Table on arena_floor

# Load bread object from XML file
bread = new CustomObject on table1,
with mjcfXml "custom_object/bread.xml",
with color (0, 1, 1, 1)
77 changes: 77 additions & 0 deletions examples/robosuite/full_xml_test3.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# examples/robosuite/full_xml.scenic
"""Currently No support for custom_arena_xml. fix: WIP"""
"""Test custom arena and custom objects with complete MJCF XML."""
model scenic.simulators.robosuite.model

# Define the complete custom arena XML
custom_arena_xml = """
<mujoco model="custom_arena">
<asset>
<texture builtin="gradient" height="256" rgb1=".9 .9 1." rgb2=".2 .3 .4" type="skybox" width="256"/>
<texture builtin="flat" height="512" name="texplane" rgb1="0.7 0.7 0.8" rgb2="0.5 0.5 0.6" type="2d"/>
<material name="floorplane" reflectance="0.01" shininess="0.0" specular="0.0" texrepeat="2 2" texture="texplane" texuniform="true"/>
</asset>
<worldbody>
<!-- Floor -->
<geom condim="3" material="floorplane" name="floor" pos="0 0 0" size="3 3 0.125" type="plane" group="1"/>

<!-- Light -->
<light pos="1.0 1.0 1.5" dir="-0.2 -0.2 -1" specular="0.3 0.3 0.3" directional="true" castshadow="false"/>

<!-- Camera -->
<camera name="frontview" pos="2 2 2" xyaxes="-1 1 0 -0.3 -0.3 1"/>

<!-- GREEN TABLE to confirm custom arena is being used -->
<body name="custom_table" pos="0.5 0 0.82">
<!-- Visual geoms (group 1) - GREEN -->
<geom name="table_top" type="box" size="0.4 0.5 0.025" rgba="0.2 0.9 0.2 1" group="1"/>
<geom name="table_leg1" type="cylinder" pos="0.35 0.45 -0.4" size="0.02 0.4" rgba="0.1 0.7 0.1 1" group="1"/>
<geom name="table_leg2" type="cylinder" pos="-0.35 0.45 -0.4" size="0.02 0.4" rgba="0.1 0.7 0.1 1" group="1"/>
<geom name="table_leg3" type="cylinder" pos="0.35 -0.45 -0.4" size="0.02 0.4" rgba="0.1 0.7 0.1 1" group="1"/>
<geom name="table_leg4" type="cylinder" pos="-0.35 -0.45 -0.4" size="0.02 0.4" rgba="0.1 0.7 0.1 1" group="1"/>

<!-- Collision geoms (group 0) -->
<geom name="table_top_col" type="box" size="0.4 0.5 0.025" rgba="0 0 0 0" group="0"/>
<geom name="table_leg1_col" type="cylinder" pos="0.35 0.45 -0.4" size="0.02 0.4" rgba="0 0 0 0" group="0"/>
<geom name="table_leg2_col" type="cylinder" pos="-0.35 0.45 -0.4" size="0.02 0.4" rgba="0 0 0 0" group="0"/>
<geom name="table_leg3_col" type="cylinder" pos="0.35 -0.45 -0.4" size="0.02 0.4" rgba="0 0 0 0" group="0"/>
<geom name="table_leg4_col" type="cylinder" pos="-0.35 -0.45 -0.4" size="0.02 0.4" rgba="0 0 0 0" group="0"/>
</body>
</worldbody>
</mujoco>
"""

# Define the ball object XML
ball_object_xml = """
<mujoco model="ball">
<worldbody>
<body>
<body name="object">
<geom name="visual"
type="sphere"
size="0.05"
rgba="1 1 0 1"
contype="0"
conaffinity="0"
group="1"/>
</body>
</body>
</worldbody>
</mujoco>
"""

# Create the custom arena
arena = new CustomArena,
with arena_xml custom_arena_xml

# Create a yellow ball using custom XML
yellow_ball = new CustomObject at (0.5, 0.0, 1.0),
with mjcfXml ball_object_xml

# Create a red box using built-in Box class for comparison
red_box = new Box at (0.7, 0.2, 1.0),
with color (1, 0, 0, 1),
with width 0.04, with length 0.04, with height 0.04

# Create the Panda robot
ego = new Panda at (-0.5, 0, 0)
54 changes: 54 additions & 0 deletions examples/robosuite/mesh_test.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# examples/robosuite/mesh_test.scenic
"""Test custom mesh objects with relative paths in XML."""
model scenic.simulators.robosuite.model

param scenic_file_dir = localPath(".")

# Dragon object XML - uses relative path to mesh file
dragon_object_xml = """
<mujoco model="dragon">
<asset>
<mesh name="dragon_mesh" file="custom_object/dragon.stl" scale="0.003 0.003 0.003"/>
<material name="dragon_mat" rgba="0.8 0.2 0.2 1" specular="0.5" shininess="0.3"/>
</asset>
<worldbody>
<body>
<body name="object">
<joint name="object_joint" type="free" damping="0.0005"/>

<geom name="visual"
pos="0 0 0"
mesh="dragon_mesh"
type="mesh"
material="dragon_mat"
contype="0"
conaffinity="0"
group="1"/>

<geom name="collision"
pos="0 0 0"
type="box"
size="0.04 0.04 0.01"
rgba="0 0 0 0"
group="0"/>
</body>
</body>
</worldbody>
</mujoco>
"""

# Use default table arena
table = new Table on arena_floor

# Create dragon - path in XML is relative to this .scenic file
dragon = new CustomObject on table,
with mjcfXml dragon_object_xml,
with color (1, 0, 1, 1)

# Add a simple ball for comparison
ball = new Ball on table,
with color (0, 1, 0, 1),
with radius 0.03

# Robot
ego = new Panda on (0, 0, 0)
78 changes: 78 additions & 0 deletions examples/robosuite/spatial_operators_demo.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# examples/robosuite/spatial_operators_demo.scenic
""" WIP """

"""
Demonstration of spatial operators with mesh-aware RoboSuite objects.
This example shows how Scenic can now use 'on' and other spatial operators
with RoboSuite objects thanks to mesh extraction.
"""
model scenic.simulators.robosuite.model

# Enable mesh extraction for spatial awareness
param extract_meshes = True
param scenic_file_dir = localPath(".")
param render = True
param camera_view = "frontview"

# Robot at origin
ego = new Panda at (0, 0, 0)

# Create a table - Scenic knows its surface geometry
main_table = new Table at (0.6, 0, 0.8),
with width 1.0,
with length 0.8

# Red box at table surface (Table position is already at surface height)
red_box = new Box at (0.6, -0.2, 0.85),
with color (1, 0, 0, 1),
with width 0.05, with length 0.05, with height 0.05

# Green ball also at table surface
green_ball = new Ball at (0.7, 0.1, 0.85),
with color (0, 1, 0, 1),
with radius 0.03

# Blue cylinder on top of the red box - stacking works now
blue_cylinder = new Cylinder on red_box, # Stack on top of box
with color (0, 0, 1, 1),
with width 0.04, with length 0.04, with height 0.08

# Custom object with mesh
custom_xml = """
<mujoco model="custom_block">
<worldbody>
<body>
<body name="object">
<geom name="visual"
type="box"
size="0.08 0.04 0.02"
pos="0 0 0"
rgba="0.8 0.8 0.2 1"
group="1"/>
</body>
</body>
</worldbody>
</mujoco>
"""

# Yellow block at table surface
yellow_block = new CustomObject at (0.5, 0.2, 0.85),
with mjcfXml custom_xml

# Complex object (Milk carton) at table surface
milk = new Milk at (0.8, -0.1, 0.85)

# Spatial constraint - require objects to be visible from robot
require ego can see red_box
require ego can see green_ball

# Behavior using spatial awareness
behavior PickupSequence():
"""Pick up objects in sequence based on their spatial positions."""
# Check which object is closer
if distance to red_box < distance to green_ball:
do PickAndLift(red_box, height=1.1)
else:
do PickAndLift(green_ball, height=1.1)

ego.behavior = PickupSequence()
30 changes: 30 additions & 0 deletions examples/robosuite/stack_lift.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# examples/robosuite/stack_lift.scenic
model scenic.simulators.robosuite.model

work_table = new Table on (0.6, 0, 0.8),
with width 0.6,
with length 1.2,
with height 0.05

bottom_cube = new Box on work_table,
with color (0.2, 0.3, 0.8, 1),
with width 0.06, with length 0.06, with height 0.06

top_cube = new Box on bottom_cube,
with color (0.8, 0.2, 0.2, 1)


pickup_object = top_cube

behavior StackLift():
"""Pick up the top cube from the stack and lift it."""
do PickObject(pickup_object)
do LiftToHeight(1.05)
for _ in range(10):
if pickup_object.position.z > 1.0:
terminate simulation
wait
terminate simulation

ego = new UR5e on (0, 0, 0),
with behavior StackLift()
Loading