mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-07 13:37:44 +08:00
Refactor code for improved readability and consistency
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
#include <message_filters/subscriber.h>
|
||||
#include <message_filters/sync_policies/approximate_time.h>
|
||||
@@ -30,7 +30,7 @@ class D2CViewer {
|
||||
rmw_qos_profile_t depth_qos, bool use_intra_process = false);
|
||||
~D2CViewer();
|
||||
|
||||
void messageCallback(const sensor_msgs::msg::Image::ConstSharedPtr & rgb_msg,
|
||||
void messageCallback(const sensor_msgs::msg::Image::ConstSharedPtr& rgb_msg,
|
||||
const sensor_msgs::msg::Image::ConstSharedPtr& depth_msg);
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
#include "utils.h"
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -239,9 +239,9 @@ class OBCameraNode {
|
||||
|
||||
void captureInitialRosParameters();
|
||||
|
||||
bool isLaunchParamProvided(const std::string ¶m_name) const;
|
||||
bool isLaunchParamProvided(const std::string& param_name) const;
|
||||
|
||||
bool exportConfigJsonToFile(const std::string &file_path, std::string &message);
|
||||
bool exportConfigJsonToFile(const std::string& file_path, std::string& message);
|
||||
|
||||
void exportConfigJsonIfRequested();
|
||||
|
||||
@@ -249,8 +249,8 @@ class OBCameraNode {
|
||||
|
||||
void syncConfigJsonDeviceSettings();
|
||||
|
||||
void syncConfigJsonFilterSettings(const std::vector<std::shared_ptr<ob::Filter>> &filters,
|
||||
const std::string &sensor_name);
|
||||
void syncConfigJsonFilterSettings(const std::vector<std::shared_ptr<ob::Filter>>& filters,
|
||||
const std::string& sensor_name);
|
||||
|
||||
void setupProfiles();
|
||||
|
||||
@@ -282,19 +282,19 @@ class OBCameraNode {
|
||||
|
||||
void publishDepthFiltersStatus();
|
||||
|
||||
DepthFilterState buildDepthFilterState(const std::string &filter_name, bool enabled,
|
||||
const std::shared_ptr<ob::Filter> &filter) const;
|
||||
DepthFilterState buildDepthFilterState(const std::string& filter_name, bool enabled,
|
||||
const std::shared_ptr<ob::Filter>& filter) const;
|
||||
|
||||
static std::string normalizeDepthFilterName(const std::string &filter_name);
|
||||
static std::string normalizeDepthFilterName(const std::string& filter_name);
|
||||
|
||||
static void appendDepthFilterParam(DepthFilterState &filter_state, const std::string &name,
|
||||
const std::string &value);
|
||||
static void appendDepthFilterParam(DepthFilterState& filter_state, const std::string& name,
|
||||
const std::string& value);
|
||||
|
||||
void updateDepthFilterEnabledCache(const std::string &filter_name, bool enabled);
|
||||
void updateDepthFilterEnabledCache(const std::string& filter_name, bool enabled);
|
||||
|
||||
bool applyNamedDepthFilterConfig(
|
||||
const std::string &filter_name, bool enabled,
|
||||
const std::vector<orbbec_camera_msgs::msg::DepthFilterParam> ¶ms, std::string &message);
|
||||
const std::string& filter_name, bool enabled,
|
||||
const std::vector<orbbec_camera_msgs::msg::DepthFilterParam>& params, std::string& message);
|
||||
|
||||
void setupCameraInfo();
|
||||
|
||||
@@ -435,8 +435,8 @@ class OBCameraNode {
|
||||
void switchIRCameraCallback(const std::shared_ptr<SetString::Request>& request,
|
||||
std::shared_ptr<SetString::Response>& response);
|
||||
|
||||
void exportConfigJsonCallback(const std::shared_ptr<SetString::Request> &request,
|
||||
std::shared_ptr<SetString::Response> &response);
|
||||
void exportConfigJsonCallback(const std::shared_ptr<SetString::Request>& request,
|
||||
std::shared_ptr<SetString::Response>& response);
|
||||
|
||||
bool writeCustomerData(const std::string& data);
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
#pragma once
|
||||
|
||||
#include "jpeg_decoder.h"
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
* Copyright (c) 2023 Orbbec 3D Technology, Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
|
||||
@@ -71,20 +71,21 @@ inline std::string formatObErrorWithStatus(const ob::Error& e) {
|
||||
RCLCPP_ERROR(logger_, "Unknown exception in %s at line %d", __FUNCTION__, __LINE__); \
|
||||
}
|
||||
|
||||
#define TRY_TO_SET_PROPERTY(func, property, value) \
|
||||
try { \
|
||||
device_->func(property, value); \
|
||||
} catch (const ob::Error& e) { \
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
|
||||
<< __FUNCTION__ << " at line " << __LINE__ \
|
||||
<< ": " << orbbec_camera::formatObErrorWithStatus(e)); \
|
||||
} catch (const std::exception& e) { \
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
|
||||
<< __FUNCTION__ << " at line " << __LINE__ \
|
||||
<< ": " << e.what()); \
|
||||
} catch (...) { \
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
|
||||
<< __FUNCTION__ << " at line " << __LINE__); \
|
||||
#define TRY_TO_SET_PROPERTY(func, property, value) \
|
||||
try { \
|
||||
device_->func(property, value); \
|
||||
} catch (const ob::Error& e) { \
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
|
||||
<< __FUNCTION__ << " at line " << __LINE__ \
|
||||
<< ": " \
|
||||
<< orbbec_camera::formatObErrorWithStatus(e)); \
|
||||
} catch (const std::exception& e) { \
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
|
||||
<< __FUNCTION__ << " at line " << __LINE__ \
|
||||
<< ": " << e.what()); \
|
||||
} catch (...) { \
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
|
||||
<< __FUNCTION__ << " at line " << __LINE__); \
|
||||
}
|
||||
|
||||
// Macros for checking conditions and comparing values
|
||||
@@ -168,8 +169,7 @@ OBLogSeverity obLogSeverityFromString(const std::string_view& log_level);
|
||||
|
||||
std::string getObSdkLogDirectory();
|
||||
|
||||
std::string configureObSdkLoggerForTool(const std::string& tool_name,
|
||||
const std::string& log_level);
|
||||
std::string configureObSdkLoggerForTool(const std::string& tool_name, const std::string& log_level);
|
||||
|
||||
OBFormat OBFormatFromString(const std::string& format);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user