Skip to content

Commit

Permalink
Updated logical camera for frustum
Browse files Browse the repository at this point in the history
  • Loading branch information
BA-Utkarsh committed Nov 25, 2024
1 parent 19f7bd1 commit a455c61
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
8 changes: 8 additions & 0 deletions include/gz/sensors/LogicalCameraSensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions include/gz/sensors/Sensor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 13 additions & 2 deletions src/LogicalCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<msgs::LogicalCameraImage>(
Expand Down Expand Up @@ -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();
}

0 comments on commit a455c61

Please sign in to comment.