Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamics randomization for MuJoCo #51

Merged
merged 33 commits into from
Jun 12, 2018
Merged

Commits on Jun 12, 2018

  1. First draft to specify variations in dynamics randomization

    A simple data structure consisting of a list of variation objects was
    implemented. Each variation object is an instance of the Variation class
    that works as a container for each of the fields used to randomized a
    dynamic parameter within the simulation environment.
    This list of variations is further tested in script
    test_dynamics_rand.py to verify that fields within each variation can be
    set and get.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    c9bfd53 View commit details
    Browse the repository at this point in the history
  2. Apply PEP8 format with YEPF

    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    7b49c10 View commit details
    Browse the repository at this point in the history
  3. Reimplement the fluent interface to create individual setters

    A setter for each field in the Variation class is used now instead of a
    constructor containing all fields as parameters. This allows a modular
    setting of fields for different configuration scenarios for dynamics
    randomization.
    To define the methods and distributions, two enumeration classes were
    created: VariationMethods and VariationDistributions.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    4814fe0 View commit details
    Browse the repository at this point in the history
  4. Apply PEP8 format with YEPF

    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    76de607 View commit details
    Browse the repository at this point in the history
  5. Add fisrt draft of randomize environment

    Implement basic feature of a wrappered environment, which choose new
    randomized physics params in mujoco on every reset().
    Chang committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    f26bece View commit details
    Browse the repository at this point in the history
  6. Rename RandomizeEnv.py to randomized_env.py

    All the python files have file names in lowercase. To keep this
    standard, refactor RandomizeEnv.py to randomized_env.py.
    Chang committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    7cdbac7 View commit details
    Browse the repository at this point in the history
  7. Add features and remove variables in RandomizedEnv

    Add error handling in constructor and reset().
    Remove variables that doesn't depend on self._wrapped_env.sim in
    reset().
    Reuse MODEL_DIR in mujoco_env.py
    Alphabetize imports.
    Chang committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    edd1cb2 View commit details
    Browse the repository at this point in the history
  8. Fix bugs in error handling

    Fix wrong AttributeError raising in constructor when there
    is element in xml.
    
    Add error handling towards the Variation.range attribute. When
    the range shape isn't the same as the attribute value shape,
    raise an AttributeError.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    ef8f05a View commit details
    Browse the repository at this point in the history
  9. Add thread to generate Mujoco models

    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    70a0608 View commit details
    Browse the repository at this point in the history
  10. Add thread terminate in mujoco_model_gen

    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    3db0053 View commit details
    Browse the repository at this point in the history
  11. Add interrupt handler to mujoco model gen

    Finish the thread when the simulaton is interrupted.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    a122e90 View commit details
    Browse the repository at this point in the history
  12. Add documentation to new classes and sort import headers

    Other miscellaneous changes include:
    - Rename classes VariationsMethods and VariationDistributions to
    VariationsMethod and VariationDistribution respectively.
    - The parsing of the XML string and fetch of the dynamic parameters to
    randomize is now done within the worker thread.
    - The file randomize_env.py was renamed to randomized_env.py
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    834f2c2 View commit details
    Browse the repository at this point in the history
  13. Fix bug in MujocoModelGenerator

    Before this commit, when there is an error raised when loading the xml
    object, only the worker_thread terminates. This commit fixes this bug by
    terminating all the processes.
    
    Fix some typo in the last commit.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    9724d5f View commit details
    Browse the repository at this point in the history
  14. Change multi-thread MujocoModelGen to n-length queue

    Create an 10-length queue in MujocoModelGenerator to store the
    mujoco_models.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    aa0b2b6 View commit details
    Browse the repository at this point in the history
  15. Miscellaneous changes to improve the code

    - Renamed classes VariationMethod and VariationDistribution to Method
    and
    Distribution.
    - Enforced the use of methods exclusive for uniform or normal
    distributions in the fluent interface pattern provided in class
    Variations by splitting the class into VariationsBase,
    VariationsGaussian and VariationsUniform.
    - Included the module os.path.osp in rllab.envs.mujoco modules.
    - Changed error types and improved messages for two errors in class
    MujocoModelGenerator.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    9d64272 View commit details
    Browse the repository at this point in the history
  16. Fix PEP8 formatting in file mujoco_model_gen.py

    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    ff97435 View commit details
    Browse the repository at this point in the history
  17. Add miscellaneous changes to improve the code

     - Delete unused threading.Event in MujocoModelGenerator.
     - Correct error types in MujocoModelGenerator.
     - Renamed classes RandomizedEnv to RandomizedDynamicsEnv.
     - Delete wrong try-except in RandomizedDynamicsEnv.
     - Use randomize_dynamics() in the launcher.
     - Format method chains onto multiple lines.
     - Correct wrong param name in Variation.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    e6180ce View commit details
    Browse the repository at this point in the history
  18. Add local cache of elems in MujocoModelGenerator

    Solve the problem with v.elem=e, which calls the setter method in
    Variation. Replace this with a local cache of elements.
    
    Same with v.default in MujocoModelGenerator.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    dc668e8 View commit details
    Browse the repository at this point in the history
  19. Add miscellaneous changes to improve the code

     - Remove the setter in Variation
     - Add check of parameter shape in MujocoModelGenerator
     - Fix some typo
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    f604b7f View commit details
    Browse the repository at this point in the history
  20. Fix PEP formatting with YAPF

    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    c74bee6 View commit details
    Browse the repository at this point in the history
  21. Add error handling to MujocoModelGenerator

     - Add more detailed information in handling the shape of the sampled
     value with the default value
    
     - Add timeout in the Queue.get() in MujocoModelGenerator so the main
     thread will catch error raised in worker thread
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    8b66b7f View commit details
    Browse the repository at this point in the history
  22. Rename RandomizedDynamicsEnv to RandomizedEnv

    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    66a7df8 View commit details
    Browse the repository at this point in the history
  23. Fix mujoco exception caused by cached propery action_space

    The cached property action_space found in mujoco_env.py produces an
    error in Linux for dynamics randomization. The idea behind the cached
    property is to avoid doing an expensive computation several times, so
    for regular execution, action_space is obtained from the model that is
    used for the entire training once, improving the performance.
    However, for dynamics randomization there's a new model for each
    episode, and that requires that the action_space is updated accordingly,
    but that does not happen because it's cached.
    To update action_space and not make an invasive change, the attribute is
    invalidated for each reset in the RandomizedEnv class.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    a9d586d View commit details
    Browse the repository at this point in the history
  24. Add miscellaneous changes to improve the code

     - Move the dynamics_randomization package to rllab.envs.mujoco.
    
     - Delete tosser.xml, use xml in rllab/vendor/mujoco_model for test
    
     - The old test_dynamics_rand.py only tests for the Variations API,
       so rewrite it to test for both Variations API and RandomizedEnv.
    
     - Reorder imports.
    
     - Delete import os.path as osp in rllab/envs/mujoco/__init__.py.
       Previously added by mistake.
    Chang committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    3476dc0 View commit details
    Browse the repository at this point in the history
  25. Rename mujoco_model_gen to mujoco_model_generator

    Package names should follow class names.
    Chang committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    761f065 View commit details
    Browse the repository at this point in the history
  26. Delete trpo_swimmer in dynamics_randomization

    test_dynamics_rand.py is enough for testing. Remove trpo_swimmer.py
    Chang committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    775a628 View commit details
    Browse the repository at this point in the history
  27. Initialize variations and generation of XML string in Variations

    The code to initialize the variations and to generate the randomized
    parameters was moved into the Variations class. This will keep all the
    current code related to variations in the same file to improve the API
    of dynamics randomization, and will enable a more modular code for
    further features in the module.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    59f9ca4 View commit details
    Browse the repository at this point in the history
  28. Return to single thread, add default values and fix imports

    There is a bottleneck at function load_model_from_xml from mujoco-py
    when using multi threading. In a single thread, a call to this function
    takes units of milliseconds, while in multi threading it takes tens of
    milliseconds. Maybe this is due to internal data structures that are
    required for both loading the model in the worker thread and performing
    the simulations in the main thread, causing the delay in
    load_model_from_xml and other functions that can be perceived in the
    cumulative time obtained by the profiler by running
    test_dynamics_rand.py.
    Due to this poor performance, the file mujoco_model_gen.py was removed
    since it serves no purpose now that the variations.py file contains
    methods to process the XML file, and the calls to obtain the randomized
    model are done directly in the class RandomizedEnv.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    9056d88 View commit details
    Browse the repository at this point in the history
  29. Sort modules in the package, add newline at EOF and defaults

    The changes in this commit include:
    - The modules in the __ini__.py file were sorted alphabetically.
    - The new line at the end of file was added in randomized_env.py.
    - Default values were assigned for VariationSpec, specifically for
    fields method, distribution, mean_std and var_range. Fields xpath,
    attrib, elem and default are specific to the model in the XML file
    provided by the user, so they cannot be default parameters. Further
    more, elem and default are obtained by parsing the XML file, so the user
    won't set them.
    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    041d83b View commit details
    Browse the repository at this point in the history
  30. Fix PEP8 formatting in randomized_env.py

    Angel Gonzalez authored and CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    33c12f5 View commit details
    Browse the repository at this point in the history
  31. Reorder imports in the package

    Alphabetize the imports order in the package
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    2d1c54d View commit details
    Browse the repository at this point in the history
  32. Change comments in the package

    The dynamic randomization is set to single thread, so the comments
    contains 'MujocoModelGenerator' need to be changed or deleted.
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    1422eba View commit details
    Browse the repository at this point in the history
  33. Refactor package name and test file location

    Rename the dynamics_randmization to randomization since it's not
    actually specific to dynamics.
    
    Move tesrt_dynamic_rand.oy to tests/
    CatherineSue committed Jun 12, 2018
    Configuration menu
    Copy the full SHA
    360bef5 View commit details
    Browse the repository at this point in the history