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

Adjust the scaling automatically in TopDownRenderer #776

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

pengzhenghao
Copy link
Member

What changes do you make in this PR?

  • Please describe why you create this PR

Now the map can be displayed as:
image

Better workaround is expected.

Checklist

  • I have merged the latest main branch into current branch.
  • I have run bash scripts/format.sh before merging.
  • Please use "squash and merge" mode.

@pengzhenghao pengzhenghao added the Merge after all tests pass Merge this PR when all tests pass! label Nov 19, 2024
@pengzhenghao pengzhenghao enabled auto-merge (squash) November 19, 2024 17:39
@pengzhenghao pengzhenghao merged commit 0624f72 into main Nov 19, 2024
14 checks passed
@pengzhenghao pengzhenghao deleted the nuscene-render branch November 19, 2024 18:22
@pengzhenghao
Copy link
Member Author

To future user who tries to visualize the NuScene scenario:

You can enlarge the background canvas film_size (because nuscene's map is super huge) so the resolution will be acceptable:

env.render(mode="top_down", target_agent_heading_up=True, text=dict(text="text"), film_size=(20000, 20000))

image

Full script:

import cv2
from metadrive.envs.scenario_env import ScenarioEnv
from metadrive.policy.replay_policy import ReplayEgoCarPolicy

if __name__ == "__main__":
    data_directory = "/home/zhenghao/Downloads/scene"
    num_scenarios = 2
    try:
        env = ScenarioEnv(
            {
                "sequential_seed": True,
                "use_render": False,
                "data_directory": data_directory,
                "num_scenarios": num_scenarios,
                "agent_policy": ReplayEgoCarPolicy
            }
        )
        for seed in range(num_scenarios):
            env.reset(seed)
            run = True
            while run:
                o, r, tm, tc, info = env.step([0, 0])
                # o = env.render()
                o = env.render(mode="top_down", target_agent_heading_up=True, text=dict(text="text"), film_size=(20000, 20000))
                print(type(o))
                cv2.imshow("top_down", o[:, :, ::-1])
                cv2.waitKey(1)
                if tm or tc:
                    run = False
    finally:
        env.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge after all tests pass Merge this PR when all tests pass!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant