Skip to content

Use base RenderingSensor::HasConnections function in sensors system #1528

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

Merged
merged 1 commit into from
Jul 19, 2022
Merged
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
50 changes: 1 addition & 49 deletions src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@ class gz::sim::systems::SensorsPrivate
/// \param[in] _ecm Entity component manager
public: void UpdateBatteryState(const EntityComponentManager &_ecm);

/// \brief Check if sensor has subscribers
/// \param[in] _sensor Sensor to check
/// \return True if the sensor has subscribers, false otherwise
public: bool HasConnections(sensors::RenderingSensor *_sensor) const;

/// \brief Use to optionally set the background color.
public: std::optional<math::Color> backgroundColor;

Expand Down Expand Up @@ -342,7 +337,7 @@ void SensorsPrivate::RunOnce()
{
sensors::Sensor *s = this->sensorManager.Sensor(id);
auto rs = dynamic_cast<sensors::RenderingSensor *>(s);
if (rs->IsActive() && !this->HasConnections(rs))
if (rs->IsActive() && !rs->HasConnections())
{
rs->SetActive(false);
tmpDisabledSensors.insert(rs);
Expand Down Expand Up @@ -895,49 +890,6 @@ std::string Sensors::CreateSensor(const Entity &_entity,
return sensor->Name();
}

//////////////////////////////////////////////////
bool SensorsPrivate::HasConnections(sensors::RenderingSensor *_sensor) const
{
if (!_sensor)
return true;

// \todo(iche033) Remove this function once a virtual
// sensors::RenderingSensor::HasConnections function is available
{
auto s = dynamic_cast<sensors::RgbdCameraSensor *>(_sensor);
if (s)
return s->HasConnections();
}
{
auto s = dynamic_cast<sensors::DepthCameraSensor *>(_sensor);
if (s)
return s->HasConnections();
}
{
auto s = dynamic_cast<sensors::GpuLidarSensor *>(_sensor);
if (s)
return s->HasConnections();
}
{
auto s = dynamic_cast<sensors::SegmentationCameraSensor *>(_sensor);
if (s)
return s->HasConnections();
}
{
auto s = dynamic_cast<sensors::ThermalCameraSensor *>(_sensor);
if (s)
return s->HasConnections();
}
{
auto s = dynamic_cast<sensors::CameraSensor *>(_sensor);
if (s)
return s->HasConnections();
}
gzwarn << "Unable to check connection count for sensor: " << _sensor->Name()
<< ". Unknown sensor type." << std::endl;
return true;
}

GZ_ADD_PLUGIN(Sensors, System,
Sensors::ISystemConfigure,
Sensors::ISystemReset,
Expand Down