After reading this, you will know:
- How to assemble furniture
- Control the agent with human or RL
- Basic environment configuration
- Code structure and key functions
$ python -m furniture.demo_manual
We recommend trying the Cursor agent first to get a sense of the furniture and physics. The Cursor, Sawyer, and Baxter share a common control scheme. In general, the control is over the movement and rotation of the hand.
- Move: Q-E moves the hand up-down, W-S moves the hand forward-backward, and A-D moves the hand left-right.
- Rotate: J-L, I-K, U-O keys control each axis of rotation.
- Switch hands: 1 or 2 for the corresponding hand.
- Grasp: The space key holds an object within the Cursor. For Sawyer and Baxter, the space key closes the grippers.
- Attach: C will attach two parts together. The environment requires multiple attach actions to fully attach the parts together.
- Release: The enter (return) key releases any objects held by the Cursor. For Sawyer and Baxter, the enter key opens the grippers.
- Screenshot: T key will save the screen in
furniture/camera_ob.png
. - Record video: setting flag
--record True
in the command line args will record a video. - Record trajectory: To save the current episode to a pickle file, press Y. Make sure the
--record_demo
flag isTrue
. The scene will be saved in the demo directory astest.pkl
. You can load this scene using--load_demo
. Demonstration playback is supported through therun_demo
function offurniture/env/furniture.py
.
The Gym interface makes it easy to use the environment with various RL algorithms. Moreover, users can easily switch furniture models and backgrounds using reset
method. Please refer to furniture/demo_manual.py
for more detail.
import gym
import furniture
# make an environment
env = gym.make('IKEASawyer-v0', furniture_name="table_lack_0825")
done = False
# reset environment
observation = env.reset()
# reset environment with @furniture_id and @background_name
# observation = env.reset(furniture_id=furniture_id, background=background_name)
while not done:
# simulate environment
observation, reward, done, info = env.step(env.action_space.sample())
Here are some general command line configuration options.
'--furniture_name': str, name of furniture. Refer to furniture list in docs/configurations.md
'--furniture_id': int, ID of furniture. Refer to list below for ID furniture mappings
'--background': str, name of background scene. Refer to list below for supported scenes
'--unity': bool, use unity for rendering, otherwise use mujoco viewer
'--unity_editor' bool, use unity editor for unity
'--port': port, port for MuJoCo-Unity plugin
'--seed': int, seed for rng
'--max_episode_steps': int, maximum length (# of steps) of episode
'--screen_width': int, width of visual observation
'--screen_height': int, height of visual observation
'--camera_ids': list[int], MuJoCo camera ID
'--control_freq': int, frequency of physics simulation
'--move_speed': float, step size of movements
'--rotate_speed': float, step size of rotation
'--load_demo': string, path to a pickle file of a demonstration
'--record_demo': bool, whether to enable demonstration recording
'--demo_dir': string, path to demonstration folder
'--virtual_display': str, specify display number
Within each furniture/config/furniture_*.py
, there are environment specific configurations in the __init__
function. See Configure Environments for available furniture models, backgrounds, etc.
RGB | Depth | Segmentation |
To configure the observations, use the following flags.
'--robot_ob': bool, whether to include agent state in ob
'--object_ob': bool, whether to include object pose in ob
'--subtask_ob': bool, whether to include subtask (part ids) in ob
'--visual_ob': bool, whether to include camera image in ob
'--depth_ob': bool, whether to include depth map in ob
'--segmentation_ob': bool, whether to include object segmentation in ob
See demo_gym.py
for parallel execution of our environment.
The structure of the repository:
env
: Environment code for simulated experimentsfurniture-unity
: Unity projectconfig
: Argument parserutil
: Utility functions including loggermethod
: Code for IL/RL (BC, SAC, and PPO)
furniture/env
folder contains the python code for environment scripting. We use many files and functions from the Robosuite environment. The main files and folders are:
This is the base environment. It contains functionality for interfacing with the MuJoCo simulation and Unity Renderer. Some functions of interest are:
step(action)
: Environmental step function used for RL training.render(mode)
: Gets RGB images, segmentation map, depth maps, from the simulation._is_aligned(a,b)
: Checks if two connectors are aligned. You can adjust threshold to decide connection of two parts_connect(a,b)
: Connects the given two connectors using a weld constraint.
The next files all extend furniture/env/furniture.py
with agent-specific logic.
furniture/env/furniture_cursor.py
furniture/env/furniture_sawyer.py
furniture/env/furniture_baxter.py
furniture/env/furniture_panda.py
furniture/env/furniture_jaco.py
These agents override observation_space
, dof
, get_obs
, and _step
.
Code for robots, MuJoCo XML objects, and initialization code can be found in the respective folders.
The furniture XMLs can be found in furniture/env/models/assets/objects
.
More documentation on the XML schema can be found in the XML documentation.
This folder is a Unity3d project. You can open it using the Unity Editor to change lighting, backgrounds, and textures. The code is implemented on top of DoorGym-Unity.
This folder contains BC, SAC, PPO implementation.