Skip to content

Conversation

j-rivero
Copy link
Contributor

@j-rivero j-rivero commented Apr 10, 2025

🎉 New feature

Comes from #2809. Related to gazebosim/gz-tools#7 and #2737.

Summary

This PR introduces a standalone executable for gz sim by following a similar approach to #2724. The new executable is integrated into cmdsim.rb.in, replacing the existing functionality. It is also a step in the direction of decoupling the server from GUI components, allowing us to build gz-sim library without GUI support.

#2809 should give a full context of the work. This PR changes the target branch name to main not to include the work in Ionic but in the upcoming Jetty.

To port #2809 here I made the following commits:

  • 39573e7 is the result of applying the diff from Standalone gz sim executable #2809 almost cleanly
  • 39296e8 adapt the changes to use the unversioned gz-sim Remove major version from package name #2726
  • 31bd100 renamed the executable gz-sim-gui since this new executable in this branch conflicts with the gui component at src/gui in this repository. In the gz-sim9 branch it is known as gz-sim9-gui but now that we are not using version numbers generates a conflict. I choosed gz-sim-gui-client but we can use a better name.

Include here the list of things broken or for testing:

  • Manual testing in Mac [blocker]
  • gz-sim continue not working on Mac [non-merge-blocker]
  • Initial world selection screen in Windows do not work properly [non-merge-blocker] Fixed in Fix for GUI wait screen bug in standalone executable #2905
  • gz-sim-gui-client displays the world initial selection screen [non-merge-blocker]
  • gz-sim-gui-client input parameters referenced SDF files [non-merge-blocker]
  • Parameters are duplicated between gz-sim-gui-client / gz-sim-main [non-merge-blocker]
  • [updated] Version arguments -v 4 to gz-sim-gui-client says it is not expected Fixed in Fix for GUI wait screen bug in standalone executable #2905

Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
…he gui unversioned component

Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
@j-rivero
Copy link
Contributor Author

@osrf-jenkins run tests

Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
@j-rivero
Copy link
Contributor Author

@osrf-jenkins run tests

Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
@j-rivero
Copy link
Contributor Author

The gz command tests are failing. Need to fix these before merging.
There is a failure in the Mac version also in the command test:

135: [ 50%] Linking CXX executable command_TEST
135: dyld[34618]: Symbol not found: __ZN2gz3sim3v1010components7Factory8InstanceEv
135:   Referenced from: <04E4F5FD-583F-3D32-8098-6E46F747E67F> /private/var/folders/ng/v8gtqrqs1sj3dzz5pvh558mh0000gp/T/gz/temp_dirdaDezq/command_TEST
135:   Expected in:     <no uuid> unknown
135: CMake Error at /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:132 (message):
135:   Error running test executable.
135: 
135:     Path: '/private/var/folders/ng/v8gtqrqs1sj3dzz5pvh558mh0000gp/T/gz/temp_dirdaDezq/command_TEST'
135:     Working directory: '/private/var/folders/ng/v8gtqrqs1sj3dzz5pvh558mh0000gp/T/gz/temp_dirdaDezq'
135:     Result: Subprocess aborted
135:     Output:
135:       
135: 
135: Call Stack (most recent call first):
135:   /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:275 (gtest_discover_tests_impl)
135: 
135: 
135: make[3]: *** [command_TEST] Error 1
135: make[3]: *** Deleting file `command_TEST'

@scpeters
Copy link
Member

I'm testing this on a Mac laptop. I first built it in a colcon workspace containing only gz-tools2 and this branch of gz-sim, with all the other dependencies built from brew formulae.

  • I'm able to run in server-only mode with install/libexec/gz/sim10/gz-sim-main -v 4 -s
  • I'm getting dyld[37202]: Library not loaded: @rpath/libgz-sim-gui.10.dylib errors when trying to open the gui in a separate terminal with -g. I'm currently debugging by building this branch through the brew formula (by replacing main on this line of gz-sim10.rb with the name of this pull request's branch). I will keep you updated on my progress

@iche033
Copy link
Contributor

iche033 commented Apr 25, 2025

The gz command tests are failing. Need to fix these before merging. There is a failure in the Mac version also in the command test:

135: [ 50%] Linking CXX executable command_TEST
135: dyld[34618]: Symbol not found: __ZN2gz3sim3v1010components7Factory8InstanceEv
135:   Referenced from: <04E4F5FD-583F-3D32-8098-6E46F747E67F> /private/var/folders/ng/v8gtqrqs1sj3dzz5pvh558mh0000gp/T/gz/temp_dirdaDezq/command_TEST
135:   Expected in:     <no uuid> unknown
135: CMake Error at /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:132 (message):
135:   Error running test executable.
135: 
135:     Path: '/private/var/folders/ng/v8gtqrqs1sj3dzz5pvh558mh0000gp/T/gz/temp_dirdaDezq/command_TEST'
135:     Working directory: '/private/var/folders/ng/v8gtqrqs1sj3dzz5pvh558mh0000gp/T/gz/temp_dirdaDezq'
135:     Result: Subprocess aborted
135:     Output:
135:       
135: 
135: Call Stack (most recent call first):
135:   /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake:275 (gtest_discover_tests_impl)
135: 
135: 
135: make[3]: *** [command_TEST] Error 1
135: make[3]: *** Deleting file `command_TEST'

I noticed this homebrew test failure recently and it's also happening in other builds as well, e.g. in #2870. May or may not be related

@iche033
Copy link
Contributor

iche033 commented Apr 25, 2025

  • I'm getting dyld[37202]: Library not loaded: @rpath/libgz-sim-gui.10.dylib errors when trying to open the gui in a separate terminal with -g. I'm currently debugging by building this branch through the brew formula (by replacing main on this line of gz-sim10.rb with the name of this pull request's branch). I will keep you updated on my progress

I get the same error with all gz packages built from source in a colcon workspace.

  • I tried setting DYLD_LIBRARY_PATH and using popen instead of std::system to launch the gui process but the result is the same. Looks like it doesn't launch the exe with the same environment.
  • Note I built the packages with -DCMAKE_MACOSX_RPATH=FALSE
    • here's my otool output:
      otool -L ./install/libexec/gz/sim10/gz-sim-main | grep gz-sim`
      ./install/libexec/gz/sim10/gz-sim-main:
         libgz-sim-gui.10.dylib (compatibility version 10.0.0, current version 10.0.0)
         libgz-sim.10.dylib (compatibility version 10.0.0, current version 10.0.0)
      

Other notes:

  • Running gz-sim-gui-client with an existing server works but it brings up the quick start dialog (the dialog for selecting what world to launch)
  • I couldn't pass the -v 4 arg to gz-sim-gui-client. It says arg was not expected.

@scpeters
Copy link
Member

I'm testing this on a Mac laptop. I first built it in a colcon workspace containing only gz-tools2 and this branch of gz-sim, with all the other dependencies built from brew formulae.

  • I'm able to run in server-only mode with install/libexec/gz/sim10/gz-sim-main -v 4 -s
  • I'm getting dyld[37202]: Library not loaded: @rpath/libgz-sim-gui.10.dylib errors when trying to open the gui in a separate terminal with -g. I'm currently debugging by building this branch through the brew formula (by replacing main on this line of gz-sim10.rb with the name of this pull request's branch). I will keep you updated on my progress

I am able to run gz-sim-main -s and gz-sim-main -g in separate terminals after compiling with brew and adding an additional rpath configuration in osrf/homebrew-simulation#3025 (and changing the target branch from main to this branch). Out of curiosity, I tried launching gz-sim-main without -s or -g to see if it could launch both server and gui at the same time, but it didn't work in my limited testing. This didn't work before either, but I was just curious to see if it was fixed

@j-rivero
Copy link
Contributor Author

Thanks for the test !

  • Running gz-sim-gui-client with an existing server works but it brings up the quick start dialog (the dialog for selecting what world to launch)

I think we already captured this problem in the description.

* I couldn't pass the `-v 4` arg to `gz-sim-gui-client`. It says arg was not expected.

Oh this is new, to be fixed IMHO without being a blocker for the PR.

I tried launching gz-sim-main without -s or -g to see if it could launch both server and gui at the same time, but it didn't work in my limited testing. This didn't work before either, but I was just curious to see if it was fixed

Iit works on Linux and Windows as far as I can tell. Seems like we will need more work on Mac. Not a blocker since we are not introducing a regression.

@traversaro traversaro mentioned this pull request Apr 26, 2025
18 tasks
@j-rivero j-rivero force-pushed the jetty/standalone_execs branch from a7560d0 to 52d66cc Compare May 6, 2025 18:00
j-rivero added 3 commits May 6, 2025 20:19
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@openrobotics.com>
@j-rivero j-rivero mentioned this pull request May 7, 2025
9 tasks
j-rivero added 2 commits May 7, 2025 22:18
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

I'm partially done reviewing this; here are a few comments for now

src/cmd/gz.cc Outdated
// console output with zero verbosity.
if (verbosity == 0)
// Check if passed string is valid
if(!_file.empty())
Copy link
Member

Choose a reason for hiding this comment

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

should there be an else branch that returns -1 if _file is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the whole thing did not work since the logic behind this and your next comment was to run checksdf and parsesdf functions even if the input file was empty and return ok if that case. I changed the logic not to pass the files in f8d454e. There are some problems in that code (gz-main-gui should not accept sdf inputs) but I prefer not to change this PR more and create new ones. The problem is registered in the PR description.

src/cmd/gz.cc Outdated
{
static std::string worldInstallDir = gz::sim::getWorldInstallDir();
return worldInstallDir.c_str();
if(!_parsedSdfFile.empty())
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this check. It looks like an empty std::string is passed to this function at src/cmd/sim_main.cc:450-451 and src/cmd/sim_main.cc:507-508, but this function is a no-op for empty strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Seems like a mistake, removed in 9dd80aa

Copy link
Contributor Author

Choose a reason for hiding this comment

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

affected by #2849 (comment)

j-rivero and others added 6 commits May 13, 2025 17:24
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Co-authored-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Jose Luis Rivero <jrivero@osrfoundation.org>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
@j-rivero j-rivero requested a review from scpeters May 14, 2025 15:32
j-rivero added 2 commits May 14, 2025 17:59
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
@j-rivero
Copy link
Contributor Author

There are a couple of Wrench related tests that fail on Linux that seems unrelated. I think that we should be in a good position to merge and address the fixes and improvements detailed in the description in new PRs.

@scpeters
Copy link
Member

There are a couple of Wrench related tests that fail on Linux that seems unrelated. I think that we should be in a good position to merge and address the fixes and improvements detailed in the description in new PRs.

the tests passed on a retry

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

two minor nits that can be addressed in separate pull requests

" - vulkan (beta)\n"
" - metal (Apple only. Default for Apple)\n"
"Note: If Vulkan is being in the GUI and gz-gui was\n"
"built against Qt < 5.15.2, it may be very slow")
Copy link
Member

Choose a reason for hiding this comment

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

nit: we can probably remove this comment since we are now on Qt 6

this can be addressed later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks! I'll get them in a new PR or please remind that to me if I won't :)

" - vulkan (beta)\n"
" - metal (Apple only. Default for Apple)\n"
"Note: If Vulkan is being in the GUI and gz-gui was\n"
"built against Qt < 5.15.2, it may be very slow")
Copy link
Member

Choose a reason for hiding this comment

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

nit: this comment can probably be removed since we are now using Qt 6

@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development May 14, 2025
@j-rivero
Copy link
Contributor Author

The time has come. Great work @sauk2 and thanks to @iche033 and @scpeters for the feedback. Merging !

@j-rivero j-rivero merged commit 0b89dee into main May 14, 2025
9 checks passed
@j-rivero j-rivero deleted the jetty/standalone_execs branch May 14, 2025 21:53
@github-project-automation github-project-automation bot moved this from In review to Done in Core development May 14, 2025
@traversaro
Copy link
Contributor

Thanks a lot to everyone involved, this was a great result!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪵 jetty Gazebo Jetty

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants