feat: add runtime stream profile service

This commit is contained in:
slz
2026-07-08 16:10:51 +08:00
parent fdc0d1fe9c
commit d59c78d750
6 changed files with 506 additions and 101 deletions
+35
View File
@@ -351,6 +351,11 @@ void OBCameraNode::setupCameraCtrlServices() {
std::shared_ptr<SetBool::Response> response) {
setStreamsEnableCallback(request, response);
});
set_stream_profile_srv_ = node_->create_service<SetStreamProfile>(
"set_stream_profile", [this](const std::shared_ptr<SetStreamProfile::Request> request,
std::shared_ptr<SetStreamProfile::Response> response) {
setStreamProfileCallback(request, response);
});
get_streams_enable_srv_ = node_->create_service<GetBool>(
"get_streams_enable", [this](const std::shared_ptr<GetBool::Request> request,
std::shared_ptr<GetBool::Response> response) {
@@ -632,6 +637,36 @@ void OBCameraNode::setStreamsEnableCallback(
}
}
void OBCameraNode::setStreamProfileCallback(
const std::shared_ptr<SetStreamProfile::Request>& request,
std::shared_ptr<SetStreamProfile::Response>& response) {
try {
std::vector<PendingStreamProfile> pending_profiles;
std::string message;
if (!validateStreamProfileRequest(request, pending_profiles, message)) {
response->success = false;
response->message = message;
return;
}
if (!applyStreamProfiles(pending_profiles, message)) {
response->success = false;
response->message = message;
return;
}
response->success = true;
response->message = message;
} catch (const ob::Error& e) {
response->success = false;
response->message = orbbec_camera::formatObErrorWithStatus(e);
} catch (const std::exception& e) {
response->success = false;
response->message = e.what();
} catch (...) {
response->success = false;
response->message = "unknown error";
}
}
void OBCameraNode::getStreamsEnableCallback(
const std::shared_ptr<orbbec_camera_msgs::srv::GetBool::Request> request,
std::shared_ptr<orbbec_camera_msgs::srv::GetBool::Response> response) {