-
Notifications
You must be signed in to change notification settings - Fork 772
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
[ros2] Add check if rclcpp::init() has been called #859
[ros2] Add check if rclcpp::init() has been called #859
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching the problem and making a PR!
The new test failed on the build farm, it looks like the message is published too late:
19:54:56 12: �[0m/tmp/ws/src/gazebo_ros_pkgs/gazebo_ros/test/test_plugins.cpp:63: Failure
19:54:56 12: Expected: (msg) != (nullptr), actual: 16-byte object <00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00> vs 8-byte object <00-00 00-00 00-00 00-00>
19:54:56 12: test
19:54:57 12: [WARN] [hello_ros_world]: Publishing
rclcpp::init(argc, argv); | ||
if (!rclcpp::is_initialized()) { | ||
rclcpp::init(argc, argv); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! It may also be worth it adding a check to gazebo_ros_init
, and in both cases, printing a warning if it's been initialized, so the user knows their arguments won't be loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'll add a check to gazebo_ros_init
, too.
I think using both gazebo_ros_init
and gazebo_ros_factory
is a common use case for ROS users. In that case it might be annoying when a warning is always printed. Is that OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's go without the warning, thanks!
6d3652e
to
18be0fe
Compare
Thank you for your reviewing.
Thanks for your advice in advance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating, this looks good to me.
rclcpp::init(argc, argv); | ||
impl_->ros_node_ = gazebo_ros::Node::Get(); | ||
} else { | ||
impl_->ros_node_ = gazebo_ros::Node::Get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: this line can be moved out of the if
/else
Hi,
I would like to use both
gazebo_ros_init
andgazebo_ros_factory
plugins at the same time. But when I tried that, it failed.This PR adds check if
rclcpp::init()
has been called before calling it.