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

gazebo_ros_api_plugin cleanup #1137

Merged
merged 4 commits into from
Aug 24, 2020

Conversation

scpeters
Copy link
Member

I noticed with @clalancette that gazebo_ros_api_plugin advertises the /clock topic and sets some variables in multiple places (loadGazeboRosApiPlugin() and advertiseServices()). This removes that duplicate code from advertiseServices() and makes sure is called before advertiseServices().

There's also an unused private function that is an overload of publishSimTime(), so I've removed it here and added doxygen for the remaining publishSimTime().

Remove an unused overload of publishSimTime and add doxygen
for the remaining publishSimTime function.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
The /clock topic is advertised in both loadGazeboRosApiPlugin
and advertiseServices. This removes the code from advertiseServices
and moves it earlier in loadGazeboRosApiPlugin.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

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

All of my comments are exactly that; comments pointing out why things are like they are. The changes look good to me. I'll approve, but someone else from the Gazebo team should probably take a look.

@@ -193,7 +193,6 @@ void GazeboRosApiPlugin::loadGazeboRosApiPlugin(std::string world_name)

gazebonode_ = gazebo::transport::NodePtr(new gazebo::transport::Node());
gazebonode_->Init(world_name);
//stat_sub_ = gazebonode_->Subscribe("~/world_stats", &GazeboRosApiPlugin::publishSimTime, this); // TODO: does not work in server plugin?
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is commented out, we also don't need the void GazeboRosApiPlugin::publishSimTime(const boost::shared_ptr<gazebo::msgs::WorldStatistics const> &msg) signature below, so it makes sense to remove both.

Comment on lines -252 to -254
// publish clock for simulated ros time
pub_clock_ = nh_->advertise<rosgraph_msgs::Clock>("/clock",10);

Copy link
Contributor

Choose a reason for hiding this comment

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

And now this code is duplicate because we already do this in the main loadGazeboRosApiPlugin

Comment on lines 206 to 208
// Manage clock for simulated ros time
pub_clock_ = nh_->advertise<rosgraph_msgs::Clock>("/clock",10);

Copy link
Contributor

Choose a reason for hiding this comment

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

By moving this above advertiseServices, we get exactly the same behavior as before, but without the code duplication.

Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

small nit

gazebo_ros/src/gazebo_ros_api_plugin.cpp Outdated Show resolved Hide resolved
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@scpeters
Copy link
Member Author

@osrf-jenkins run tests please

@scpeters
Copy link
Member Author

@ahcorde I merged your suggestion

@scpeters scpeters merged commit bd5e3e9 into ros-simulation:melodic-devel Aug 24, 2020
@scpeters scpeters deleted the api_plugin_cleanup branch August 24, 2020 21:52
scpeters added a commit to scpeters/gazebo_ros_pkgs that referenced this pull request Aug 27, 2020
Remove an unused overload of publishSimTime and add doxygen
for the remaining publishSimTime function.

* Remove duplicate code for /clock advertisement

The /clock topic is advertised in both loadGazeboRosApiPlugin
and advertiseServices. This removes the code from advertiseServices
and moves it earlier in loadGazeboRosApiPlugin.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>

Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
scpeters added a commit that referenced this pull request Sep 2, 2020
Remove an unused overload of publishSimTime and add doxygen
for the remaining publishSimTime function.

* Remove duplicate code for /clock advertisement

The /clock topic is advertised in both loadGazeboRosApiPlugin
and advertiseServices. This removes the code from advertiseServices
and moves it earlier in loadGazeboRosApiPlugin.

Signed-off-by: Steve Peters <scpeters@openrobotics.org>

Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
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.

None yet

3 participants