Skip to content

Commit

Permalink
Multiagent Mujoco v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Schroeder de Witt committed Apr 13, 2022
1 parent d0f35a0 commit b90252d
Show file tree
Hide file tree
Showing 26 changed files with 103 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#.idea/
.DS_Store
*.pyc
__pycache__/
29 changes: 26 additions & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
```diff
+ New Addition: Multi-Agent Mujoco now supports Scenarios with Coupled Robots (using Tendons).
+ Check out instructions below.
- PLEASE NOTE: To use the legacy version of Multiagent Mujoco please check out tag v1.0
```

```diff
+ New Version: Multi-Agent MuJoCo is now at Version 1.1.0. Changes and added features are as follows:
+ Fixed a bug in action mapping in the step function (thanks go to Paul Barde). This fixes several unphysical mappings found in previous versions.
+ Multi-Agent MuJoCo can now be installed as a PIP package.
+ I am in the process of establishing comprehensive benchmarks of all Multi-Agent MuJoCO scenarios across a variety of RL algorithms.
```

```diff
Expand All @@ -17,20 +23,20 @@ Described in the paper [Deep Multi-Agent Reinforcement Learning for Decentralize

# Installation

**Note: You require OpenAI Gym Version 0.10.8 and Mujoco 2.0**
**Note: You require OpenAI Gym Version 0.10.8 and Mujoco 2.1**

Simply clone this repository and put ./src on your PYTHONPATH.
To render, please also set the following environment variables:

```
LD_LIBRARY_PATH=${HOME}/.mujoco/mujoco200/bin;
LD_LIBRARY_PATH=${HOME}/.mujoco/mujoco210/bin;
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
```

# Example

```python
from src.multiagent_mujoco.mujoco_multi import MujocoMulti
from multiagent_mujoco.mujoco_multi import MujocoMulti
import numpy as np
import time

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class MujocoMulti(MultiAgentEnv):

def __init__(self, batch_size=None, **kwargs):
super().__init__(batch_size, **kwargs)
self.scenario = kwargs["env_args"]["scenario"] # e.g. Ant-v2
self.agent_conf = kwargs["env_args"]["agent_conf"] # e.g. '2x3'
self.scenario = kwargs["env_args"]["scenario"] # e.g. Ant-v2
self.agent_conf = kwargs["env_args"]["agent_conf"] # e.g. '2x3'

self.agent_partitions, self.mujoco_edges, self.mujoco_globals = get_parts_and_edges(self.scenario,
self.agent_partitions, self.mujoco_edges, self.mujoco_globals = get_parts_and_edges(self.scenario,
self.agent_conf)

self.n_agents = len(self.agent_partitions)
Expand Down Expand Up @@ -107,9 +107,18 @@ def __init__(self, batch_size=None, **kwargs):

def step(self, actions):

# need to remove dummy actions that arise due to unequal action vector sizes across agents
flat_actions = np.concatenate([actions[i][:self.action_space[i].low.shape[0]] for i in range(self.n_agents)])
obs_n, reward_n, done_n, info_n = self.wrapped_env.step(flat_actions)
# we need to map actions back into MuJoCo action space
env_actions = np.zeros((sum([self.action_space[i].low.shape[0] for i in range(self.n_agents)]),)) + np.nan
for a, partition in enumerate(self.agent_partitions):
for i, body_part in enumerate(partition):
if env_actions[body_part.act_ids] == env_actions[body_part.act_ids]:
raise Exception("FATAL: At least one env action is doubly defined!")
env_actions[body_part.act_ids] = actions[a][i]

if np.isnan(env_actions).any():
raise Exception("FATAL: At least one env action is undefined!")

obs_n, reward_n, done_n, info_n = self.wrapped_env.step(env_actions)
self.steps += 1

info = {}
Expand Down
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from setuptools import setup

description = """MAMuJoCo - Multi-Agent MuJoCo
Benchmark for Continuous Multi-Agent Robotic Control, based on OpenAI's Mujoco Gym environments.
Described in the paper Deep Multi-Agent Reinforcement Learning for Decentralized Continuous Cooperative Control
by Christian Schroeder de Witt, Bei Peng, Pierre-Alexandre Kamienny, Philip Torr, Wendelin Böhmer and Shimon Whiteson,
Torr Vision Group and Whiteson Research Lab, University of Oxford, 2020
Contact CSDW at [email protected]
"""

extras_deps = {
"dev": [
"pre-commit>=2.0.1",
"black>=19.10b0",
"flake8>=3.7",
"flake8-bugbear>=20.1",
],
}

setup(
name="MAMujoco",
version="1.1.0",
description="MAMuJoCo - Multi-Agent MuJoCo.",
long_description=description,
author="Christian Schroeder de Witt",
author_email="[email protected]",
license="Apache 2.0 License",
keywords="Robotics, MuJoCo, Multi-Agent Reinforcement Learning",
url="https://github.com/schroederdewitt/multiagent_mujoco",
packages=[
"multiagent_mujoco",
"multiagent_mujoco.assets",
],
extras_require=extras_deps,
install_requires=[
"numpy>=1.22.3",
"gym==0.10.8",
"mujoco-py>=2.1.2.14",
"scipy>=1.8.0",
"Jinja2>=3.0.3",
"glfw>=2.5.1",
"Cython>=0.29.28"
],
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.

0 comments on commit b90252d

Please sign in to comment.