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] Fixing the namespacing for the sonar plugin #76

Open
wants to merge 3 commits into
base: kinetic-devel
Choose a base branch
from

Conversation

RaquelTirach
Copy link

Namespacing for sonar plugin

While using the gazebo_ros_sonar plugin in a drone URDF model and spawning this type of drone several times in my.world with different robot namespaces, I encountered that type of error, since the same namespacing is used for all sonars on all drones:
[ERROR] [1598280399.141939871, 74.990000000]: Tried to advertise a service that is already advertised in this node [/sonar_front_center_015/range/set_parameters]
I offer here a solution which is highly inspired by the methods GetModelName and GetRobotNamespace from gazebo_ros_utils.h. Those two methods are used in the gazebo_ros_camera plugin and allow several robots from the same model to have their own sensors with their own topics.

@StefanFabian
Copy link
Member

Thank you for your PR! This is a good point and your help in creating a solution is greatly appreciated!
However, your proposed change would break code for existing users.
Perhaps it could be enabled using a new option as it was done in #73?

@RaquelTirach
Copy link
Author

Thank you for your quick reply!

I updated the pull request to include an option to use the default robotNamespacing. I created a new tag which, if true, enables the default namespacing.

Comment on lines 89 to 90
if (_sdf->HasElement("useNamespaceFromScopedName")){
if (_sdf->GetElement("useNamespaceFromScopedName")){
Copy link
Member

Choose a reason for hiding this comment

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

This should be an and &&. Otherwise, the option existing but set to false would not initialize the namespace at all.
Also, I'm pretty sure you also have to extract the value using GetValue()->GetAsBool().

And please follow the code style of the project, e.g., brackets {} on new lines, no spaces between function names and parameters etc.

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