mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-13 11:30:20 +08:00
[service] add set_threshold_filter_enable
This commit is contained in:
@@ -302,6 +302,9 @@ class OBCameraNode {
|
||||
void setSequenceIdFilterEnableCallback(
|
||||
const std::shared_ptr<std_srvs::srv::SetBool::Request>& request,
|
||||
std::shared_ptr<std_srvs::srv::SetBool::Response>& response);
|
||||
void setThresholdFilterEnableCallback(
|
||||
const std::shared_ptr<std_srvs::srv::SetBool::Request>& request,
|
||||
std::shared_ptr<std_srvs::srv::SetBool::Response>& response);
|
||||
|
||||
bool toggleSensor(const stream_index_pair& stream_index, bool enabled, std::string& msg);
|
||||
|
||||
@@ -458,6 +461,7 @@ class OBCameraNode {
|
||||
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr set_sync_host_time_srv_;
|
||||
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr set_decimation_filter_enable_srv_;
|
||||
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr set_sequence_id_filter_enable_srv_;
|
||||
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr set_threshold_filter_enable_srv_;
|
||||
|
||||
bool enable_sync_output_accel_gyro_ = false;
|
||||
bool publish_tf_ = false;
|
||||
|
||||
@@ -194,6 +194,11 @@ void OBCameraNode::setupCameraCtrlServices() {
|
||||
std::shared_ptr<SetBool::Response> response) {
|
||||
setSequenceIdFilterEnableCallback(request, response);
|
||||
});
|
||||
set_threshold_filter_enable_srv_ = node_->create_service<SetBool>(
|
||||
"set_threshold_filter_enable", [this](const std::shared_ptr<SetBool::Request> request,
|
||||
std::shared_ptr<SetBool::Response> response) {
|
||||
setThresholdFilterEnableCallback(request, response);
|
||||
});
|
||||
}
|
||||
|
||||
void OBCameraNode::setExposureCallback(const std::shared_ptr<SetInt32::Request>& request,
|
||||
@@ -905,4 +910,38 @@ void OBCameraNode::setSequenceIdFilterEnableCallback(
|
||||
response->success = false;
|
||||
}
|
||||
}
|
||||
void OBCameraNode::setThresholdFilterEnableCallback(
|
||||
const std::shared_ptr<std_srvs::srv::SetBool::Request>& request,
|
||||
std::shared_ptr<std_srvs::srv::SetBool::Response>& response) {
|
||||
try {
|
||||
enable_threshold_filter_ = request->data;
|
||||
if (enable_threshold_filter_) {
|
||||
threshold_filter_max_ = node_->get_parameter("threshold_filter_max").as_int();
|
||||
threshold_filter_min_ = node_->get_parameter("threshold_filter_min").as_int();
|
||||
if (threshold_filter_max_ == -1 || threshold_filter_min_ == -1) {
|
||||
RCLCPP_WARN(
|
||||
logger_,
|
||||
"Please configure the parameter 'threshold_filter_max' and 'threshold_filter_min'");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
threshold_filter_max_ = -1;
|
||||
threshold_filter_min_ = -1;
|
||||
node_->set_parameter(rclcpp::Parameter("threshold_filter_max", threshold_filter_max_));
|
||||
node_->set_parameter(rclcpp::Parameter("threshold_filter_min", threshold_filter_min_));
|
||||
}
|
||||
setupDepthPostProcessFilter();
|
||||
node_->set_parameter(rclcpp::Parameter("enable_threshold_filter", enable_threshold_filter_));
|
||||
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;
|
||||
}
|
||||
}
|
||||
} // namespace orbbec_camera
|
||||
|
||||
Reference in New Issue
Block a user