Skip to content

Commit

Permalink
use new has connections function
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jun 8, 2022
1 parent 62de3a2 commit 6d86600
Showing 1 changed file with 1 addition and 49 deletions.
50 changes: 1 addition & 49 deletions src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,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 @@ -332,7 +327,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 @@ -841,49 +836,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;
}

IGNITION_ADD_PLUGIN(Sensors, System,
Sensors::ISystemConfigure,
Sensors::ISystemUpdate,
Expand Down

0 comments on commit 6d86600

Please sign in to comment.