add get_ldp_measure_distance

This commit is contained in:
Joe Dong
2024-07-10 19:57:17 +08:00
parent 2e7ec7b9c0
commit 49ba570897
2 changed files with 27 additions and 0 deletions
+23
View File
@@ -164,6 +164,11 @@ void OBCameraNode::setupCameraCtrlServices() {
std::shared_ptr<SetBool::Response> response) {
setIRLongExposureCallback(request, response);
});
get_ldp_measure_distance_srv_ = node_->create_service<GetInt32>(
"get_ldp_measure_distance", [this](const std::shared_ptr<GetInt32::Request> request,
std::shared_ptr<GetInt32::Response> response) {
getLdpMeasureDistanceCallback(request, response);
});
}
void OBCameraNode::setExposureCallback(const std::shared_ptr<SetInt32::Request>& request,
@@ -628,6 +633,24 @@ void OBCameraNode::getLdpStatusCallback(const std::shared_ptr<GetBool::Request>&
}
}
void OBCameraNode::getLdpMeasureDistanceCallback(const std::shared_ptr<GetInt32::Request>& request,
std::shared_ptr<GetInt32::Response>& response) {
(void)request;
try {
response->data = device_->getIntProperty(OB_PROP_LDP_MEASURE_DISTANCE_INT);
response->success = true;
} catch (const ob::Error& e) {
response->message = e.getMessage();
response->success = false;
} catch (const std::exception& e) {
response->message = e.what();
response->success = false;
} catch (...) {
response->message = "unknown error";
response->success = false;
}
}
void OBCameraNode::toggleSensorCallback(const std::shared_ptr<SetBool::Request>& request,
std::shared_ptr<SetBool::Response>& response,
const stream_index_pair& stream_index) {