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

Add a way to pass extra parameters to ros_gz_bridge #628

Merged
merged 14 commits into from
Nov 20, 2024

Conversation

Amronos
Copy link
Contributor

@Amronos Amronos commented Oct 30, 2024

🎉 New feature

Closes #624

Summary

Added a new argument bridge_params to allow users to pass extra parameters to ros_gz_bridge when using the launch file. An example of these parameters would be qos_overrides
I have changed the node declarations to an opaque function so that I can get the value of bridge_params.
bridge_params is converted from string to dictionary and then passed to the parameters of the ros_gz_bridge node.
The way I have done all of this is complicated and so please do tell me if there is an easier way to do this.

Test it

To test this something like the following command can be used:
ros2 launch ros_gz_bridge ros_gz_bridge.launch.py bridge_name:=ros_gz_bridge config_file:=<path_to_your_YAML_file> bridge_params:="'qos_overrides./topic_name.publisher.durability': 'transient_local', 'qos_overrides./another_topic_name.publisher.durability': 'transient_local'"

Then to check if the qos overrides have applied:
ros2 topic info /topic_name --verbose
ros2 topic info /another_topic_name --verbose

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@Amronos Amronos requested a review from ahcorde as a code owner October 30, 2024 07:34
Copy link
Contributor

@caguero caguero left a comment

Choose a reason for hiding this comment

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

@Amronos Amronos requested a review from caguero October 30, 2024 09:30
@azeey
Copy link
Contributor

azeey commented Nov 1, 2024

I haven't had time to dig into this, but it feels like a big code change for a fairly small feature. Is it the conversion from string to dictionary that requires the use of the opaque function? Another approach I would consider is moving more of the logic into the gz_server Action or even reverting the current architecture where the Action includes a launch file

ros_gz_bridge_description = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[PathJoinSubstitution([FindPackageShare('ros_gz_bridge'),
'launch',
'ros_gz_bridge.launch.py'])]),

and instead have the ros_gz_bridge.launch.py file use the Action. It seems like we have more flexibility there.

@Amronos
Copy link
Contributor Author

Amronos commented Nov 1, 2024

Is it the conversion from string to dictionary that requires the use of the opaque function?

Yes.

or even reverting the current architecture where the Action includes a launch file and instead have the ros_gz_bridge.launch.py file use the Action. It seems like we have more flexibility there.

That does sound like a good idea.

@Amronos
Copy link
Contributor Author

Amronos commented Nov 14, 2024

Any updates on this PR?

Copy link
Contributor

@caguero caguero left a comment

Choose a reason for hiding this comment

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

Could you merge from ros2. In particular, I want to make sure that this patch is consider in your refactor:

https://github.com/gazebosim/ros_gz/pull/620/files

Copy link
Contributor

@caguero caguero left a comment

Choose a reason for hiding this comment

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

Does this test work for you? (remember to update the path to the bridge config file).

ros2 launch ros_gz_sim ros_gz_sim.launch bridge_name:=ros_gz_bridge config_file:=/home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/full.yaml world_sdf_file:=empty.sdf use_composition:=True create_own_container:=True

@Amronos
Copy link
Contributor Author

Amronos commented Nov 14, 2024

Does this test work for you? (remember to update the path to the bridge config file).

ros2 launch ros_gz_sim ros_gz_sim.launch bridge_name:=ros_gz_bridge config_file:=/home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/full.yaml world_sdf_file:=empty.sdf use_composition:=True create_own_container:=True

I haven't specifically run this command, but I have used the ros_gz_sim.launch.py launch file inside another python launch file with composition enabled.

@caguero
Copy link
Contributor

caguero commented Nov 14, 2024

Does this test work for you? (remember to update the path to the bridge config file).

ros2 launch ros_gz_sim ros_gz_sim.launch bridge_name:=ros_gz_bridge config_file:=/home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/full.yaml world_sdf_file:=empty.sdf use_composition:=True create_own_container:=True

I haven't specifically run this command, but I have used the ros_gz_sim.launch.py launch file inside another python launch file with composition enabled.

I'm getting an error that I don't get with the ros2 branch:

[INFO] [launch]: All log files can be found below /home/caguero/.ros/log/2024-11-14-17-40-26-288785-cold-1915140
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): 'str' object has no attribute 'perform'

Amronos and others added 10 commits November 15, 2024 10:58
Allows one to pass extra arguments to ros_gz_bridge

Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Aarav Gupta <[email protected]>
…action using the launch file

Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Wiktor Bajor <[email protected]>
Signed-off-by: Aarav Gupta <[email protected]>
@Amronos
Copy link
Contributor Author

Amronos commented Nov 15, 2024

The XML launch file should work now.
Should I add the bridge_params argument to the other launch files?

@Amronos Amronos requested a review from caguero November 15, 2024 05:35
@caguero
Copy link
Contributor

caguero commented Nov 15, 2024

The XML launch file should work now. Should I add the bridge_params argument to the other launch files?

That'd be great!

@Amronos
Copy link
Contributor Author

Amronos commented Nov 15, 2024

Should be ready to merge now!

Copy link
Contributor

@caguero caguero left a comment

Choose a reason for hiding this comment

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

I think there's still something not working for me. If I run:

ros2 launch ros_gz_sim ros_gz_sim.launch.py bridge_name:=ros_gz_bridge config_file:=/home/caguero/ros_gz_ws/src/ros_gz/ros_gz_bridge/test/config/full.yaml world_sdf_file:=empty.sdf use_composition:=True create_own_container:=True

And then:

caguero@cold:~/ros_gz_ws$ ros2 node list
WARNING: Be aware that there are nodes in the graph that share an exact name, which can have unintended side effects.
/gz_server
/gzserver
/gzserver
/gzserver
/launch_ros_2128322
/ros_gz_bridge
/ros_gz_bridge
/ros_gz_container

It shows multiple instances of the bridge and gzserver. This issue was fixed in #620 but it's resurfacing here.

@Amronos Amronos requested a review from caguero November 16, 2024 04:41
@caguero
Copy link
Contributor

caguero commented Nov 18, 2024

@Amronos , out of curiosity, were you able to solve the latest issue (duplicated nodes)?

@Amronos
Copy link
Contributor Author

Amronos commented Nov 19, 2024

@Amronos , out of curiosity, were you able to solve the latest issue (duplicated nodes)?

Yes, it was fixed in commit f2d6cda. The PR should be ready to merge.

Copy link
Contributor

@caguero caguero left a comment

Choose a reason for hiding this comment

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

All looks good to me now, thanks!

@caguero caguero merged commit 558a1cf into gazebosim:ros2 Nov 20, 2024
4 checks passed
@caguero caguero mentioned this pull request Nov 20, 2024
8 tasks
@Amronos Amronos deleted the bridge-params branch November 21, 2024 02:06
@Amronos
Copy link
Contributor Author

Amronos commented Nov 21, 2024

@caguero Can this also be backported to Jazzy? If yes, #629 should be backported first.

@ahcorde
Copy link
Collaborator

ahcorde commented Nov 21, 2024

https://github.com/Mergifyio backport jazzy

Copy link
Contributor

mergify bot commented Nov 21, 2024

backport jazzy

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 21, 2024
* Add bridge_params argument to ros_gz_bridge
Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Wiktor Bajor <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Wiktor Bajor <[email protected]>
(cherry picked from commit 558a1cf)
ahcorde pushed a commit that referenced this pull request Nov 21, 2024
* Add bridge_params argument to ros_gz_bridge
Signed-off-by: Aarav Gupta <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Wiktor Bajor <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Wiktor Bajor <[email protected]>
(cherry picked from commit 558a1cf)

Co-authored-by: Aarav Gupta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Passing parameters to ros_gz_bridge from launch files
5 participants