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

Fixing multiagent with topdownmap #1072

Conversation

vincentpierre
Copy link
Contributor

@vincentpierre vincentpierre commented Jan 10, 2023

Motivation and Context

On top of making TopDownMap work for rearrangement tasks, I also added an agent_index to the actions allowing to control the agents from the gym interface. Running this code :

import habitat
import numpy as np

cli_arg = ['+habitat/task/measurements=top_down_map']
config = habitat.get_config('benchmark/rearrange/rearrange_easy_multi_agent.yaml', cli_arg)
from habitat.utils.gym_definitions import make_gym_from_config
env = make_gym_from_config(config)

env.reset();env.render()

while True:
   _,_,_,_ = env.step(np.array(([0.0] * 8 + [0.2, 1.0] + [0.0]) + ([0.0] * 8 + [0.2, -1.0] + [0.0]) , dtype=np.float32))
   _=env.render()

Gives the following pygame output :

multi-agent-top-down

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@vincentpierre vincentpierre requested a review from ASzot January 10, 2023 01:19
@vincentpierre vincentpierre self-assigned this Jan 10, 2023
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 10, 2023
…wn_map. (requires pygame installed and mac)

```

import habitat
import numpy as np

cli_arg = ['+habitat/task/measurements=top_down_map']
config = habitat.get_config('benchmark/rearrange/rearrange_easy_multi_agent.yaml', cli_arg)
from habitat.utils.gym_definitions import make_gym_from_config
env = make_gym_from_config(config)

env.reset();env.render()

while True:
   _,_,_,_ = env.step(np.array(([0.0] * 8 + [0.2, 1.0] + [0.0]) + ([0.0] * 8 + [0.2, -1.0] + [0.0]) , dtype=np.float32))
   _=env.render()

```
Copy link
Contributor

@ASzot ASzot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a cleaner setup, LGTM. In the future, we may want to add more flexibility to the top down map to control the colors of the agent markers to better differentiate the two agents.

@vincentpierre vincentpierre merged commit b1f2d47 into facebookresearch:main Jan 12, 2023
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
* render now will render the top_down_map properly

* made topdown map work for rearrangement

* working for rearrangement

* Adding agent_index to action configurations'

* addressing comments and removing the top_down_map from the default measures

* For reference, run this code to see the multi-agent render the top_down_map. (requires pygame installed and mac)

```

import habitat
import numpy as np

cli_arg = ['+habitat/task/measurements=top_down_map']
config = habitat.get_config('benchmark/rearrange/rearrange_easy_multi_agent.yaml', cli_arg)
from habitat.utils.gym_definitions import make_gym_from_config
env = make_gym_from_config(config)

env.reset();env.render()

while True:
   _,_,_,_ = env.step(np.array(([0.0] * 8 + [0.2, 1.0] + [0.0]) + ([0.0] * 8 + [0.2, -1.0] + [0.0]) , dtype=np.float32))
   _=env.render()

```

* unifying extract_scalar_info

* proper typing for rgb_frame

* resolving one last issue

* resolving issues with set_agent_state in rearrangement

Co-authored-by: vincentpierre <vincentpierre@users.noreply.github.com>
HHYHRHY pushed a commit to SgtVincent/EMOS that referenced this pull request Aug 31, 2024
* render now will render the top_down_map properly

* made topdown map work for rearrangement

* working for rearrangement

* Adding agent_index to action configurations'

* addressing comments and removing the top_down_map from the default measures

* For reference, run this code to see the multi-agent render the top_down_map. (requires pygame installed and mac)

```

import habitat
import numpy as np

cli_arg = ['+habitat/task/measurements=top_down_map']
config = habitat.get_config('benchmark/rearrange/rearrange_easy_multi_agent.yaml', cli_arg)
from habitat.utils.gym_definitions import make_gym_from_config
env = make_gym_from_config(config)

env.reset();env.render()

while True:
   _,_,_,_ = env.step(np.array(([0.0] * 8 + [0.2, 1.0] + [0.0]) + ([0.0] * 8 + [0.2, -1.0] + [0.0]) , dtype=np.float32))
   _=env.render()

```

* unifying extract_scalar_info

* proper typing for rgb_frame

* resolving one last issue

* resolving issues with set_agent_state in rearrangement

Co-authored-by: vincentpierre <vincentpierre@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants