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

fix: set traci default view if it doesn't exist #191

Merged
merged 5 commits into from
Mar 20, 2024

Conversation

KevynKelso
Copy link
Contributor

This change allows you to use LIB_SUMO_AS_TRACI=1 with use_gui=True in some situations.

@LucasAlegre
Copy link
Owner

Hi @KevynKelso, thanks for this contribution!

Can you explain a bit what this does, and in which cases is it possible to use the GUI with libsumo?

@KevynKelso
Copy link
Contributor Author

Hey @LucasAlegre thanks for getting back to me!

libtraci added this DEFAULT_VIEW parameter to libtraci.gui at the bottom of their init.py I assume for convenience purposes. However, this parameter does not exist in the libsumo implementation, so when LIBSUMO_AS_TRACI=1, accessing traci.gui.DEFAULT_VIEW throws an AttributeError.

For me, this was the only change required to use both LIBSUMO_AS_TRACI=1 and use_gui=True with the following code snippet:
env = SumoEnvironment( net_file="nets/2way-single-intersection/single-intersection.net.xml", route_file="nets/2way-single-intersection/single-intersection-vhvh.rou.xml", out_csv_name=info_csv, single_agent=True, use_gui=True, num_seconds=1800, render_mode="human", )

I also tested with the petting zoo environment and that seems to work without issue as well, but I can't say it will work in every situation. It does however, seem to make sumo-rl more user friendly in the event someone is trying to use the gui and forgot to unset LIBSUMO_AS_TRACI, or is trying to get better performance with the gui or something like that.

Also I'm using sumo version 1.19.0

@KevynKelso KevynKelso force-pushed the fix_potential_undefined_view branch from a49f3da to f047bcf Compare March 20, 2024 02:46
@LucasAlegre LucasAlegre merged commit c3ce351 into LucasAlegre:main Mar 20, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants