-
Notifications
You must be signed in to change notification settings - Fork 156
Conversation
Hi @dtch1997! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
I refactored the pybullet-relevant code into a separate |
I need some help with understanding the config dictionary setup in Currently I get the following error in my tests:
There appears to be a missing key Appreciate help with getting this to work correctly. |
This resolves the error where the diagnostics were reporting a missing seed argument.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
I resolved the missing seed error (albeit rather hackily.) |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Commit 6512c94 adds a proposal for a general interface to gym backends. Instead of having if-else statements in every function, we can have a single if-else statement that constructs a handler which implements polymorphic behaviour. @luisenp Does this look good? If so I can go ahead and implement it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposal for EnvHandler
looks good! Just let a comment about our new version of make_env
, which doesn't require legacy_make_env
(that's just there for backwards compatibility). Otherwise, I haven't looked at the code too deeply or ran anything, but I'll put some time for that during the week. Thanks a lot for the contribution!
Ah, this is normal. This just means that black changed some of your
formatting automatically and you have to stage some of your files again.
…On Sat, Oct 2, 2021, 10:28 AM Daniel Tan ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In mbrl/util/pybullet.py
<#135 (comment)>
:
> + self._exit_method = self._exit_pybullet_gym
+ else:
+ raise RuntimeError("Tried to freeze an unsupported environment.")
+
+ def _enter_pybullet_gym(self):
+ # For now, the accepted envs are limited to ease implementation and testing
+ from pybulletgym.envs.roboschool.robots.locomotors.walker_base import WalkerBase as RSWalkerBase
+ from pybulletgym.envs.mujoco.robots.locomotors.walker_base import WalkerBase as MJWalkerBase
+ env = self._env.env
+ robot = env.robot
+ assert isinstance(robot, (RSWalkerBase, MJWalkerBase))
+ self.state_id = env._p.saveState()
+ self.ground_ids = env.ground_ids
+ self.potential = env.potential
+ self.reward = float(env.reward)
+ robot_keys = [("body_rpy", tuple), ("body_xyz", tuple), ("feet_contact", np.copy), ("initial_z", float), ("joint_speeds", np.copy), ("joints_at_limit", int), ("walk_target_dist", float), ("walk_target_theta", float), ("walk_target_x", float), ("walk_target_y", float)]
I fixed the above by switching my development environment to python 3.7.
Now I'm struggling to understand why this happens with black:
(mbrl-lib-py37) ***@***.***:~/code/mbrl-lib$ git commit
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/dtch1997/.cache/pre-commit/patch1633184818-865.
black....................................................................Failed
- hook id: black
- files were modified by this hook
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#135 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABEKAIRMV3YA7UR2N3O52EDUE4JJZANCNFSM5FGH3DOA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Implement make_env and add docstrings for abstract class methods make_env interface has been expanded to accommodate python dicts Added a new method is_correct_env_type to simplify type checking Ported over utility functions from mujoco.py
This has not been tested (because I do not have a Mujoco license). This is a best-effort attempt to replicate the original functionality but somebody else should test this code and modify it as necessary
TODO: Figure out how to implement many of the methods described here
Flesh out the skeleton implemented in previous commit
Avoid circular import in env_handler Lazy import so we don't load unused handlers
@luisenp thanks for asking! I've been quite pressed for time this week, but I am continuing to work on this. I will keep you posted when I make progress or need help |
@luisenp I have enabled
I am investigating whether it is possible to somehow transfer state between envs using
If you are alright with a somewhat hacky solution, it might be possible to skip using Would like to hear if you have any recommendations on how to solve this. Thanks! |
Hi @dtch1997, thanks a lot for the update! I haven't taken a look but I'll try to do so today or tomorrow. I'm curious as to why it's needed to write the state to a file. Is there a reason why having a shared object in memory that can be copied for each environment wouldn't work in this case? |
@luisenp This is a limitation of the Another potential idea is to use a in-memory file object to write to such as |
Thanks for the explanation, @dtch1997, that help me understand the issue better. I've been busy with other things, but I'll try to look into this today and see if I can give you any other suggestions. |
HI @dtch1997. I ran the code on my end and it's also quite slow for me, but at least it seems to be doing something. On the other hand, it's hard to say if the controller is functioning correctly given how slow it is. I'm wondering if the easiest work around would be to stop relying on the state to be passed around, and instead pass the best action found after aggregating all trajectories, and update each local environment to move one step using that action. This assumes that the environment is deterministic and that setting the seed is all that's needed to set their initial state (both seem reasonable assumptions to me). It's less robust than passing the state directly, but it should work for the environments we have considered so far. That being said, for the purpose of this PR, I think the a slow but working solution is good enough, so my proposal is to start porting mujoco and dmcontrol to the new class structure, and once that's done and How does this sound? |
@luisenp sounds good, I will move on to integrating Mujoco / Dmcontrol. |
@luisenp can you point me to a version of On a side note: DeepMind has recently acquired Mujoco and made it freely available. Going forward it is still unclear whether |
Hi @dtch1997, my version of I saw the Mujoco announcement, which was really good news! Moving forward, we'll likely more actively support the newer versions of Mujoco, but, as long as it remains practical, we should maintain backward compatibility with mujoco_py and Mujoco 2.0. This means that people that has already ran MBRL-LIb experiments on those environments, should be able to still do so in the future. |
@luisenp Is there a
|
mmm, actually, I don't think there is, now that I think about it. Are you able to do the |
7484f09
to
2702fcc
Compare
@luisenp no worries I realized I had a typo, was able to install |
Awesome, thanks a lot for your hard work! |
Hi @luisenp, I have added support for the remaining Pybullet envs. The freezing / unfreezing of generic Pybullet envs is done by pickling the env and then restoring it from the pickled version. This is not ideal but I decided to do this because:
I have tested these changes with |
Thanks a lot @dtch1997. I'll take a look and see if I spot anything strange in the code, but, in general, if the code runs w/o issues I'd say the PR would be good to merge, and we can look into optimizations later. Sorry it's taken me long to give more feedback, or even confirm that it works. I'm really busy with another deadline, but I'll try to find some time to finalize this PR this week. Thanks! |
Hi @dtch1997. I'm really sorry that is taking me so long to review this, but my other commitments are taking all of my time. It might be hard for me to take a look at this until mid-November, but rest assured that this is a really nice contribution, and I'm looking forward to merge it in. |
@luisenp let me know if there's anything else I need to do for this PR. |
Hi @dtch1997, thanks for reaching out and apologies again for the lack of input on my part. My other commitments should clear out by next week, so you can expect some final comments to merge this in from me by Wednesday 30 or so. |
* Added pre-commit to dev requirements * Added copyright header to planet visualizer * Updated main.py to follow new env handlers, and updated README files with PyBullet information.
Hi @dtch1997, PR merged! Let me know if you are still interested in the followups we had discussed and we can discuss a bit a plan for it. Thanks again for the contribution :) |
Continuation of incomplete PR from #87
This is my first time contributing to an open-source project so any advice is welcome, technical or otherwise
Types of changes
Motivation and Context / Related issue
This adds support for PyBullet, an open-source alternative to MuJoCo. MuJoCo-compatible and RobotSchool environments are supported via pybullet-gym.
How Has This Been Tested (if it applies)
python -m pytest tests/pybullet
Checklist