Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 2 additions & 4 deletions include/gz/sensors/CameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ namespace gz
/// \return The distance from the 1st camera, in meters.
public: double Baseline() const;

/// \brief Check if there are any subscribers
/// \return True if there are subscribers, false otherwise
/// \todo(iche033) Make this function virtual on Garden
public: bool HasConnections() const;
// Documentation inherited.
public: virtual bool HasConnections() const override;

/// \brief Advertise camera info topic.
/// \return True if successful.
Expand Down
6 changes: 2 additions & 4 deletions include/gz/sensors/DepthCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ namespace gz
/// \return height of the image
public: virtual double NearClip() const;

/// \brief Check if there are any subscribers
/// \return True if there are subscribers, false otherwise
/// \todo(iche033) Make this function virtual on Garden
public: bool HasConnections() const;
// Documentation inherited.
public: virtual bool HasConnections() const override;

/// \brief Create a camera in a scene
/// \return True on success.
Expand Down
6 changes: 2 additions & 4 deletions include/gz/sensors/RgbdCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ namespace gz
/// \return height of the image
public: virtual unsigned int ImageHeight() const override;

/// \brief Check if there are any subscribers
/// \return True if there are subscribers, false otherwise
/// \todo(iche033) Make this function virtual on Garden
public: bool HasConnections() const;
// Documentation inherited.
public: virtual bool HasConnections() const override;

/// \brief Create an RGB camera and a depth camera.
/// \return True on success.
Expand Down
6 changes: 2 additions & 4 deletions include/gz/sensors/SegmentationCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ namespace gz
/// \return height of the image
public: virtual unsigned int ImageHeight() const override;

/// \brief Check if there are any subscribers
/// \return True if there are subscribers, false otherwise
/// \todo(iche033) Make this function virtual on Garden
public: bool HasConnections() const;
// Documentation inherited.
public: virtual bool HasConnections() const override;

/// \brief Create a camera in a scene
/// \return True on success.
Expand Down
4 changes: 4 additions & 0 deletions include/gz/sensors/Sensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ namespace gz
/// \sa IsActive
public: void SetActive(bool _active);

/// \brief Check if there are any subscribers
/// \return True if there are subscribers, false otherwise
public: virtual bool HasConnections() const;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \internal
/// \brief Data pointer for private data
Expand Down
6 changes: 2 additions & 4 deletions include/gz/sensors/ThermalCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,8 @@ namespace gz
/// \param[in] resolution Temperature linear resolution
public: virtual void SetLinearResolution(float _resolution);

/// \brief Check if there are any subscribers
/// \return True if there are subscribers, false otherwise
/// \todo(iche033) Make this function virtual on Garden
public: bool HasConnections() const;
// Documentation inherited.
public: virtual bool HasConnections() const override;

/// \brief Create a camera in a scene
/// \return True on success.
Expand Down
3 changes: 3 additions & 0 deletions include/gz/sensors/WideAngleCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ namespace gz
// Documentation inherited.
public: rendering::CameraPtr RenderingCamera() const override;

// Documentation inherited.
public: virtual bool HasConnections() const override;

/// \brief Create a camera in a scene
/// \return True on success.
private: bool CreateCamera();
Expand Down
6 changes: 6 additions & 0 deletions src/Sensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -535,3 +535,9 @@ void Sensor::SetActive(bool _active)
{
this->dataPtr->active = _active;
}

//////////////////////////////////////////////////
bool Sensor::HasConnections() const
{
return true;
}
7 changes: 7 additions & 0 deletions src/WideAngleCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,3 +560,10 @@ rendering::CameraPtr WideAngleCameraSensor::RenderingCamera() const
{
return this->dataPtr->camera;
}

//////////////////////////////////////////////////
bool WideAngleCameraSensor::HasConnections() const
{
return (this->dataPtr->pub && this->dataPtr->pub.HasConnections()) ||
this->dataPtr->imageEvent.ConnectionCount() > 0u;
}
2 changes: 2 additions & 0 deletions test/integration/wide_angle_camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void WideAngleCameraSensorTest::ImagesWithBuiltinSDF(
gz::sensors::WideAngleCameraSensor *sensor =
mgr.CreateSensor<gz::sensors::WideAngleCameraSensor>(sensorPtr);
ASSERT_NE(sensor, nullptr);
EXPECT_FALSE(sensor->HasConnections());
sensor->SetScene(scene);

ASSERT_NE(sensor->RenderingCamera(), nullptr);
Expand All @@ -162,6 +163,7 @@ void WideAngleCameraSensorTest::ImagesWithBuiltinSDF(
"/test/integration/WideAngleCamera_imagesWithBuiltinSDF/";
std::string topic = topicBase + "image";
WaitForMessageTestHelper<gz::msgs::Image> helper(topic);
EXPECT_TRUE(sensor->HasConnections());

std::string infoTopic = topicBase + "camera_info";
WaitForMessageTestHelper<gz::msgs::CameraInfo> infoHelper(infoTopic);
Expand Down