mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 20:17:47 +08:00
set response status
This commit is contained in:
@@ -114,12 +114,16 @@ void OBCameraNode::setExposureCallback(const std::shared_ptr<SetInt32::Request>&
|
|||||||
RCLCPP_ERROR(logger_, "%s NOT a video stream", __FUNCTION__);
|
RCLCPP_ERROR(logger_, "%s NOT a video stream", __FUNCTION__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
response->success = true;
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
RCLCPP_ERROR(logger_, "%s unknown error %d", __FUNCTION__, __LINE__);
|
RCLCPP_ERROR(logger_, "%s unknown error %d", __FUNCTION__, __LINE__);
|
||||||
|
response->success = false;
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,11 +175,15 @@ void OBCameraNode::setGainCallback(const std::shared_ptr<SetInt32 ::Request>& re
|
|||||||
RCLCPP_ERROR(logger_, "%s NOT a video stream", __FUNCTION__);
|
RCLCPP_ERROR(logger_, "%s NOT a video stream", __FUNCTION__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
response->success = true;
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
response->success = false;
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,12 +207,15 @@ void OBCameraNode::setWhiteBalanceCallback(const std::shared_ptr<rmw_request_id_
|
|||||||
std::shared_ptr<SetInt32 ::Response>& response) {
|
std::shared_ptr<SetInt32 ::Response>& response) {
|
||||||
try {
|
try {
|
||||||
device_->setIntProperty(OB_PROP_COLOR_WHITE_BALANCE_INT, request->data);
|
device_->setIntProperty(OB_PROP_COLOR_WHITE_BALANCE_INT, request->data);
|
||||||
|
response->success = true;
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
|
response->success = false;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
|
response->success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,23 +227,30 @@ void OBCameraNode::setAutoExposureCallback(
|
|||||||
try {
|
try {
|
||||||
switch (stream) {
|
switch (stream) {
|
||||||
case OB_STREAM_IR:
|
case OB_STREAM_IR:
|
||||||
|
response->success = false;
|
||||||
response->message = "IR not support set auto exposure";
|
response->message = "IR not support set auto exposure";
|
||||||
break;
|
break;
|
||||||
case OB_STREAM_DEPTH:
|
case OB_STREAM_DEPTH:
|
||||||
device_->setIntProperty(OB_PROP_DEPTH_AUTO_EXPOSURE_BOOL, request->data);
|
device_->setIntProperty(OB_PROP_DEPTH_AUTO_EXPOSURE_BOOL, request->data);
|
||||||
|
response->success = true;
|
||||||
break;
|
break;
|
||||||
case OB_STREAM_COLOR:
|
case OB_STREAM_COLOR:
|
||||||
device_->setIntProperty(OB_PROP_COLOR_AUTO_EXPOSURE_BOOL, request->data);
|
device_->setIntProperty(OB_PROP_COLOR_AUTO_EXPOSURE_BOOL, request->data);
|
||||||
|
response->success = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RCLCPP_ERROR(logger_, "%s NOT a video stream", __FUNCTION__);
|
RCLCPP_ERROR(logger_, "%s NOT a video stream", __FUNCTION__);
|
||||||
|
response->success = false;
|
||||||
|
response->message = "NOT a video stream";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
response->success = false;
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,11 +263,15 @@ void OBCameraNode::setFanModeCallback(const std::shared_ptr<rmw_request_id_t>& r
|
|||||||
bool fan_mode = request->data;
|
bool fan_mode = request->data;
|
||||||
try {
|
try {
|
||||||
device_->setBoolProperty(OB_PROP_FAN_WORK_MODE_INT, fan_mode);
|
device_->setBoolProperty(OB_PROP_FAN_WORK_MODE_INT, fan_mode);
|
||||||
|
response->success = true;
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
response->success = false;
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,11 +285,15 @@ void OBCameraNode::setFloorEnableCallback(
|
|||||||
bool floor_enable = request->data;
|
bool floor_enable = request->data;
|
||||||
try {
|
try {
|
||||||
device_->setBoolProperty(OB_PROP_FLOOD_BOOL, floor_enable);
|
device_->setBoolProperty(OB_PROP_FLOOD_BOOL, floor_enable);
|
||||||
|
response->success = true;
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
response->success = false;
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,11 +325,15 @@ void OBCameraNode::setLdpEnableCallback(
|
|||||||
bool ldp_enable = request->data;
|
bool ldp_enable = request->data;
|
||||||
try {
|
try {
|
||||||
device_->setBoolProperty(OB_PROP_LDP_BOOL, ldp_enable);
|
device_->setBoolProperty(OB_PROP_LDP_BOOL, ldp_enable);
|
||||||
|
response->success = true;
|
||||||
} catch (const ob::Error& e) {
|
} catch (const ob::Error& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.getMessage();
|
response->message = e.getMessage();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
response->success = false;
|
||||||
response->message = e.what();
|
response->message = e.what();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
response->success = false;
|
||||||
response->message = "unknown error";
|
response->message = "unknown error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user