Fixed maybe can not read temperature warning

This commit is contained in:
Joe Dong
2024-04-25 10:53:18 +08:00
parent 3be8dc4f22
commit e020ba6d3f
+8 -4
View File
@@ -248,10 +248,10 @@ void OBCameraNode::setupProfiles() {
for (size_t i = 0; i < profiles->count(); i++) { for (size_t i = 0; i < profiles->count(); i++) {
auto profile = profiles->getProfile(i)->as<ob::VideoStreamProfile>(); auto profile = profiles->getProfile(i)->as<ob::VideoStreamProfile>();
RCLCPP_DEBUG_STREAM( RCLCPP_DEBUG_STREAM(
logger_, "Sensor profile: " logger_,
<< "stream_type: " << magic_enum::enum_name(profile->type()) "Sensor profile: " << "stream_type: " << magic_enum::enum_name(profile->type())
<< "Format: " << profile->format() << ", Width: " << profile->width() << "Format: " << profile->format() << ", Width: " << profile->width()
<< ", Height: " << profile->height() << ", FPS: " << profile->fps()); << ", Height: " << profile->height() << ", FPS: " << profile->fps());
supported_profiles_[elem].emplace_back(profile); supported_profiles_[elem].emplace_back(profile);
} }
std::shared_ptr<ob::VideoStreamProfile> selected_profile; std::shared_ptr<ob::VideoStreamProfile> selected_profile;
@@ -636,6 +636,10 @@ void OBCameraNode::setupDiagnosticUpdater() {
if (diagnostic_period_ < 0.0) { if (diagnostic_period_ < 0.0) {
return; return;
} }
if (!device_->isPropertySupported(OB_STRUCT_DEVICE_TEMPERATURE, OB_PERMISSION_READ)) {
RCLCPP_WARN_STREAM(logger_, "Device doesn't support temperature reading.");
return;
}
diagnostic_updater_ = std::make_unique<diagnostic_updater::Updater>(node_, diagnostic_period_); diagnostic_updater_ = std::make_unique<diagnostic_updater::Updater>(node_, diagnostic_period_);
auto info = device_->getDeviceInfo(); auto info = device_->getDeviceInfo();
CHECK_NOTNULL(info); CHECK_NOTNULL(info);