We recommend using a dedicated Anaconda or Python virtual environment for managing dependencies.
To get started:
conda create -n robosuite-env python=3.10 -y
conda activate robosuite-env
pip install -r requirements.txtThis will install all necessary packages, including robosuite and reinforcement learning libraries.
NOTE: If you are not on a Mac, run all files using python instead of mjpython. Also, comment out this line os.environ.setdefault("MUJOCO_GL", "egl") in eval.py if you are on windows
To train a model, run train.py with the following flags:
--task: the robosuite task you trained your model on and want to evaluate- Choices: lift, door
- Default: lift
- Choices: lift, door
--continue_train: if you want to continue training a model from its checkpoint--reward_shaping: if you want to use dense instead of sparse rewards for training- Default: True
--no_reward_shaping: if you want to use sparse rewards--checkpoint: the path of the saved model.zipfile you want to continue training- E.g.
"SAC_lift_dense_1mil.zip"
- E.g.
--timesteps: the number of timesteps to train your model- Default: 500,000
Now run:
mjpython main.py
To test your model after training, run eval.py with the following flags:
--task: the robosuite task you trained your model on and want to evaluate- Choices: lift, door
- Default: lift
- Choices: lift, door
--checkpoint: the path of the model you want to evaluate- Required: True
- E.g.
"demos/SAC_lift_dense_1mil.zip"
- E.g.
- Required: True
--model: the type of model you're evaluating- Choices: SAC, PPO
- Default: SAC
- Choices: SAC, PPO
Now run:
mjpython eval.py
You may also run our demo models: SAC: lift, sparse, 1 million iterations
mjpython eval.py --task lift --checkpoint demos/SAC_lift_sparse_1mil.zip --model SAC
SAC: lift, dense, 1 million iterations
mjpython eval.py --task lift --checkpoint demos/SAC_lift_dense_1mil.zip --model SAC
PPO: lift, sparse, 10 million iterations
mjpython eval.py --task lift --checkpoint demos/PPO_lift_sparse_10mil.zip --model PPO
PPO: lift, dense, 10 million iterations
mjpython eval.py --task lift --checkpoint demos/PPO_lift_dense_10mil.zip --model PPO
SAC: door, dense, 1 million iterations
mjpython eval.py --task door --checkpoint demos/SAC_door_dense_1mil.zip --model SAC
PPO: door, dense, 3 million iterations
mjpython eval.py --task door --checkpoint demos/PPO_door_dense_3mil.zip --model PPO
The core PPO implementation, custom reward functions, and evaluation scripts are located in the PPO branch.
- Dense Reward Function: Defined in
env.pyunder thePPObranch. - Lift Task Training: See
main.pyfor PPO training on the Lift environment. - Door Task Training: See
door_main.pyfor PPO training on the Door environment. - Evaluation: Use
eval.pyto evaluate a trained PPO model.
To evaluate your own trained model:
-
Replace the file path in
model.load(...)insideeval.pywith the path to your.zipmodel. -
Run the script:
mjpython eval.py
Make sure you are in the correct branch (e.g. PPO) to access all relevant code for training and evaluation.