Skip to content
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

Make rendering sensors' HasConnections function virtual #234

Merged
merged 5 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions include/gz/sensors/AirPressureSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Data pointer for private data
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/AltimeterSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Data pointer for private data
Expand Down
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
3 changes: 1 addition & 2 deletions include/gz/sensors/ForceTorqueSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Data pointer for private data
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/GpuLidarSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

/// \brief Connect function pointer to internal GpuRays callback
/// \return gz::common::Connection pointer
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/ImuSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Data pointer for private data
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/Lidar.hh
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ namespace gz

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

/// \brief Get the visibility mask
/// \return Visibility mask
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/LogicalCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

/// \brief Get the latest image. An image is an instance of
/// msgs::LogicalCameraImage, which contains a list of detected models.
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/MagnetometerSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
/// \brief Data pointer for private data
Expand Down
3 changes: 1 addition & 2 deletions include/gz/sensors/NavSatSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ namespace gz

/// \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;
public: virtual bool HasConnections() const override;

/// \brief Easy short hand for setting the position of the sensor.
/// \param[in] _latitude Latitude angle.
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