diff --git a/src/SystemLoader.cc b/src/SystemLoader.cc index 3a78dda509..ab18134643 100644 --- a/src/SystemLoader.cc +++ b/src/SystemLoader.cc @@ -78,7 +78,11 @@ class ignition::gazebo::SystemLoaderPrivate return false; } - auto pluginName = *pluginNames.begin(); + std::string pluginName = ""; + for (const auto &name : pluginNames) + { + pluginName = name; + } if (pluginName.empty()) { ignerr << "Failed to load system plugin [" << _filename << diff --git a/src/systems/air_pressure/AirPressure.cc b/src/systems/air_pressure/AirPressure.cc index c3e45a81ec..f3d7931b13 100644 --- a/src/systems/air_pressure/AirPressure.cc +++ b/src/systems/air_pressure/AirPressure.cc @@ -140,15 +140,17 @@ void AirPressurePrivate::CreateAirPressureEntities(EntityComponentManager &_ecm) data.SetTopic(topic); } std::unique_ptr sensor = - this->sensorFactory.CreateSensor< - sensors::AirPressureSensor>(data); - if (nullptr == sensor) + std::make_unique(); + if (!sensor->Load(data)) { - ignerr << "Failed to create sensor [" << sensorScopedName << "]" - << std::endl; - return true; + ignerr << "Sensor::Load failed for plugin [AirPressureSensor]\n"; + return false; + } + if (!sensor->Init()) + { + ignerr << "Sensor::Init failed for plugin [AirPressureSensor]\n"; + return false; } - // set sensor parent std::string parentName = _ecm.Component( _parent->Data())->Data(); diff --git a/src/systems/altimeter/Altimeter.cc b/src/systems/altimeter/Altimeter.cc index 65744608a6..740104c756 100644 --- a/src/systems/altimeter/Altimeter.cc +++ b/src/systems/altimeter/Altimeter.cc @@ -141,13 +141,16 @@ void AltimeterPrivate::CreateAltimeterEntities(EntityComponentManager &_ecm) data.SetTopic(topic); } std::unique_ptr sensor = - this->sensorFactory.CreateSensor< - sensors::AltimeterSensor>(data); - if (nullptr == sensor) + std::make_unique(); + if (!sensor->Load(data)) { - ignerr << "Failed to create sensor [" << sensorScopedName << "]" - << std::endl; - return true; + ignerr << "Sensor::Load failed for plugin [AltimeterSensor]\n"; + return false; + } + if (!sensor->Init()) + { + ignerr << "Sensor::Init failed for plugin [AltimeterSensor]\n"; + return false; } // set sensor parent diff --git a/src/systems/imu/Imu.cc b/src/systems/imu/Imu.cc index 6a645a13ec..fff0900ba4 100644 --- a/src/systems/imu/Imu.cc +++ b/src/systems/imu/Imu.cc @@ -160,13 +160,16 @@ void ImuPrivate::CreateImuEntities(EntityComponentManager &_ecm) data.SetTopic(topic); } std::unique_ptr sensor = - this->sensorFactory.CreateSensor< - sensors::ImuSensor>(data); - if (nullptr == sensor) + std::make_unique(); + if (!sensor->Load(data)) { - ignerr << "Failed to create sensor [" << sensorScopedName << "]" - << std::endl; - return true; + ignerr << "Sensor::Load failed for plugin [ImuSensor]\n"; + return false; + } + if (!sensor->Init()) + { + ignerr << "Sensor::Init failed for plugin [ImuSensor]\n"; + return false; } // set sensor parent diff --git a/src/systems/logical_camera/LogicalCamera.cc b/src/systems/logical_camera/LogicalCamera.cc index 9a16fcf40c..11ad7da8d1 100644 --- a/src/systems/logical_camera/LogicalCamera.cc +++ b/src/systems/logical_camera/LogicalCamera.cc @@ -144,13 +144,16 @@ void LogicalCameraPrivate::CreateLogicalCameraEntities( data->GetElement("topic")->Set(topic); } std::unique_ptr sensor = - this->sensorFactory.CreateSensor< - sensors::LogicalCameraSensor>(data); - if (nullptr == sensor) + std::make_unique(); + if (!sensor->Load(data)) { - ignerr << "Failed to create sensor [" << sensorScopedName << "]" - << std::endl; - return true; + ignerr << "Sensor::Load failed for plugin [LogicalCameraSensor]\n"; + return false; + } + if (!sensor->Init()) + { + ignerr << "Sensor::Init failed for plugin [LogicalCameraSensor]\n"; + return false; } // set sensor parent diff --git a/src/systems/magnetometer/Magnetometer.cc b/src/systems/magnetometer/Magnetometer.cc index 227558414b..4dfb3a329a 100644 --- a/src/systems/magnetometer/Magnetometer.cc +++ b/src/systems/magnetometer/Magnetometer.cc @@ -156,15 +156,17 @@ void MagnetometerPrivate::CreateMagnetometerEntities( data.SetTopic(topic); } std::unique_ptr sensor = - this->sensorFactory.CreateSensor< - sensors::MagnetometerSensor>(data); - if (nullptr == sensor) + std::make_unique(); + if (!sensor->Load(data)) { - ignerr << "Failed to create sensor [" << sensorScopedName << "]" - << std::endl; - return true; + ignerr << "Sensor::Load failed for plugin [MagnetometerSensor]\n"; + return false; + } + if (!sensor->Init()) + { + ignerr << "Sensor::Init failed for plugin [MagnetometerSensor]\n"; + return false; } - // set sensor parent std::string parentName = _ecm.Component( _parent->Data())->Data(); diff --git a/src/systems/sensors/CMakeLists.txt b/src/systems/sensors/CMakeLists.txt index da081b2dff..f8dd886e24 100644 --- a/src/systems/sensors/CMakeLists.txt +++ b/src/systems/sensors/CMakeLists.txt @@ -4,10 +4,8 @@ gz_add_system(sensors PUBLIC_LINK_LIBS ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER} ignition-sensors${IGN_SENSORS_VER}::ignition-sensors${IGN_SENSORS_VER} + ${PROJECT_LIBRARY_TARGET_NAME}-rendering + PRIVATE_LINK_LIBS ignition-sensors${IGN_SENSORS_VER}::camera - ignition-sensors${IGN_SENSORS_VER}::gpu_lidar - ignition-sensors${IGN_SENSORS_VER}::depth_camera ignition-sensors${IGN_SENSORS_VER}::thermal_camera - ${PROJECT_LIBRARY_TARGET_NAME}-rendering ) - diff --git a/src/systems/sensors/Sensors.cc b/src/systems/sensors/Sensors.cc index d973d94a60..16a0aaf764 100644 --- a/src/systems/sensors/Sensors.cc +++ b/src/systems/sensors/Sensors.cc @@ -498,8 +498,9 @@ std::string Sensors::CreateSensor(const Entity &_entity, return std::string(); } - // Create within ign-sensors - auto sensorId = this->dataPtr->sensorManager.CreateSensor(_sdf); + // Create using ign-sensors + ignition::sensors::SensorId sensorId = + this->dataPtr->sensorManager.CreateSensor(_sdf); auto sensor = this->dataPtr->sensorManager.Sensor(sensorId); // Add to sensorID -> entity map