diff --git a/gazebo/dave_gz_sensor_plugins/src/UnderwaterCamera.cc b/gazebo/dave_gz_sensor_plugins/src/UnderwaterCamera.cc index 230bcfa8..6618de5e 100644 --- a/gazebo/dave_gz_sensor_plugins/src/UnderwaterCamera.cc +++ b/gazebo/dave_gz_sensor_plugins/src/UnderwaterCamera.cc @@ -104,13 +104,6 @@ void UnderwaterCamera::Configure( gzdbg << "dave_gz_sensor_plugins::UnderwaterCamera::Configure on entity: " << _entity << std::endl; - if (!rclcpp::ok()) - { - rclcpp::init(0, nullptr); - } - - this->ros_node_ = std::make_shared("underwater_camera_node"); - auto rgbdCamera = _ecm.Component(_entity); if (!rgbdCamera) { @@ -133,6 +126,14 @@ void UnderwaterCamera::Configure( return; } + if (!rclcpp::ok()) + { + rclcpp::init(0, nullptr); + } + + std::string rosNodeName = sensorSdf.Name() + "_node"; + this->ros_node_ = std::make_shared(rosNodeName); + if (this->dataPtr->topic.empty()) { auto scoped = gz::sim::scopedName(_entity, _ecm);