diff --git a/include/gz/sensors/LogicalCameraSensor.hh b/include/gz/sensors/LogicalCameraSensor.hh index f7e10449..3a5a7b54 100644 --- a/include/gz/sensors/LogicalCameraSensor.hh +++ b/include/gz/sensors/LogicalCameraSensor.hh @@ -104,6 +104,14 @@ namespace gz /// \return True if there are subscribers, false otherwise public: virtual bool HasConnections() const override; + /// \brief Check if there are any image subscribers + /// \return True if there are image subscribers, false otherwise + public: virtual bool HasImageConnections() const; + + /// \brief Check if there are any frustum subscribers + /// \return True if there are info subscribers, false otherwise + public: virtual bool HasFrustumConnections() const; + /// \brief Get the latest image. An image is an instance of /// msgs::LogicalCameraImage, which contains a list of detected models. /// \return List of detected models. diff --git a/include/gz/sensors/Sensor.hh b/include/gz/sensors/Sensor.hh index f5cc7e1a..404cbca5 100644 --- a/include/gz/sensors/Sensor.hh +++ b/include/gz/sensors/Sensor.hh @@ -161,10 +161,6 @@ namespace gz /// \return Topic sensor publishes data to public: std::string Topic() const; - /// \brief Get topic where sensor data is published. - /// \return Topic sensor publishes data to - public: std::string Topic_logic() const; - /// \brief Set topic where sensor data is published. /// \param[in] _topic Topic sensor publishes data to. /// \return True if a valid topic was set. diff --git a/src/LogicalCameraSensor.cc b/src/LogicalCameraSensor.cc index 63988a09..939dd08c 100644 --- a/src/LogicalCameraSensor.cc +++ b/src/LogicalCameraSensor.cc @@ -110,7 +110,7 @@ bool LogicalCameraSensor::Load(sdf::ElementPtr _sdf) return false; if (this->Topic().empty()) - this->SetTopic("/camera/logical"); + this->SetTopic("/logical_camera"); this->dataPtr->pub = this->dataPtr->node.Advertise( @@ -236,6 +236,17 @@ msgs::LogicalCameraImage LogicalCameraSensor::Image() const ////////////////////////////////////////////////// bool LogicalCameraSensor::HasConnections() const { - return this->dataPtr->pub_logic && this->dataPtr->pub_logic.HasConnections(); + return this->HasImageConnections() || this->HasFrustumConnections(); +} + +////////////////////////////////////////////////// +bool LogicalCameraSensor::HasImageConnections() const +{ + return this->dataPtr->pub && this->dataPtr->pub.HasConnections(); } +////////////////////////////////////////////////// +bool LogicalCameraSensor::HasFrustumConnections() const +{ + return this->dataPtr->pub_logic && this->dataPtr->pub_logic.HasConnections(); +}