Enhance error handling by formatting error messages

This commit is contained in:
ob-yalian
2026-04-01 20:52:46 +08:00
parent ad55f90bcc
commit b82fc0c267
9 changed files with 108 additions and 92 deletions
+12 -2
View File
@@ -37,13 +37,23 @@ inline void LogFatal(const char* file, int line, const std::string& message) {
std::cerr << "Check failed at " << file << ":" << line << ": " << message << std::endl;
std::abort();
}
inline const char* getObErrorMessage(const ob::Error& e) {
return e.getMessage() ? e.getMessage() : "Unknown OB error";
}
inline std::string formatObErrorWithStatus(const ob::Error& e) {
std::ostringstream os;
os << getObErrorMessage(e) << " status:" << static_cast<int>(e.getStatus());
return os.str();
}
} // namespace orbbec_camera
#define TRY_EXECUTE_BLOCK(block) \
try { \
block; \
} catch (const ob::Error& e) { \
std::string error_msg = e.getMessage() ? e.getMessage() : "Unknown OB error"; \
std::string error_msg = orbbec_camera::formatObErrorWithStatus(e); \
if (error_msg.find("Device is deactivated") != std::string::npos || \
error_msg.find("disconnected") != std::string::npos || \
error_msg.find("Send control transfer failed") != std::string::npos) { \
@@ -66,7 +76,7 @@ inline void LogFatal(const char* file, int line, const std::string& message) {
} catch (const ob::Error& e) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__ \
<< ": " << e.getMessage()); \
<< ": " << orbbec_camera::formatObErrorWithStatus(e)); \
} catch (const std::exception& e) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__ \
+27 -26
View File
@@ -288,7 +288,7 @@ void OBCameraNode::setupDevices() {
TRY_EXECUTE_BLOCK(device_->loadPreset(device_preset_.c_str()));
RCLCPP_INFO_STREAM(logger_, "Device preset " << device_->getCurrentPresetName() << " loaded");
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to load device preset: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to load device preset: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to load device preset: " << e.what());
} catch (...) {
@@ -1569,7 +1569,7 @@ void OBCameraNode::setupProfiles() {
<< imu_rate_[stream_index]);
} catch (const ob::Error &e) {
RCLCPP_INFO_STREAM(logger_, "Failed to setup << " << stream_name_[stream_index]
<< " profile: " << e.getMessage());
<< " profile: " << orbbec_camera::formatObErrorWithStatus(e));
enable_stream_[stream_index] = false;
stream_profile_[stream_index] = nullptr;
}
@@ -1653,7 +1653,7 @@ void OBCameraNode::startStreams() {
onNewFrameSetCallback(frame_set);
});
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to start pipeline: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to start pipeline: " << orbbec_camera::formatObErrorWithStatus(e));
RCLCPP_INFO_STREAM(logger_, "try to disable ir stream and try again");
enable_stream_[INFRA0] = false;
setupPipelineConfig();
@@ -1760,7 +1760,7 @@ void OBCameraNode::startIMUSyncStream() {
<< fullGyroScaleRangeToString(gyro_range)
<< ",rate:" << sampleRateToString(gyro_rate));
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to start IMU sync stream: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to start IMU sync stream: " << orbbec_camera::formatObErrorWithStatus(e));
imu_sync_output_start_ = false;
} catch (...) {
RCLCPP_ERROR_STREAM(
@@ -1831,7 +1831,7 @@ void OBCameraNode::stopStreams() {
}
} catch (const ob::Error &e) {
RCLCPP_WARN_STREAM(
logger_, "Failed to disable interleave frame during shutdown: " << e.getMessage());
logger_, "Failed to disable interleave frame during shutdown: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (...) {
RCLCPP_WARN_STREAM(logger_, "Failed to disable interleave frame during shutdown");
}
@@ -1841,7 +1841,7 @@ void OBCameraNode::stopStreams() {
"Device or pipeline not available during stop - likely disconnected");
}
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline");
}
@@ -1858,7 +1858,7 @@ void OBCameraNode::stopIMU() {
try {
imuPipeline_->stop();
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop imu pipeline: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to stop imu pipeline: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop imu pipeline");
}
@@ -1872,7 +1872,7 @@ void OBCameraNode::stopIMU() {
sensors_[stream_index]->stop();
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop " << stream_name_[stream_index]
<< " stream: " << e.getMessage());
<< " stream: " << orbbec_camera::formatObErrorWithStatus(e));
}
imu_started_[stream_index] = false;
}
@@ -2356,8 +2356,8 @@ void OBCameraNode::setupTopics() {
setupPublishers();
setupDiagnosticUpdater();
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to setup topics: " << e.getMessage());
throw std::runtime_error(e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to setup topics: " << orbbec_camera::formatObErrorWithStatus(e));
throw std::runtime_error(orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to setup topics: " << e.what());
throw std::runtime_error(e.what());
@@ -2417,8 +2417,9 @@ void OBCameraNode::onTemperatureUpdate(diagnostic_updater::DiagnosticStatusWrapp
status.add("Chip Bottom Temperature", temperature.chipBottomTemp);
status.summary(diagnostic_msgs::msg::DiagnosticStatus::OK, "Temperature is normal");
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to TemperatureUpdate1: " << e.getMessage());
status.summary(diagnostic_msgs::msg::DiagnosticStatus::ERROR, e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to TemperatureUpdate1: " << orbbec_camera::formatObErrorWithStatus(e));
status.summary(diagnostic_msgs::msg::DiagnosticStatus::ERROR,
orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to TemperatureUpdate2: " << e.what());
status.summary(diagnostic_msgs::msg::DiagnosticStatus::ERROR, e.what());
@@ -2474,7 +2475,7 @@ void OBCameraNode::setupDiagnosticUpdater() {
diagnostic_cv_.notify_all();
} catch (const ob::Error &e) {
RCLCPP_WARN_STREAM(logger_, "Diagnostic update failed: "
<< e.getMessage() << " - Device may be disconnected");
<< orbbec_camera::formatObErrorWithStatus(e) << " - Device may be disconnected");
// Stop the diagnostic timer if device is having issues
try {
if (diagnostic_timer_) {
@@ -2491,7 +2492,7 @@ void OBCameraNode::setupDiagnosticUpdater() {
}
});
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to setup diagnostic updater: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to setup diagnostic updater: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to setup diagnostic updater: " << e.what());
} catch (...) {
@@ -2726,7 +2727,7 @@ void OBCameraNode::publishPointCloud(const std::shared_ptr<ob::FrameSet> &frame_
}
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, e.getMessage());
RCLCPP_ERROR_STREAM(logger_, orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, e.what());
} catch (...) {
@@ -3368,7 +3369,7 @@ void OBCameraNode::onNewFrameSetCallback(std::shared_ptr<ob::FrameSet> frame_set
}
}
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "onNewFrameSetCallback error: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "onNewFrameSetCallback error: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "onNewFrameSetCallback error: " << e.what());
} catch (...) {
@@ -3483,7 +3484,7 @@ std::shared_ptr<ob::Frame> OBCameraNode::softwareDecodeColorFrame(
try {
color_frame = filter->process(frame);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Format convert failed: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Format convert failed: " << orbbec_camera::formatObErrorWithStatus(e));
return nullptr;
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Format convert failed: " << e.what());
@@ -4140,7 +4141,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = stream_profile->getExtrinsicTo(base_stream_profile);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to get " << stream_name_[stream_index]
<< " extrinsic: " << e.getMessage());
<< " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
@@ -4185,7 +4186,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[COLOR]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
depth_to_other_extrinsics_[COLOR] = ex;
@@ -4201,7 +4202,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[INFRA0]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
depth_to_other_extrinsics_[INFRA0] = ex;
@@ -4216,7 +4217,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[INFRA1]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
depth_to_other_extrinsics_[INFRA1] = ex;
@@ -4231,7 +4232,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[INFRA2]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
ex.trans[0] = -std::abs(ex.trans[0]);
@@ -4247,7 +4248,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[ACCEL]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
depth_to_other_extrinsics_[ACCEL] = ex;
@@ -4262,7 +4263,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[GYRO]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
depth_to_other_extrinsics_[GYRO] = ex;
@@ -4277,7 +4278,7 @@ void OBCameraNode::calcAndPublishStaticTransform() {
ex = stream_profile_[COLOR_LEFT]->getExtrinsicTo(stream_profile_[COLOR_RIGHT]);
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_,
"Failed to get " << frame_id << " extrinsic: " << e.getMessage());
"Failed to get " << frame_id << " extrinsic: " << orbbec_camera::formatObErrorWithStatus(e));
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
}
depth_to_other_extrinsics_[COLOR_LEFT] = ex;
@@ -4726,7 +4727,7 @@ void OBCameraNode::setFilterCallback(const std::shared_ptr<SetFilter ::Request>
}
response->success = true;
} catch (const ob::Error &e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception &e) {
response->message = e.what();
+13 -13
View File
@@ -217,7 +217,7 @@ void OBCameraNodeDriver::init() {
ob::Context::setLoggerFileName(log_file_name);
RCLCPP_INFO_STREAM(logger_, "SDK log file name set to: " << log_file_name);
} catch (const ob::Error &e) {
RCLCPP_WARN_STREAM(logger_, "Failed to set SDK log file name: " << e.getMessage());
RCLCPP_WARN_STREAM(logger_, "Failed to set SDK log file name: " << orbbec_camera::formatObErrorWithStatus(e));
}
}
// Force IP
@@ -528,7 +528,7 @@ void OBCameraNodeDriver::resetDevice() {
device_.reset();
RCLCPP_INFO_STREAM(logger_, "device_ reset completed");
} catch (const ob::Error &e) {
RCLCPP_WARN_STREAM(logger_, "OB Exception during device reset: " << e.getMessage());
RCLCPP_WARN_STREAM(logger_, "OB Exception during device reset: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_WARN_STREAM(logger_, "Standard exception during device reset: " << e.what());
} catch (...) {
@@ -586,7 +586,7 @@ void OBCameraNodeDriver::deviceStatusTimer() {
ob_camera_node_->getColorStatus(status_msg);
ob_camera_node_->getDepthStatus(status_msg);
} catch (const ob::Error &e) {
std::string error_msg = e.getMessage() ? e.getMessage() : "Unknown OB error";
std::string error_msg = orbbec_camera::formatObErrorWithStatus(e);
if (error_msg.find("Device is deactivated") != std::string::npos ||
error_msg.find("disconnected") != std::string::npos ||
error_msg.find("Send control transfer failed") != std::string::npos) {
@@ -615,7 +615,7 @@ void OBCameraNodeDriver::deviceStatusTimer() {
status_msg.connection_type = device_info_->getConnectionType();
}
} catch (const ob::Error &e) {
std::string error_msg = e.getMessage() ? e.getMessage() : "Unknown OB error";
std::string error_msg = orbbec_camera::formatObErrorWithStatus(e);
if (error_msg.find("Device is deactivated") != std::string::npos ||
error_msg.find("disconnected") != std::string::npos ||
error_msg.find("Send control transfer failed") != std::string::npos) {
@@ -642,7 +642,7 @@ void OBCameraNodeDriver::deviceStatusTimer() {
status_msg.calibration_from_factory = calibration_from_factory;
}
} catch (const ob::Error &e) {
std::string error_msg = e.getMessage() ? e.getMessage() : "Unknown OB error";
std::string error_msg = orbbec_camera::formatObErrorWithStatus(e);
if (error_msg.find("Device is deactivated") != std::string::npos ||
error_msg.find("disconnected") != std::string::npos ||
error_msg.find("Send control transfer failed") != std::string::npos) {
@@ -681,7 +681,7 @@ void OBCameraNodeDriver::deviceStatusTimer() {
status_msg.customer_calibration_ready = false;
}
} catch (const ob::Error &e) {
std::string error_msg = e.getMessage() ? e.getMessage() : "Unknown OB error";
std::string error_msg = orbbec_camera::formatObErrorWithStatus(e);
if (error_msg.find("Device is deactivated") != std::string::npos ||
error_msg.find("disconnected") != std::string::npos ||
error_msg.find("Send control transfer failed") != std::string::npos) {
@@ -839,7 +839,7 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceBySerialNumber(
}
} catch (ob::Error &e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Failed to get device info " << e.getMessage());
"Failed to get device info " << orbbec_camera::formatObErrorWithStatus(e));
} catch (std::exception &e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Failed to get device info " << e.what());
@@ -872,7 +872,7 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByUSBPort(
return device;
} catch (ob::Error &e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Failed to get device info " << e.getMessage());
"Failed to get device info " << orbbec_camera::formatObErrorWithStatus(e));
} catch (std::exception &e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Failed to get device info " << e.what());
@@ -908,7 +908,7 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByNetIP(
}
} catch (ob::Error &e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Failed to get device info " << e.getMessage());
"Failed to get device info " << orbbec_camera::formatObErrorWithStatus(e));
continue;
} catch (std::exception &e) {
RCLCPP_ERROR_STREAM_THROTTLE(logger_, *get_clock(), 5000,
@@ -953,7 +953,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device (Attempt "
<< retry_count + 1 << " of " << max_retries
<< "): " << e.getMessage());
<< "): " << orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device (Attempt " << retry_count + 1
<< " of " << max_retries
@@ -1180,7 +1180,7 @@ bool OBCameraNodeDriver::applyForceIpConfig() {
RCLCPP_ERROR(logger_, "[ForceIP] Failed to apply config (SDK returned false)");
}
} catch (const ob::Error &e) {
RCLCPP_ERROR(logger_, "[ForceIP] ob::Error: %s", e.getMessage());
RCLCPP_ERROR(logger_, "[ForceIP] ob::Error: %s", orbbec_camera::formatObErrorWithStatus(e).c_str());
} catch (const std::exception &e) {
RCLCPP_ERROR(logger_, "[ForceIP] std::exception: %s", e.what());
} catch (...) {
@@ -1320,7 +1320,7 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
ob_camera_node_->startStreams();
}
} catch (ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << orbbec_camera::formatObErrorWithStatus(e));
start_device_failed = true;
} catch (std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << e.what());
@@ -1393,7 +1393,7 @@ void OBCameraNodeDriver::updatePresetFirmware(std::string path) {
}
}
} catch (ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to update Preset Firmware " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to update Preset Firmware " << orbbec_camera::formatObErrorWithStatus(e));
} catch (std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to update Preset Firmware " << e.what());
} catch (...) {
+9 -9
View File
@@ -95,8 +95,8 @@ void OBLidarNode::setupTopics() {
setupProfiles();
setupPublishers();
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to setup topics: " << e.getMessage());
throw std::runtime_error(e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to setup topics: " << orbbec_camera::formatObErrorWithStatus(e));
throw std::runtime_error(orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to setup topics: " << e.what());
throw std::runtime_error(e.what());
@@ -363,7 +363,7 @@ void OBLidarNode::setupProfiles() {
<< " sample rate " << imu_rate_);
} catch (const ob::Error &e) {
RCLCPP_INFO_STREAM(logger_, "Failed to setup << " << stream_name_[stream_index]
<< " profile: " << e.getMessage());
<< " profile: " << orbbec_camera::formatObErrorWithStatus(e));
enable_stream_[stream_index] = false;
stream_profile_[stream_index] = nullptr;
}
@@ -438,7 +438,7 @@ void OBLidarNode::startStreams() {
onNewFrameSetCallback(frame_set);
});
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to start pipeline: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to start pipeline: " << orbbec_camera::formatObErrorWithStatus(e));
setupPipelineConfig();
pipeline_->start(pipeline_config_, [this](const std::shared_ptr<ob::FrameSet> &frame_set) {
onNewFrameSetCallback(frame_set);
@@ -509,7 +509,7 @@ void OBLidarNode::stopStreams() {
try {
pipeline_->stop();
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline");
}
@@ -528,7 +528,7 @@ void OBLidarNode::stopIMU() {
imuPipeline_->stop();
imu_sync_output_start_ = false;
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop IMU pipeline: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "Failed to stop IMU pipeline: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop IMU pipeline");
}
@@ -654,7 +654,7 @@ void OBLidarNode::onNewFrameSetCallback(std::shared_ptr<ob::FrameSet> frame_set)
}
}
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "onNewFrameSetCallback error: " << e.getMessage());
RCLCPP_ERROR_STREAM(logger_, "onNewFrameSetCallback error: " << orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(logger_, "onNewFrameSetCallback error: " << e.what());
} catch (...) {
@@ -1249,11 +1249,11 @@ void OBLidarNode::calcAndPublishStaticTransform() {
}
} catch (const ob::Error &e) {
RCLCPP_WARN_STREAM(logger_,
"Could not get GYRO extrinsic for verification: " << e.getMessage());
"Could not get GYRO extrinsic for verification: " << orbbec_camera::formatObErrorWithStatus(e));
}
} catch (const ob::Error &e) {
RCLCPP_WARN_STREAM(logger_, "Failed to get ACCEL extrinsic, trying GYRO: " << e.getMessage());
RCLCPP_WARN_STREAM(logger_, "Failed to get ACCEL extrinsic, trying GYRO: " << orbbec_camera::formatObErrorWithStatus(e));
try {
ex = base_stream_profile->getExtrinsicTo(stream_profile_[GYRO]);
RCLCPP_INFO_STREAM(logger_, "Using GYRO extrinsic for IMU");
+34 -34
View File
@@ -434,7 +434,7 @@ void OBCameraNode::setDisparityRangeModeCallback(const std::shared_ptr<SetInt32:
response->message = "disparity_range_mode updated to " + std::to_string(current_mode_value);
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -492,7 +492,7 @@ void OBCameraNode::setDisparitySearchOffsetCallback(
response->message = "disparity_search_offset updated to " + std::to_string(current_offset);
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -517,7 +517,7 @@ void OBCameraNode::setStreamsEnableCallback(
}
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -566,7 +566,7 @@ void OBCameraNode::setExposureCallback(const std::shared_ptr<SetInt32::Request>&
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -604,7 +604,7 @@ void OBCameraNode::getGainCallback(const std::shared_ptr<GetInt32::Request>& req
response->success = true;
} catch (ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -651,7 +651,7 @@ void OBCameraNode::setGainCallback(const std::shared_ptr<SetInt32 ::Request>& re
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -763,7 +763,7 @@ void OBCameraNode::setAeRoiCallback(const std::shared_ptr<SetArrays ::Request>&
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -781,7 +781,7 @@ void OBCameraNode::getWhiteBalanceCallback(const std::shared_ptr<GetInt32::Reque
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -811,7 +811,7 @@ void OBCameraNode::setWhiteBalanceCallback(const std::shared_ptr<SetInt32 ::Requ
device_->setIntProperty(OB_PROP_COLOR_WHITE_BALANCE_INT, request->data);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->message = e.what();
response->success = false;
@@ -829,7 +829,7 @@ void OBCameraNode::getAutoWhiteBalanceCallback(const std::shared_ptr<GetInt32::R
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->message = e.what();
} catch (...) {
@@ -845,7 +845,7 @@ void OBCameraNode::setAutoWhiteBalanceCallback(const std::shared_ptr<SetBool::Re
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->message = e.what();
} catch (...) {
@@ -892,7 +892,7 @@ void OBCameraNode::setAutoExposureCallback(
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->message = e.what();
} catch (...) {
@@ -910,7 +910,7 @@ void OBCameraNode::setFanWorkModeCallback(const std::shared_ptr<SetInt32::Reques
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -932,7 +932,7 @@ void OBCameraNode::setFloorEnableCallback(
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -957,7 +957,7 @@ void OBCameraNode::setLaserEnableCallback(
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -993,7 +993,7 @@ void OBCameraNode::setLdpEnableCallback(
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -1029,7 +1029,7 @@ void OBCameraNode::getExposureCallback(const std::shared_ptr<GetInt32::Request>&
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1054,7 +1054,7 @@ void OBCameraNode::getDeviceInfoCallback(const std::shared_ptr<GetDeviceInfo::Re
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -1078,7 +1078,7 @@ void OBCameraNode::getSDKVersion(const std::shared_ptr<GetString::Request>& requ
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -1120,7 +1120,7 @@ void OBCameraNode::setMirrorCallback(const std::shared_ptr<SetBool::Request>& re
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1165,7 +1165,7 @@ void OBCameraNode::setFlipCallback(const std::shared_ptr<SetBool::Request>& requ
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1210,7 +1210,7 @@ void OBCameraNode::setRotationCallback(const std::shared_ptr<SetInt32::Request>&
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1228,7 +1228,7 @@ void OBCameraNode::getLdpStatusCallback(const std::shared_ptr<GetBool::Request>&
response->data = device_->getBoolProperty(OB_PROP_LDP_STATUS_BOOL);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1250,7 +1250,7 @@ void OBCameraNode::getLaserStatusCallback(const std::shared_ptr<GetBool::Request
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1278,7 +1278,7 @@ void OBCameraNode::setPtpConfigCallback(
response->success = true;
} catch (const ob::Error& e) {
response->success = false;
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
@@ -1295,7 +1295,7 @@ void OBCameraNode::getPtpConfigCallback(const std::shared_ptr<GetBool::Request>&
response->data = device_->getBoolProperty(OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1313,7 +1313,7 @@ void OBCameraNode::getLrmMeasureDistanceCallback(const std::shared_ptr<GetInt32:
response->data = device_->getIntProperty(OB_PROP_LDP_MEASURE_DISTANCE_INT);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1359,7 +1359,7 @@ bool OBCameraNode::toggleSensor(const stream_index_pair& stream_index, bool enab
startStreams();
return true;
} catch (const ob::Error& e) {
msg = e.getMessage();
msg = orbbec_camera::formatObErrorWithStatus(e);
return false;
} catch (const std::exception& e) {
msg = e.what();
@@ -1408,7 +1408,7 @@ void OBCameraNode::switchIRCameraCallback(const std::shared_ptr<SetString::Reque
response->success = true;
return;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1425,7 +1425,7 @@ void OBCameraNode::setIRLongExposureCallback(
device_->setBoolProperty(OB_PROP_IR_LONG_EXPOSURE_BOOL, request->data);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1445,7 +1445,7 @@ void OBCameraNode::setRESETTimestampCallback(
device_->setBoolProperty(OB_PROP_TIMER_RESET_SIGNAL_BOOL, true);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1463,7 +1463,7 @@ void OBCameraNode::setSYNCInterleaveLaserCallback(
device_->setIntProperty(OB_PROP_FRAME_INTERLEAVE_LASER_PATTERN_SYNC_DELAY_INT, request->data);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1481,7 +1481,7 @@ void OBCameraNode::setSYNCHostimeCallback(
device_->timerSyncWithHost();
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
@@ -1501,7 +1501,7 @@ void OBCameraNode::sendSoftwareTriggerCallback(
}
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->message = orbbec_camera::formatObErrorWithStatus(e);
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
+9 -5
View File
@@ -30,6 +30,7 @@
#include <vector>
#include "libobsensor/ObSensor.hpp"
#include "orbbec_camera/utils.h"
namespace {
@@ -381,7 +382,8 @@ void logCurrentPresetList(const rclcpp::Logger &logger, const std::shared_ptr<ob
RCLCPP_INFO(logger, "[%s] Preset[%u]: %s", stage, i, preset_list->getName(i));
}
} catch (const ob::Error &e) {
RCLCPP_WARN(logger, "[%s] Failed to query preset list: %s", stage, e.getMessage());
RCLCPP_WARN(logger, "[%s] Failed to query preset list: %s", stage,
orbbec_camera::formatObErrorWithStatus(e).c_str());
} catch (const std::exception &e) {
RCLCPP_WARN(logger, "[%s] Failed to query preset list: %s", stage, e.what());
}
@@ -458,7 +460,8 @@ std::shared_ptr<ob::Device> waitForReconnect(const rclcpp::Logger &logger,
return device;
}
} catch (const ob::Error &e) {
RCLCPP_WARN(logger, "Reconnect attempt failed (SDK): %s", e.getMessage());
RCLCPP_WARN(logger, "Reconnect attempt failed (SDK): %s",
orbbec_camera::formatObErrorWithStatus(e).c_str());
} catch (const std::exception &e) {
RCLCPP_WARN(logger, "Reconnect attempt failed: %s", e.what());
} catch (...) {
@@ -728,7 +731,7 @@ int main(int argc, char **argv) {
break;
} catch (const ob::Error &e) {
RCLCPP_WARN(logger, "Second update transient error: %s, retrying...",
e.getMessage());
orbbec_camera::formatObErrorWithStatus(e).c_str());
device = waitForReconnectUntil(logger, ctx, run_args, true, second_deadline);
}
}
@@ -742,7 +745,8 @@ int main(int argc, char **argv) {
} catch (const ob::Error &e) {
const std::string target =
run_args.serial_number.empty() ? "<default>" : run_args.serial_number;
RCLCPP_ERROR(logger, "Target %s failed: %s", target.c_str(), e.getMessage());
RCLCPP_ERROR(logger, "Target %s failed: %s", target.c_str(),
orbbec_camera::formatObErrorWithStatus(e).c_str());
failed_targets.push_back(target);
if (!args.continue_on_error) {
throw;
@@ -776,7 +780,7 @@ int main(int argc, char **argv) {
rclcpp::shutdown();
return 0;
} catch (const ob::Error &e) {
RCLCPP_ERROR(logger, "ob::Error: %s", e.getMessage());
RCLCPP_ERROR(logger, "ob::Error: %s", orbbec_camera::formatObErrorWithStatus(e).c_str());
} catch (const std::exception &e) {
RCLCPP_ERROR(logger, "Exception: %s", e.what());
} catch (...) {
+1 -1
View File
@@ -204,7 +204,7 @@ int main(int argc, char **argv) {
}
} catch (ob::Error &e) {
RCLCPP_ERROR(logger, "ip_config_tool: %s", e.getMessage());
RCLCPP_ERROR(logger, "ip_config_tool: %s", orbbec_camera::formatObErrorWithStatus(e).c_str());
rclcpp::shutdown();
return 1;
} catch (const std::exception &e) {
+2 -1
View File
@@ -95,7 +95,8 @@ int main() {
}
}
} catch (ob::Error& e) {
RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), e.getMessage());
RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"),
orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception& e) {
RCLCPP_ERROR_STREAM(rclcpp::get_logger("list_device_node"), e.what());
} catch (...) {
+1 -1
View File
@@ -52,7 +52,7 @@ class MultiCameraSubscriber : public rclcpp::Node {
is_gemini330_ = isGemini335PID(pid);
}
} catch (ob::Error &e) {
RCLCPP_ERROR_STREAM(get_logger(), e.getMessage());
RCLCPP_ERROR_STREAM(get_logger(), orbbec_camera::formatObErrorWithStatus(e));
} catch (const std::exception &e) {
RCLCPP_ERROR_STREAM(get_logger(), e.what());
} catch (...) {