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

Consider warning users if there is already a Gazebo server running in the background #2806

Open
arjo129 opened this issue Mar 4, 2025 · 9 comments · May be fixed by #2828
Open

Consider warning users if there is already a Gazebo server running in the background #2806

arjo129 opened this issue Mar 4, 2025 · 9 comments · May be fixed by #2828
Labels
enhancement New feature or request good first issue Good for newcomers help wanted We accept pull requests! OOBE 📦✨ Out-of-box experience

Comments

@arjo129
Copy link
Contributor

arjo129 commented Mar 4, 2025

Desired behavior

When users close the Gazebo GUI, the server can sometimes continue running in the background. This, combined with the ability to launch multiple Gazebo simulations, leads to confusion when a new gz sim client instance is started. To improve usability, the Gazebo quick start screen should detect existing running servers and present them to the user before launching a new one. Additionally, enhancing the gz sim -g command to accept a world name argument would allow users to target specific running simulations.

Alternatives considered

Implementation suggestion

Additional context

See #2805

@arjo129 arjo129 added the enhancement New feature or request label Mar 4, 2025
@arjo129 arjo129 added good first issue Good for newcomers help wanted We accept pull requests! OOBE 📦✨ Out-of-box experience labels Mar 4, 2025
@GauravKumar9920
Copy link
Contributor

Hi @arjo129, I have a potential code ready to fix this. But first, I would need to test if It works. How do I test it ?
I am using Mac and running ubuntu 24.04 through docker, which has gz installation script right in its image.

@arjo129
Copy link
Contributor Author

arjo129 commented Mar 13, 2025

I recommend spinning up a second instance of gazebo sim in the background as a server only process.

gz sim -s some_world.sdf

Then spin up gz sim on a new terminal

gz sim

@GauravKumar9920
Copy link
Contributor

Hi @arjo129 , I'm using ubuntu 24.04(on a different machine(not docker)), and previously I had gz harmonic installed.
for this issue I installed gazebo ionic(gz-sim9 branch) from source and tried removing gz harmonic.
but when I run gz sim --version it shows -
Gazebo Sim, version 8.9.0

Is this the correct version, If I am not wrong it's the harmonic version right ?

@arjo129
Copy link
Contributor Author

arjo129 commented Mar 13, 2025

I recommend following the source install instructions here.

Make sure to source the correct directory and don't have a gazebo classic installation. You can use docker on ubuntu as well, personally I use distrobox to create isolated docker containers so that my host system is not tainted. However its up to you to choose what you'd like to use.

@GauravKumar9920
Copy link
Contributor

I am running into a issue where -
I have the run gz sim -s shapes.sdf and gz sim -s default.sdf in seprate termianls. when I go ahead and run gz sim -g shapes.sdf why does the sometimes worldName printed is shapes and sometimes default ?

I’ve figured out why this is happening. Both servers are running at the same time, and the client (gz sim -g) chooses the server that responds first. currently I have added a functionality to accept -g "file name" as an argument and only launch the give file name(previously it didn't use to consider 'file name' as an argument.) though while doing so, it is sometimes able to launch the passed gui and sometimes it doesn't because There’s no way to tell the client which server to connect to when there are multiple instances active, so it sometimes connects to the “shapes” world and sometimes to the “default” one.

any ideas on how do I fix that ?

@iche033
Copy link
Contributor

iche033 commented Mar 17, 2025

currently I have added a functionality to accept -g "file name"

I think there is an edge case that if the user launches multiple gz sim servers with the same world name, e.g. shapes.sdf, they would still run into the same issue though

@GauravKumar9920 GauravKumar9920 linked a pull request Mar 18, 2025 that will close this issue
@GauravKumar9920
Copy link
Contributor

GauravKumar9920 commented Mar 18, 2025

currently I have added a functionality to accept -g "file name"

I think there is an edge case that if the user launches multiple gz sim servers with the same world name, e.g. shapes.sdf, they would still run into the same issue though

Indeed, I had observed that. I believe that determining how to receive the appropriate server name feedback from the service call would be crucial in resolving this issue. I am currently looking into this matter.

At present, the code will only launch the gui of the file passed in as filename, provided that the server names are different. (Although it fails to launch at times because when the world name is requested by the line - https://github.com/GauravKumar9920/gz-sim/blob/f60df980d50534cf366f29b7372d6debad4b4a56/src/gui/Gui.cc#L475C13-L475C74 it sometimes returns the correct list of files and sometimes does not.)

p.s - Please note that I have created a pull request to demonstrate the modifications I have made thus far. However, it is not currently in a stage where it can be merged.

@arjo129
Copy link
Contributor Author

arjo129 commented Mar 19, 2025

The diff you've submitted is really big for a relatively small change. Couple of things I'd suggest are to breakdown this problem into smaller chunks.

  1. To deal with the case which @iche033 mentions, I recommend a really simple fix. First when a server starts a world, I recommend using gz-transport to check if there are other worlds running. If there are print a gzwarn/gzerr saying "Another world of the same name is running".
  2. On the client side, I don't recommend using file names but world names. It is possible to create worlds without files. TBF, I'd hold the work of on this till Standalone gz sim executable #2809 is complete. Or build on Standalone gz sim executable #2809.
  3. On the startup screen again use gz-transport to query for the existence of worlds. If they exist consider injecting a banner that says: "Warning: we detected an already running world on start".

@GauravKumar9920
Copy link
Contributor

Additionally, enhancing the gz sim -g command to accept a world name argument would allow users to target specific running simulations.

Thank you @arjo129 for clarifying, I was previously trying to fix the issues relating to gz-sim '-s' and '-g' commands, I will help with #2809 once done with this : )

Since the scope of this pr is just to warn the user of multiple running servers I will make the changes accordingly..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted We accept pull requests! OOBE 📦✨ Out-of-box experience
Projects
Status: Inbox
Development

Successfully merging a pull request may close this issue.

3 participants