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

Fixes Underwater Camera Plugin which sets the ROS2 node name statically, which doesn't allow to have multiples #23

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions gazebo/dave_gz_sensor_plugins/src/UnderwaterCamera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<rclcpp::Node>("underwater_camera_node");

auto rgbdCamera = _ecm.Component<gz::sim::components::RgbdCamera>(_entity);
if (!rgbdCamera)
{
Expand All @@ -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<rclcpp::Node>(rosNodeName);

if (this->dataPtr->topic.empty())
{
auto scoped = gz::sim::scopedName(_entity, _ecm);
Expand Down