Skip to content

Commit

Permalink
👩‍🌾 Print debug messages when sensors advertise topics (#151)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina authored Aug 26, 2021
1 parent a9ce6f9 commit b475f29
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/AirPressureSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ bool AirPressureSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Air pressure for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

// Load the noise parameters
if (_sdf.AirPressureSensor()->PressureNoise().Type() != sdf::NoiseType::NONE)
{
Expand Down
3 changes: 3 additions & 0 deletions src/AltimeterSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ bool AltimeterSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Altimeter data for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

// Load the noise parameters
if (_sdf.AltimeterSensor()->VerticalPositionNoise().Type()
!= sdf::NoiseType::NONE)
Expand Down
21 changes: 10 additions & 11 deletions src/CameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ bool CameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Camera images for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

if (!this->AdvertiseInfo())
return false;

Expand Down Expand Up @@ -500,16 +503,7 @@ bool CameraSensor::AdvertiseInfo()
}
this->dataPtr->infoTopic += "/camera_info";

this->dataPtr->infoPub =
this->dataPtr->node.Advertise<ignition::msgs::CameraInfo>(
this->dataPtr->infoTopic);
if (!this->dataPtr->infoPub)
{
ignerr << "Unable to create publisher on topic["
<< this->dataPtr->infoTopic << "].\n";
}

return this->dataPtr->infoPub;
return this->AdvertiseInfo(this->dataPtr->infoTopic);
}

//////////////////////////////////////////////////
Expand All @@ -522,9 +516,14 @@ bool CameraSensor::AdvertiseInfo(const std::string &_topic)
this->dataPtr->infoTopic);
if (!this->dataPtr->infoPub)
{
ignerr << "Unable to create publisher on topic["
ignerr << "Unable to create publisher on topic ["
<< this->dataPtr->infoTopic << "].\n";
}
else
{
igndbg << "Camera info for [" << this->Name() << "] advertised on ["
<< this->dataPtr->infoTopic << "]" << std::endl;
}

return this->dataPtr->infoPub;
}
Expand Down
6 changes: 6 additions & 0 deletions src/DepthCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ bool DepthCameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Depth images for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

if (!this->AdvertiseInfo())
return false;

Expand All @@ -298,6 +301,9 @@ bool DepthCameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Points for [" << this->Name() << "] advertised on ["
<< this->Topic() << "/points]" << std::endl;

// Initialize the point message.
// \todo(anyone) The true value in the following function call forces
// the xyz and rgb fields to be aligned to memory boundaries. This is need
Expand Down
3 changes: 3 additions & 0 deletions src/GpuLidarSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ bool GpuLidarSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Lidar points for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

this->initialized = true;

return true;
Expand Down
3 changes: 3 additions & 0 deletions src/ImuSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ bool ImuSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "IMU data for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

const std::map<SensorNoiseType, sdf::Noise> noises = {
{ACCELEROMETER_X_NOISE_M_S_S, _sdf.ImuSensor()->LinearAccelerationXNoise()},
{ACCELEROMETER_Y_NOISE_M_S_S, _sdf.ImuSensor()->LinearAccelerationYNoise()},
Expand Down
4 changes: 3 additions & 1 deletion src/Lidar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ bool Lidar::Load(const sdf::Sensor &_sdf)
<< this->Topic() << "].\n";
return false;
}
ignmsg << "Publishing laser scans on [" << this->Topic() << "]" << std::endl;

igndbg << "Laser scans for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

// Load ray atributes
this->dataPtr->sdfLidar = *_sdf.LidarSensor();
Expand Down
3 changes: 3 additions & 0 deletions src/LogicalCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ bool LogicalCameraSensor::Load(sdf::ElementPtr _sdf)
return false;
}

igndbg << "Logical images for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

this->dataPtr->initialized = true;
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/MagnetometerSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ bool MagnetometerSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Magnetometer data for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

// Load the noise parameters
if (_sdf.MagnetometerSensor()->XNoise().Type() != sdf::NoiseType::NONE)
{
Expand Down
9 changes: 9 additions & 0 deletions src/RgbdCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "RGB images for [" << this->Name() << "] advertised on ["
<< this->Topic() << "/image]" << std::endl;

// Create the depth image publisher
this->dataPtr->depthPub =
this->dataPtr->node.Advertise<ignition::msgs::Image>(
Expand All @@ -222,6 +225,9 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Depth images for [" << this->Name() << "] advertised on ["
<< this->Topic() << "/depth_image]" << std::endl;

// Create the point cloud publisher
this->dataPtr->pointPub =
this->dataPtr->node.Advertise<ignition::msgs::PointCloudPacked>(
Expand All @@ -233,6 +239,9 @@ bool RgbdCameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Points for [" << this->Name() << "] advertised on ["
<< this->Topic() << "/points]" << std::endl;

if (!this->AdvertiseInfo(this->Topic() + "/camera_info"))
return false;

Expand Down
3 changes: 3 additions & 0 deletions src/ThermalCameraSensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ bool ThermalCameraSensor::Load(const sdf::Sensor &_sdf)
return false;
}

igndbg << "Thermal images for [" << this->Name() << "] advertised on ["
<< this->Topic() << "]" << std::endl;

if (!this->AdvertiseInfo())
return false;

Expand Down

0 comments on commit b475f29

Please sign in to comment.