### Install Robosuite from Pip Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Installs the robosuite library using pip. Ensure MuJoCo is set up beforehand. ```bash pip install robosuite ``` -------------------------------- ### Install Extra Dependencies from Source Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Installs optional add-on functionalities like OpenAI Gym interfaces, inverse kinematics controllers, and teleoperation support. ```bash pip3 install -r requirements-extra.txt ``` -------------------------------- ### Install and Run Pre-commit Hooks Source: https://github.com/arise-initiative/robosuite/blob/master/CONTRIBUTING.md Install pre-commit hooks for code formatting using black and isort. These hooks automatically format code before committing. Manually run all hooks to check formatting. ```sh pip install pre-commit; pre-commit install ``` ```sh pre-commit run --all-files ``` -------------------------------- ### Install Base Requirements from Source Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Installs the core dependencies for robosuite when installing from source. This also installs the library as an editable package. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Install mujoco-py from Source on Windows Source: https://github.com/arise-initiative/robosuite/wiki/Getting-Started:-Windows-10-Users Use this command to install mujoco-py from its local source directory after making necessary modifications for Windows compatibility. The --no-cache flag is recommended. ```bash pip install -e . --no_cache ``` -------------------------------- ### Install robosuite from Source on Windows Source: https://github.com/arise-initiative/robosuite/wiki/Getting-Started:-Windows-10-Users Install robosuite from its local source directory after potentially modifying requirements.txt and setup.py. This command installs the package in editable mode. ```bash pip install -e . ``` -------------------------------- ### Test Robosuite Installation (Source) Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Verifies the robosuite installation after building from source by running a demo script. For Mac users, prepend 'mj' to 'python' if using the default mjviewer renderer. ```bash python robosuite/demos/demo_random_action.py ``` -------------------------------- ### Install USD Exporter Dependencies Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Install the required Python packages for exporting trajectories to USD format. This is a prerequisite for using the USD exporter. ```sh $ pip install usd-core pillow tqdm ``` -------------------------------- ### Run Demonstration Script with MJGUI Device Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/devices.md Example of running a demonstration script using the 'mjgui' device. This command specifies the environment, robot, device, camera, and controller. ```bash mjpython robosuite/scripts/collect_human_demonstrations.py --environment Lift --robots Panda --device mjgui --camera frontview --controller WHOLE_BODY_IK ``` -------------------------------- ### Install MuJoCo Package Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Installs the MuJoCo Python package if it's not already present. This is a prerequisite for robosuite. ```bash pip install mujoco ``` -------------------------------- ### Test Robosuite Installation (Pip) Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Verifies the robosuite installation by running a demo script. For Mac users, prepend 'mj' to 'python' if using the default mjviewer renderer. ```bash python -m robosuite.demos.demo_random_action ``` -------------------------------- ### Example: Placing an Object Using Offsets Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/objects.md Demonstrates how to use offset methods to calculate and set an object's position relative to a target surface, like a table top. ```python table_top = np.array([0, 1, 0]) bottom_offset = obj.get_bottom_offset() pos = table_top - bottom_offset # pos + bottom_offset = table_top obj_xml = obj.get_obj().set("pos", array_to_string(pos)) # Set the top-level body of this object ``` -------------------------------- ### Initialize SequentialCompositeSampler for Multiple Objects Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/objects.md Use SequentialCompositeSampler to compose multiple arbitrary placement samplers. This example initializes samplers for different nut objects with distinct y-ranges. ```python # Establish named references to each nut object nut_names = ("SquareNut", "RoundNut") # Initialize the top-level sampler self.placement_initializer = SequentialCompositeSampler(name="ObjectSampler") # Create individual samplers per nut for nut_name, default_y_range in zip(nut_names, ([0.11, 0.225], [-0.225, -0.11])): self.placement_initializer.append_sampler( sampler=UniformRandomSampler( name=f"{nut_name}Sampler", x_range=[-0.115, -0.11], y_range=default_y_range, rotation=None, rotation_axis='z', ensure_object_boundary_in_range=False, ensure_valid_placement=True, reference_pos=self.table_offset, z_offset=0.02, ) ) ``` -------------------------------- ### CMakeLists.txt for Robosuite Source: https://github.com/arise-initiative/robosuite/blob/master/robosuite/models/assets/bullet_data/panda_description/CMakeLists.txt This CMakeLists.txt file configures the build process for the franka_description package. It specifies the minimum CMake version, project name, Catkin package dependencies (xacro), and installation directories for meshes and robots. ```cmake cmake_minimum_required(VERSION 2.8.3) project(franka_description) find_package(catkin REQUIRED) catkin_package(CATKIN_DEPENDS xacro) install(DIRECTORY meshes DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) install(DIRECTORY robots DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Recommended for isolating robosuite installation. Use virtualenv or Conda to create a dedicated environment. ```bash virtualenv -p python3 . && source bin/activate ``` ```bash conda create -n robosuite python=3.10 ``` -------------------------------- ### CMakeLists.txt for Robosuite Source: https://github.com/arise-initiative/robosuite/blob/master/robosuite/models/assets/bullet_data/sawyer_description/CMakeLists.txt This CMakeLists.txt file configures the build process for the Robosuite project. It finds the Catkin package and sets up installation directories for configuration files, meshes, parameters, and URDF files. ```cmake cmake_minimum_required(VERSION 2.8.3) project(sawyer_description) find_package(catkin REQUIRED) catkin_package() foreach(dir config meshes params urdf) install(DIRECTORY ${dir}/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir}) endforeach(dir) ``` -------------------------------- ### Setup Whole Body Controller Action Split Indices Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Sets up the action split indices specifically for a whole-body controller. This method is distinct from the general `setup_action_split_idx`. ```python setup_whole_body_controller_action_split_idx ``` -------------------------------- ### Example Observation Dictionary Structure Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/sensors.md This dictionary shows the typical structure of observations returned by env.step(), including image modalities and robot proprioceptive data, along with concatenated state representations. ```python { "frontview_image": np.array(...), # this has modality "image" "frontview_depth": np.array(...), # this has modality "image" "frontview_segmentation_instance": np.array(...), # this has modality "image" "robot0_joint_pos": np.array(...), # this has modality "robot0_proprio" "robot0_gripper_pos": np.array(...), # this has modality "robot0_proprio" "image-state": np.array(...), # this is a concatenation of all image observations "robot0_proprio-state": np.array(...), # this is a concatenation of all robot0_proprio observations } ``` -------------------------------- ### Clone Robosuite Repository Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md Clones the robosuite GitHub repository to install from source. Navigate into the cloned directory afterwards. ```bash git clone https://github.com/ARISE-Initiative/robosuite.git cd robosuite ``` -------------------------------- ### Setup Action Split Indices Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Configures the indices used for splitting the action vector among sub-controllers. Crucial for composite control strategies. ```python setup_action_split_idx ``` -------------------------------- ### Run Standardized Environments in Robosuite Source: https://github.com/arise-initiative/robosuite/blob/master/docs/basicusage.md Instantiate and interact with a standardized robosuite environment. Use this for benchmarking and qualitative evaluation. Ensure you have the necessary renderers installed. ```python import numpy as np import robosuite as suite # create environment instance env = suite.make( env_name="Lift", # try with other tasks like "Stack" and "Door" robots="Panda", # try with other robots like "Sawyer" and "Jaco" has_renderer=True, has_offscreen_renderer=False, use_camera_obs=False, ) # reset the environment env.reset() for i in range(1000): action = np.random.randn(*env.action_spec[0].shape) * 0.1 obs, reward, done, info = env.step(action) # take action in the environment env.render() # render on display ``` -------------------------------- ### Check MuJoCo Package Path Source: https://github.com/arise-initiative/robosuite/blob/master/docs/installation.md A Python snippet to find the installation path of the MuJoCo package. Useful for troubleshooting 'mujoco.dll not found' errors on Windows. ```python import mujoco print(mujoco.__path__) ``` -------------------------------- ### Get Controller Name Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Returns the name of the controller. Useful for identification and logging purposes. ```python name ``` -------------------------------- ### MujocoObject Placement Offset Methods Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/objects.md Provides methods to get offset information for precise object placement relative to other objects or surfaces. ```python def get_bottom_offset(self): pass ``` ```python def get_top_offset(self): pass ``` ```python def get_horizontal_radius(self): pass ``` -------------------------------- ### BASIC Controller Configuration Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/controllers.rst Example JSON configuration for a BASIC composite controller. Specifies control types and parameters for different robot body parts like arms, torso, head, base, and legs. ```json { "type": "BASIC", "body_parts": { "arms": { "right": { "type": "OSC_POSE", "input_max": 1, "input_min": -1, "output_max": [0.05, 0.05, 0.05, 0.5, 0.5, 0.5], "output_min": [-0.05, -0.05, -0.05, -0.5, -0.5, -0.5], "kp": 150, ... }, "left": { "type": "OSC_POSE", ... } }, "torso": { "type" : "JOINT_POSITION", ... }, "head": { "type" : "JOINT_POSITION", ... }, "base": { "type": "JOINT_VELOCITY", ... }, "legs": { "type": "JOINT_POSITION", ... } } } ``` -------------------------------- ### Observation Dictionary Structure Source: https://github.com/arise-initiative/robosuite/blob/master/docs/algorithms/sim2real.md This is an example of the observation dictionary structure returned by env.step() when an environment includes camera and robot proprioceptive observations. Note that 'image-state' and 'robot0_proprio-state' are concatenations of their respective modalities and are not returned by default for memory efficiency. ```python { "frontview_image": np.array(...), # this has modality "image" "frontview_depth": np.array(...), # this has modality "image" "robot0_joint_pos": np.array(...), # this has modality "robot0_proprio" "robot0_gripper_pos": np.array(...), # this has modality "robot0_proprio" "image-state": np.array(...), # this is a concatenation of all image observations "robot0_proprio-state": np.array(...), # this is a concatenation of all robot0_proprio observations } ``` -------------------------------- ### MuJoCo XML Structure for Custom Objects Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/objects.md Example of a MuJoCo MJCF XML file for defining a custom object. Must include an 'asset' section for meshes and textures, and a 'worldbody' with a top-level 'object' body. Essential sites like 'bottom_site', 'top_site', and 'horizontal_radius_site' must be defined with specified positions. ```xml ``` -------------------------------- ### Define Custom BreadObject in Python Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/objects.md Example of a Python class definition for a custom object using MujocoXMLObject. Requires a filepath to the XML and a name. Optional arguments include joints, object type, and collision geom duplication. ```python class BreadObject(MujocoXMLObject): def __init__(self, name): super().__init__(xml_path_completion("objects/bread.xml"), name=name, joints=[dict(type="free", damping="0.0005")], obj_type="all", duplicate_collision_geoms=True) ``` -------------------------------- ### Custom Sensor Filter and Sampling Rate Example Source: https://github.com/arise-initiative/robosuite/blob/master/docs/algorithms/sim2real.md This script demonstrates how to use robosuite's Observable API to model sensor realism. It customizes the 'robot0_joint_pos' observable by defining a filter function to record values using a RingBuffer and increasing its sampling rate. This allows tracking sensor values sampled at a higher frequency than the environment's control frequency. ```python import robosuite as suite import numpy as np from robosuite.utils.buffers import RingBuffer # Create env instance control_freq = 10 env = suite.make("Lift", robots="Panda", has_offscreen_renderer=False, use_camera_obs=False, control_freq=control_freq) # Define a ringbuffer to store joint position values buffer = RingBuffer(dim=env.robots[0].robot_model.dof, length=10) # Create a function that we'll use as the "filter" for the joint position Observable # This is a pass-through operation, but we record the value every time it gets called # As per the Observables API, this should take in an arbitrary numeric and return the same type / shape def filter_fcn(corrupted_value): # Record the inputted value buffer.push(corrupted_value) # Return this value (no-op performed) return corrupted_value # Now, let's enable the joint position Observable with this filter function env.modify_observable( observable_name="robot0_joint_pos", attribute="filter", modifier=filter_fcn, ) # Let's also increase the sampling rate to showcase the Observable's ability to update multiple times per env step obs_sampling_freq = control_freq * 4 env.modify_observable( observable_name="robot0_joint_pos", attribute="sampling_rate", modifier=obs_sampling_freq, ) # Take a single environment step with positive joint velocity actions action = np.ones(env.robots[0].robot_model.dof) * 1.0 env.step(action) # Now we can analyze what values were recorded np.set_printoptions(precision=2) print(f"\nPolicy Frequency: {control_freq}, Observable Sampling Frequency: {obs_sampling_freq}") print(f"Number of recorded samples after 1 policy step: {buffer._size}\n") for i in range(buffer._size): print(f"Recorded value {i}: {buffer.buf[i]}") ``` -------------------------------- ### Import Custom Controller Configuration Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/controllers.rst Demonstrates how to import a custom controller configuration from a JSON file. This allows for fine-grained control over controller parameters. ```python import robosuite as suite ``` -------------------------------- ### Render Demonstrations with Omniverse Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/renderers.md Use this script to render previously collected demonstrations using Isaac rendering. Specify dataset path, format, episode, output directory, cameras, resolution, renderer mode, and modalities like RGB and normals. ```bash python robosuite/scripts/render_dataset_with_omniverse.py --dataset /home/abhishek/Documents/research/rpl/robosuite/robosuite/models/assets/demonstrations_private/1734107564_9898326/demo.hdf5 --ds_format robosuite --episode 1 --camera agentview frontview --width 1920 --height 1080 --renderer RayTracedLighting --save_video --hide_sites --rgb --normals ``` -------------------------------- ### Pegs Arena Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modeling/arena.rst The PegsArena class is designed for tasks involving pegs, providing a suitable environment setup. ```APIDOC ## PegsArena ### Description Provides a simulation environment suitable for peg-related tasks. ### Methods - `__init__()`: Initializes the PegsArena. ``` -------------------------------- ### Instantiate and Use USDExporter Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Create a USDExporter object and update the scene with current simulation data. This prepares the scene for USD export. ```python exp = exporter.USDExporter(model=model, output_directory_name="usd_demo") exp.update_scene(data) ``` -------------------------------- ### Get Control Limits Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Retrieves the operational limits for the controller's output (e.g., joint velocities, torques). ```python control_limits ``` -------------------------------- ### Get Controller Base Pose Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Retrieves the base pose of the controller, typically relevant for mobile or base-controlled robots. ```python get_controller_base_pose ``` -------------------------------- ### Get Control Dimension Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Retrieves the dimension of the control output for the controller. Useful for understanding the action space size. ```python get_control_dim ``` -------------------------------- ### Initialize TableArena Source: https://github.com/arise-initiative/robosuite/blob/master/docs/tutorials/add_environment.md Create a table arena, which includes a table and a floor plane. Set its origin before merging it into the world. ```python from robosuite.models.arenas import TableArena mujoco_arena = TableArena() mujoco_arena.set_origin([0.8, 0, 0]) world.merge(mujoco_arena) ``` -------------------------------- ### Integrate with OpenAI Gym-style APIs Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Shows how to adapt robosuite environments to be compatible with OpenAI Gym-style APIs using the GymWrapper. This is useful for integrating with learning pipelines that require these APIs, such as OpenAI Baselines. ```python import gym env = gym.make('CartPole-v0') for i_episode in range(20): observation = env.reset() for t in range(100): env.render() print(observation) action = env.action_space.sample() observation, reward, done, info = env.step(action) if done: print("Episode finished after {} timesteps".format(t+1)) break ``` -------------------------------- ### Update Initial Joints Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Sets or updates the initial joint positions for the controller. Important for starting control from a known state. ```python update_initial_joints ``` -------------------------------- ### Get Actuator Limits Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Retrieves the limits for the robot's actuators (e.g., torque, velocity). Essential for safe and effective control. ```python actuator_limits ``` -------------------------------- ### Create Environment with Custom Controller Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/controllers.rst Instantiate a Robosuite environment using `suite.make`, specifying the desired task, robot, and the loaded custom controller configuration. ```python # Create environment env = suite.make("Lift", robots="Panda", controller_configs=config, ... ) ``` -------------------------------- ### Get Torque Compensation Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Retrieves the torque compensation parameters for the controller. Used for advanced control strategies that account for robot dynamics. ```python torque_compensation ``` -------------------------------- ### Collect Human Demonstrations Script Source: https://github.com/arise-initiative/robosuite/blob/master/docs/algorithms/demonstrations.md Use this script to collect human demonstrations for various environments using different input devices. Specify the output directory, environment name, input device, renderer, and camera views. ```python python scripts/collect_human_demonstrations.py --directory path/to/folder --environment table_push --device keyboard --renderer cv2 --camera front ``` -------------------------------- ### Get Action Limits Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Retrieves the valid range of action values for the controller. Helps in ensuring actions stay within physical limits. ```python action_limits ``` -------------------------------- ### Perform One Agent Rollout Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/environments.md This snippet demonstrates a basic policy loop for interacting with an environment. It assumes an environment has already been created and performs a single agent rollout, collecting observations, taking actions, and accumulating rewards until the episode is done. A trained policy could be used instead of a random action. ```python import numpy as np def get_policy_action(obs): # a trained policy could be used here, but we choose a random action low, high = env.action_spec return np.random.uniform(low, high) # reset the environment to prepare for a rollout obs = env.reset() done = False ret = 0. while not done: action = get_policy_action(obs) # use observation to decide on an action obs, reward, done, _ = env.step(action) # play action ret += reward print("rollout completed with return {}".format(ret)) ``` -------------------------------- ### Teleoperate Robot with SpaceMouse Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Control the robot's end-effector using a SpaceMouse 3D mouse. Requires driver installation and is currently supported on macOS. ```bash $ python demo_device_control.py --environment TwoArmLift --robots Tiago ``` -------------------------------- ### Initialize Whole Body Controller Action Split Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Specific method for initializing the action split indices tailored for whole-body control configurations. ```python _init_joint_action_policy ``` -------------------------------- ### Create TwoArmLift Environment for Pixel Observations Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/environments.md Instantiates the TwoArmLift environment for policy learning using pixel-based observations. Requires off-screen rendering and specifies camera parameters. ```python import robosuite from robosuite.controllers import load_composite_controller_config # BASIC controller: arms controlled using OSC, mobile base (if present) using JOINT_VELOCITY, other parts controlled using JOINT_POSITION controller_config = load_composite_controller_config(controller="BASIC") # create an environment for policy learning from pixels env = robosuite.make( "TwoArmLift", robots=["Sawyer", "Panda"], # load a Sawyer robot and a Panda robot gripper_types="default", # use default grippers per robot arm controller_configs=controller_config, # arms controlled via OSC, other parts via JOINT_POSITION/JOINT_VELOCITY env_configuration="opposed", # (two-arm envs only) arms face each other has_renderer=False, # no on-screen rendering has_offscreen_renderer=True, # off-screen rendering needed for image obs control_freq=20, # 20 hz control for applied actions horizon=200, # each episode terminates after 200 steps use_object_obs=False, # don't provide object observations to agent use_camera_obs=True, # provide image observations to agent camera_names="agentview", # use "agentview" camera for observations camera_heights=84, # image height camera_widths=84, # image width reward_shaping=True, # use a dense reward signal for learning ) ``` -------------------------------- ### Initialize Controllers Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Method to initialize the sub-controllers within a composite controller. Essential for setting up the controller hierarchy. ```python _init_controllers ``` -------------------------------- ### Simple Grip Controller (gripper) Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst API for the Simple Grip Controller for grippers. ```APIDOC ## Simple Grip Controller (gripper) ### Description A simple controller for gripper actions. ### Methods - `set_goal` - `run_controller` - `reset_goal` ### Properties - `control_limits` - `name` ``` -------------------------------- ### Create and Add Robot to World Source: https://github.com/arise-initiative/robosuite/blob/master/docs/tutorials/add_environment.md Instantiate a robot model and add it to the world. Grippers can be attached to the robot before adding it. ```python from robosuite.models.robots import Panda mujoco_robot = Panda() ``` ```python from robosuite.models.grippers import gripper_factory gripper = gripper_factory('PandaGripper') mujoco_robot.add_gripper(gripper) ``` ```python mujoco_robot.set_base_xpos([0, 0, 0]) world.merge(mujoco_robot) ``` -------------------------------- ### Playback Human Demonstrations Script Source: https://github.com/arise-initiative/robosuite/blob/master/docs/algorithms/demonstrations.md This script replays demonstrations stored in an HDF5 file. It randomly selects episodes from the file for playback. Ensure you are on the same machine where demonstrations were collected for deterministic playback. ```python python scripts/playback_demonstrations_from_hdf5.py --demonstration_path path/to/demo.hdf5 ``` -------------------------------- ### Arena Base Class Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modeling/arena.rst The base Arena class provides fundamental simulation environment setup, including a ground plane and visual walls. Child classes extend this to incorporate additional objects. ```APIDOC ## Arena ### Description Serves as a base model for building the simulation environment. Includes a ground plane and visual walls by default. ### Methods - `__init__()`: Initializes the Arena. - `set_origin()`: Sets the origin of the arena. - `set_camera()`: Configures the camera for the arena. ``` -------------------------------- ### Generate MuJoCo Model and Run Simulation Source: https://github.com/arise-initiative/robosuite/blob/master/docs/tutorials/add_environment.md Obtain a MuJoCo model from the world and then create an MjData instance to run the simulation step by step. ```python model = world.get_model(mode="mujoco") ``` ```python import mujoco data = mujoco.MjData(model) while data.time < 1: mujoco.mj_step(model, data) ``` -------------------------------- ### Run Robosuite Demo with Default Renderer Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Execute the demo script to test the default MuJoCo renderer. The `--renderer` flag can be set to 'default' or 'mujoco'. ```sh $ python demo_renderers.py --renderer default ``` -------------------------------- ### Create TwoArmLift Environment for Low-Dimensional Observations Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/environments.md Instantiates the TwoArmLift environment for policy learning using low-dimensional observations. Off-screen rendering is disabled. ```python import robosuite from robosuite.controllers import load_composite_controller_config # BASIC controller: arms controlled using OSC, mobile base (if present) using JOINT_VELOCITY, other parts controlled using JOINT_POSITION controller_config = load_composite_controller_config(controller="BASIC") # create an environment for policy learning from low-dimensional observations env = robosuite.make( "TwoArmLift", robots=["Sawyer", "Panda"], # load a Sawyer robot and a Panda robot gripper_types="default", # use default grippers per robot arm controller_configs=controller_config, # arms controlled via OSC, other parts via JOINT_POSITION/JOINT_VELOCITY env_configuration="opposed", # (two-arm envs only) arms face each other has_renderer=False, # no on-screen rendering has_offscreen_renderer=False, # no off-screen rendering control_freq=20, # 20 hz control for applied actions horizon=200, # each episode terminates after 200 steps use_object_obs=True, # provide object observations to agent use_camera_obs=False, # don't provide image observations to agent reward_shaping=True, # use a dense reward signal for learning ) ``` -------------------------------- ### Create TwoArmLift Environment for Visualization Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/environments.md Instantiates the TwoArmLift environment with on-screen rendering enabled. Use this for debugging or observing task execution. ```python import robosuite from robosuite.controllers import load_composite_controller_config # BASIC controller: arms controlled using OSC, mobile base (if present) using JOINT_VELOCITY, other parts controlled using JOINT_POSITION controller_config = load_composite_controller_config(controller="BASIC") # create an environment to visualize on-screen env = robosuite.make( "TwoArmLift", robots=["Sawyer", "Panda"], # load a Sawyer robot and a Panda robot gripper_types="default", # use default grippers per robot arm controller_configs=controller_config, # arms controlled via OSC, other parts via JOINT_POSITION/JOINT_VELOCITY env_configuration="opposed", # (two-arm envs only) arms face each other has_renderer=True, # on-screen rendering render_camera="frontview", # visualize the "frontview" camera has_offscreen_renderer=False, # no off-screen rendering control_freq=20, # 20 hz control for applied actions horizon=200, # each episode terminates after 200 steps use_object_obs=False, # no observations needed use_camera_obs=False, # no observations needed ) ``` -------------------------------- ### Print Whole Body Action Info Dictionary Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Prints detailed information about the action splitting for whole-body controllers in a dictionary format. Useful for debugging action space mapping. ```python print_action_info_dict ``` -------------------------------- ### Collect and Playback Robot Trajectory Data Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Demonstrates recording robot roll-out trajectory data using DataCollectionWrapper and playing it back. The wrapper stores environment states to temporary files for later simulation resets. ```bash $ python demo_collect_and_playback_data.py --environment Door ``` -------------------------------- ### Load Default Controller Configuration Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/controllers.rst Loads a default controller configuration using `load_composite_controller_config`. This is useful for quickly setting up a standard controller for an environment. ```python import robosuite as suite from robosuite import load_composite_controller_config # Load the desired controller config with default Basic controller config = load_composite_controller_config(controller="BASIC") # Create environment env = suite.make("Lift", robots="Panda", controller_configs=config, ... ) ``` -------------------------------- ### Configure Third-Party Controller Source: https://github.com/arise-initiative/robosuite/blob/master/docs/tutorials/add_controller.md Define controller-specific configurations in a JSON file. Ensure the 'type' field matches the registered controller's name. ```json { "type": "WHOLE_BODY_MINK_IK", # set the correct type "composite_controller_specific_configs": { ... }, ... } ``` -------------------------------- ### Initialize UniformRandomSampler for Object Placement Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/objects.md Use UniformRandomSampler to place objects uniformly at random within a specified range and with a given rotation. Ensure object boundaries are within range and placements are valid. ```python self.placement_initializer = UniformRandomSampler( name="ObjectSampler", mujoco_objects=self.cube, x_range=[-0.03, 0.03], y_range=[-0.03, 0.03], rotation_axis='z', rotation=None, ensure_object_boundary_in_range=False, ensure_valid_placement=True, reference_pos=self.table_offset, z_offset=0.01, ) ``` -------------------------------- ### Keyboard Device API Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/device.rst Allows control of the simulation using keyboard inputs. ```APIDOC ## Keyboard Device ### Description Enables real-time control of the simulation via keyboard presses and releases. ### Methods - **get_controller_state** - Description: Retrieves the current state of the keyboard controller. - **on_press** - Description: Callback function executed when a key is pressed. - **on_release** - Description: Callback function executed when a key is released. - **_display_controls** - Description: Internal method to display available keyboard controls. ``` -------------------------------- ### Test Controller Actions Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md This sequence illustrates the testing pattern for controllers. It shows sequential movements and pauses for each action dimension. ```text ***START OF DEMO*** ( dx, 0, 0, 0, 0, 0, grip) <-- Translation in x-direction for 'steps_per_action' steps ( 0, 0, 0, 0, 0, 0, grip) <-- No movement (pause) for 'steps_per_rest' steps ( 0, dy, 0, 0, 0, 0, grip) <-- Translation in y-direction for 'steps_per_action' steps ( 0, 0, 0, 0, 0, 0, grip) <-- No movement (pause) for 'steps_per_rest' steps ( 0, 0, dz, 0, 0, 0, grip) <-- Translation in z-direction for 'steps_per_action' steps ( 0, 0, 0, 0, 0, 0, grip) <-- No movement (pause) for 'steps_per_rest' steps ( 0, 0, 0, dr, 0, 0, grip) <-- Rotation in roll (x) axis for 'steps_per_action' steps ( 0, 0, 0, 0, 0, 0, grip) <-- No movement (pause) for 'steps_per_rest' steps ( 0, 0, 0, 0, dp, 0, grip) <-- Rotation in pitch (y) axis for 'steps_per_action' steps ( 0, 0, 0, 0, 0, 0, grip) <-- No movement (pause) for 'steps_per_rest' steps ( 0, 0, 0, 0, 0, dy, grip) <-- Rotation in yaw (z) axis for 'steps_per_action' steps ( 0, 0, 0, 0, 0, 0, grip) <-- No movement (pause) for 'steps_per_rest' steps ***END OF DEMO*** ``` -------------------------------- ### Table Arena Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modeling/arena.rst The TableArena class sets up a simulation environment with a table. ```APIDOC ## TableArena ### Description Sets up a simulation environment with a table. ### Methods - `__init__()`: Initializes the TableArena. - `configure_location()`: Configures the location of the table. ### Properties - `table_top_abs`: Absolute position of the table top. ``` -------------------------------- ### MjGUI Device API Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/device.rst Provides an interface for simulation control through the MuJoCo GUI. ```APIDOC ## MjGUI Device ### Description Allows interaction with the simulation through the MuJoCo Graphical User Interface (GUI), mapping GUI inputs to simulation actions. ### Methods - **get_controller_state** - Description: Retrieves the current state of the MjGUI controller. - **input2action** - Description: Translates GUI input events into simulation actions. - **_display_controls** - Description: Internal method to display available MjGUI controls. ``` -------------------------------- ### Gripper Controller (base class) Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Base class API for Gripper Controllers. ```APIDOC ## Gripper Controller (base class) ### Description Base class providing common functionalities for gripper controllers. ### Methods - `run_controller` - `scale_action` - `update` - `update_base_pose` - `update_initial_joints` - `clip_torques` - `reset_goal` - `nums2array` ### Properties - `torque_compensation` - `actuator_limits` - `control_limits` - `name` ``` -------------------------------- ### Record Robot Roll-out Video Source: https://github.com/arise-initiative/robosuite/blob/master/docs/demos.md Record videos of robot actions using offscreen rendering with the `imageio` library. The output video is in mp4 format. ```sh $ python demo_video_recording.py --environment Lift --robots Panda ``` -------------------------------- ### Make Environment with MJViewer Renderer Source: https://github.com/arise-initiative/robosuite/blob/master/docs/modules/devices.md Configure the Robosuite environment to use the 'mjviewer' renderer for teleoperation. Ensure 'has_renderer' is true and 'has_offscreen_renderer' is false. ```python env = suite.make( **options, renderer="mjviewer", has_renderer=True, has_offscreen_renderer=False, ignore_done=True, use_camera_obs=False, ) ``` -------------------------------- ### Run All Tests Source: https://github.com/arise-initiative/robosuite/blob/master/CONTRIBUTING.md Execute all available tests in the robosuite project to verify code correctness before submitting contributions. Ensure no errors are thrown. ```sh python -m pytest ``` -------------------------------- ### Base Device API Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/device.rst Provides the fundamental methods for all devices, enabling control and state retrieval. ```APIDOC ## Base Device ### Description Represents the base class for all devices, offering core functionalities for simulation interaction. ### Methods - **start_control** - Description: Initializes and starts the device's control loop. - **get_controller_state** - Description: Retrieves the current state of the device controller. ``` -------------------------------- ### Initialize MujocoWorldBase Source: https://github.com/arise-initiative/robosuite/blob/master/docs/tutorials/add_environment.md Create a base world object for your environment. This class houses all MuJoCo object definitions. ```python from robosuite.models import MujocoWorldBase world = MujocoWorldBase() ``` -------------------------------- ### Run Controller Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Executes the control loop for the controller, generating actions based on the current state and goal. This is the core execution method. ```python run_controller ``` -------------------------------- ### Print Robot Action Info Source: https://github.com/arise-initiative/robosuite/blob/master/docs/simulation/controller.rst Use this function to understand how actions are split among sub-controllers in composite controllers. It helps in visualizing the action space distribution. ```python robosuite.robots.robot.print_action_info() ```