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

Refactor gzserver launch args, add --initial_sim_time #1456

Merged
merged 3 commits into from
Mar 3, 2023

Conversation

scpeters
Copy link
Member

@scpeters scpeters commented Mar 2, 2023

This refactors some of the argument handling in gzserver.launch.py and adds support for the --initial_sim_time parameter, which was recently added in gazebosim/gazebo-classic#3294. It is straightforward to review the changes by commit:

  • 00c0c1e: Move the functionality of the _arg_command helper with a condition to a separate _conditional_command helper function and update the params_file support to use _conditional_command.
  • efa494f: Remove the condition argument from _arg_command and add a join_with argument instead that defaults to a space ' '. Also, since all the remaining uses of _arg_command also pass the corresponding LaunchConfiguration() right afterward, change the return value of _arg_command to a list joining the --command string with the LaunchConfiguration() value. This simplifies the specification of the cmd variable in the launch description.
  • c6f90bc: Add support for the --initial_sim_time argument, using join_with='=' so that it will be passed as --initial_sim_time=[time]. This is a valid alternative to --initial_sim_time [time] but allows old versions of gazebo to parse it all as a single argument and ignore it as unrecognized. Otherwise the --initial_sim_time may be ignored, but the [time] argument may linger and cause unintended parsing issues.

Add a helper function to replace the functionality
of _arg_command with the condition argument.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters requested review from wjwwood and audrow March 2, 2023 23:21
def _arg_command(arg, join_with=" "):
cmd = ['"--', arg, '" if "" != "', LaunchConfiguration(arg), '" else ""']
py_cmd = PythonExpression(cmd)
return (py_cmd, join_with, LaunchConfiguration(arg))
Copy link
Member

Choose a reason for hiding this comment

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

It might be harmless but in the case that the launch configuration is an empty string you'll still be adding the join with. I think anyway.

Copy link
Member

Choose a reason for hiding this comment

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

And actually if the join with is = that would be a problem no?

Copy link
Member Author

Choose a reason for hiding this comment

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

I knew I was forgetting something 🤦

Copy link
Member Author

Choose a reason for hiding this comment

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

I amended eb1d266 to efa494f, and I think this fixes the handling of join_with when the argument is empty

scpeters added 2 commits March 3, 2023 11:02
This refactors the _arg_command helper function to
remove the condition parameter (which is now unused
since the _conditional_command helper was added) and
always passes the LaunchConfiguration along with the
--command with a "join_with" separator. This simplifies
the `cmd` array definition.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Expose gzserver CLI parameter added in
gazebosim/gazebo-classic#3294.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
@scpeters scpeters force-pushed the scpeters/refactor_gzserver_launch_args branch from 75df23b to c6f90bc Compare March 3, 2023 19:03
Copy link

@audrow audrow left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@scpeters scpeters merged commit 21e28c1 into ros2 Mar 3, 2023
@scpeters scpeters deleted the scpeters/refactor_gzserver_launch_args branch March 3, 2023 21:57
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.

3 participants