mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-10 10:20:19 +08:00
Refactor code for improved readability and consistency
This commit is contained in:
@@ -17,8 +17,8 @@ class CameraExampleNode : public rclcpp::Node {
|
||||
get_params_client_ = this->create_client<orbbec_camera_msgs::srv::GetUserCalibParams>(
|
||||
"/camera/get_user_calib_params");
|
||||
set_streams_client_ = this->create_client<std_srvs::srv::SetBool>("/camera/set_streams_enable");
|
||||
set_color_ae_roi_client_ = this->create_client<orbbec_camera_msgs::srv::SetArrays>(
|
||||
"/camera/set_color_ae_roi");
|
||||
set_color_ae_roi_client_ =
|
||||
this->create_client<orbbec_camera_msgs::srv::SetArrays>("/camera/set_color_ae_roi");
|
||||
get_device_info_client_ =
|
||||
this->create_client<orbbec_camera_msgs::srv::GetDeviceInfo>("/camera/get_device_info");
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
last_time_(0.0),
|
||||
frame_interval_(1.0 / hz),
|
||||
stop_display_thread_(false) {
|
||||
sync_topics_ =
|
||||
this->declare_parameter<std::vector<std::string>>("sync_topics", std::vector<std::string>{});
|
||||
sync_topics_ = this->declare_parameter<std::vector<std::string>>("sync_topics",
|
||||
std::vector<std::string>{});
|
||||
queue_size_ = this->declare_parameter<int>("queue_size", 10);
|
||||
sync_tolerance_ms_ =
|
||||
this->declare_parameter<double>("sync_tolerance_ms", frame_interval_ * 500.0);
|
||||
@@ -70,8 +70,8 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
validate_topics();
|
||||
topic_infos_ = make_topic_infos(sync_topics_);
|
||||
|
||||
RCLCPP_INFO(this->get_logger(), "image sync node started with %zu topic(s):",
|
||||
sync_topics_.size());
|
||||
RCLCPP_INFO(this->get_logger(),
|
||||
"image sync node started with %zu topic(s):", sync_topics_.size());
|
||||
for (const auto &topic : sync_topics_) {
|
||||
RCLCPP_INFO(this->get_logger(), " %s", topic.c_str());
|
||||
}
|
||||
@@ -325,16 +325,16 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
using Policy = message_filters::sync_policies::ApproximateTime<Image, Image>;
|
||||
using Sync = message_filters::Synchronizer<Policy>;
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1]);
|
||||
sync->registerCallback(std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2));
|
||||
sync->registerCallback(
|
||||
std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr>, this, _1, _2));
|
||||
configure_synchronizer(sync);
|
||||
}
|
||||
|
||||
void create_synchronizer_3() {
|
||||
using Policy = message_filters::sync_policies::ApproximateTime<Image, Image, Image>;
|
||||
using Sync = message_filters::Synchronizer<Policy>;
|
||||
auto sync =
|
||||
std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1], subscribers_[2]);
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2]);
|
||||
sync->registerCallback(
|
||||
std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr, ImageConstPtr>, this,
|
||||
_1, _2, _3));
|
||||
@@ -346,9 +346,9 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
using Sync = message_filters::Synchronizer<Policy>;
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2], subscribers_[3]);
|
||||
sync->registerCallback(std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4));
|
||||
sync->registerCallback(std::bind(
|
||||
&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr, ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4));
|
||||
configure_synchronizer(sync);
|
||||
}
|
||||
|
||||
@@ -358,10 +358,10 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
using Sync = message_filters::Synchronizer<Policy>;
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2], subscribers_[3], subscribers_[4]);
|
||||
sync->registerCallback(std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5));
|
||||
sync->registerCallback(
|
||||
std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5));
|
||||
configure_synchronizer(sync);
|
||||
}
|
||||
|
||||
@@ -369,13 +369,13 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
using Policy =
|
||||
message_filters::sync_policies::ApproximateTime<Image, Image, Image, Image, Image, Image>;
|
||||
using Sync = message_filters::Synchronizer<Policy>;
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2], subscribers_[3], subscribers_[4],
|
||||
subscribers_[5]);
|
||||
sync->registerCallback(std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5, _6));
|
||||
auto sync =
|
||||
std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2], subscribers_[3], subscribers_[4], subscribers_[5]);
|
||||
sync->registerCallback(
|
||||
std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5, _6));
|
||||
configure_synchronizer(sync);
|
||||
}
|
||||
|
||||
@@ -386,11 +386,10 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2], subscribers_[3], subscribers_[4],
|
||||
subscribers_[5], subscribers_[6]);
|
||||
sync->registerCallback(std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5, _6, _7));
|
||||
sync->registerCallback(std::bind(
|
||||
&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr, ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5, _6, _7));
|
||||
configure_synchronizer(sync);
|
||||
}
|
||||
|
||||
@@ -401,11 +400,10 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
auto sync = std::make_shared<Sync>(Policy(queue_size_), subscribers_[0], subscribers_[1],
|
||||
subscribers_[2], subscribers_[3], subscribers_[4],
|
||||
subscribers_[5], subscribers_[6], subscribers_[7]);
|
||||
sync->registerCallback(std::bind(&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5, _6, _7, _8));
|
||||
sync->registerCallback(std::bind(
|
||||
&ImageSyncNode::sync_callback<ImageConstPtr, ImageConstPtr, ImageConstPtr, ImageConstPtr,
|
||||
ImageConstPtr, ImageConstPtr, ImageConstPtr, ImageConstPtr>,
|
||||
this, _1, _2, _3, _4, _5, _6, _7, _8));
|
||||
configure_synchronizer(sync);
|
||||
}
|
||||
|
||||
@@ -486,8 +484,8 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
if (i >= display_images.size()) {
|
||||
break;
|
||||
}
|
||||
display_images[i].copyTo(canvas(cv::Rect(x_offset, y_offset, display_images[i].cols,
|
||||
display_images[i].rows)));
|
||||
display_images[i].copyTo(
|
||||
canvas(cv::Rect(x_offset, y_offset, display_images[i].cols, display_images[i].rows)));
|
||||
x_offset += column_widths[col] + margin;
|
||||
}
|
||||
y_offset += row_heights[row] + margin;
|
||||
@@ -520,10 +518,9 @@ class ImageSyncNode : public rclcpp::Node {
|
||||
const double base_t = timestamps[0];
|
||||
for (size_t i = 0; i < timestamps.size(); ++i) {
|
||||
std::cout << topic_infos_[i].camera_name << " " << topic_infos_[i].image_type
|
||||
<< " stamp: " << std::setprecision(6) << timestamps[i]
|
||||
<< " Delay relative to " << topic_infos_[0].camera_name << " "
|
||||
<< topic_infos_[0].image_type << ": " << std::setprecision(3)
|
||||
<< (timestamps[i] - base_t) * 1000.0 << " ms" << std::endl;
|
||||
<< " stamp: " << std::setprecision(6) << timestamps[i] << " Delay relative to "
|
||||
<< topic_infos_[0].camera_name << " " << topic_infos_[0].image_type << ": "
|
||||
<< std::setprecision(3) << (timestamps[i] - base_t) * 1000.0 << " ms" << std::endl;
|
||||
}
|
||||
|
||||
double cur = 0.0;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -181,10 +181,12 @@ class SingleServiceBenchmark {
|
||||
if (response->success) {
|
||||
success++;
|
||||
RCLCPP_INFO(nh_->get_logger(), "Call %s %d/%d succeeded (cost: %.2f ms)",
|
||||
service_name_.c_str(), i + 1, count_, dt);
|
||||
service_name_.c_str(), i + 1, count_, dt);
|
||||
} else {
|
||||
RCLCPP_WARN(nh_->get_logger(), "Call %s %d/%d (cost: %.2f ms) responded with success=false, message='%s'",
|
||||
service_name_.c_str(), i + 1, count_, dt,response->message.c_str());
|
||||
RCLCPP_WARN(
|
||||
nh_->get_logger(),
|
||||
"Call %s %d/%d (cost: %.2f ms) responded with success=false, message='%s'",
|
||||
service_name_.c_str(), i + 1, count_, dt, response->message.c_str());
|
||||
}
|
||||
} else {
|
||||
success++;
|
||||
|
||||
@@ -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.
|
||||
*******************************************************************************/
|
||||
#include "orbbec_camera/dynamic_params.h"
|
||||
|
||||
namespace orbbec_camera {
|
||||
|
||||
@@ -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.
|
||||
*******************************************************************************/
|
||||
#include "orbbec_camera/jetson_nv_decoder.h"
|
||||
#include <NvJpegDecoder.h>
|
||||
#include <NvV4l2Element.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.
|
||||
*******************************************************************************/
|
||||
#include <orbbec_camera/jpeg_decoder.h>
|
||||
|
||||
namespace orbbec_camera {
|
||||
|
||||
@@ -296,9 +296,9 @@ void OBLidarNode::setupProfiles() {
|
||||
}
|
||||
|
||||
} catch (const ob::Error &ex) {
|
||||
RCLCPP_ERROR_STREAM(
|
||||
logger_, "Failed to get " << stream_name_[elem]
|
||||
<< " profile: " << orbbec_camera::formatObErrorWithStatus(ex));
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to get "
|
||||
<< stream_name_[elem] << " profile: "
|
||||
<< orbbec_camera::formatObErrorWithStatus(ex));
|
||||
RCLCPP_ERROR_STREAM(logger_, "Stream: " << magic_enum::enum_name(elem.first)
|
||||
<< ", Stream Index: " << elem.second
|
||||
<< ", Scan Rate: " << rate_[elem]
|
||||
@@ -1262,10 +1262,9 @@ void OBLidarNode::calcAndPublishStaticTransform() {
|
||||
ex = base_stream_profile->getExtrinsicTo(stream_profile_[GYRO]);
|
||||
RCLCPP_INFO_STREAM(logger_, "Using GYRO extrinsic for IMU");
|
||||
} catch (const ob::Error &e2) {
|
||||
RCLCPP_ERROR_STREAM(
|
||||
logger_, "Failed to get " << frame_id
|
||||
<< " extrinsic from both ACCEL and GYRO: "
|
||||
<< orbbec_camera::formatObErrorWithStatus(e2));
|
||||
RCLCPP_ERROR_STREAM(logger_, "Failed to get "
|
||||
<< frame_id << " extrinsic from both ACCEL and GYRO: "
|
||||
<< orbbec_camera::formatObErrorWithStatus(e2));
|
||||
ex = OBExtrinsic({{1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 0, 0}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "orbbec_camera/rk_mpp_decoder.h"
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
|
||||
@@ -1495,8 +1495,8 @@ void OBCameraNode::switchIRCameraCallback(const std::shared_ptr<SetString::Reque
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNode::exportConfigJsonCallback(const std::shared_ptr<SetString::Request> &request,
|
||||
std::shared_ptr<SetString::Response> &response) {
|
||||
void OBCameraNode::exportConfigJsonCallback(const std::shared_ptr<SetString::Request>& request,
|
||||
std::shared_ptr<SetString::Response>& response) {
|
||||
response->success = exportConfigJsonToFile(request->data, response->message);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*******************************************************************************/
|
||||
#include "orbbec_camera/utils.h"
|
||||
#include "orbbec_camera/synced_imu_publisher.h"
|
||||
#include <rclcpp/rclcpp.hpp>
|
||||
|
||||
@@ -44,8 +44,7 @@ void waitForFirmwareLogDrain(const rclcpp::Logger &logger) {
|
||||
}
|
||||
|
||||
bool isSdkLogEnabled(const std::string &log_level) {
|
||||
return orbbec_camera::obLogSeverityFromString(log_level) !=
|
||||
OBLogSeverity::OB_LOG_SEVERITY_OFF;
|
||||
return orbbec_camera::obLogSeverityFromString(log_level) != OBLogSeverity::OB_LOG_SEVERITY_OFF;
|
||||
}
|
||||
|
||||
struct CliArgs {
|
||||
@@ -629,8 +628,7 @@ bool updatePresetFirmware(const rclcpp::Logger &logger, const std::shared_ptr<ob
|
||||
|
||||
FirmwareUpdateResult updateFirmware(const rclcpp::Logger &logger,
|
||||
const std::shared_ptr<ob::Device> &device,
|
||||
const std::string &firmware_path,
|
||||
bool firmware_log_enabled) {
|
||||
const std::string &firmware_path, bool firmware_log_enabled) {
|
||||
FirmwareUpdateResult result;
|
||||
if (firmware_path.empty()) {
|
||||
result.success = true;
|
||||
|
||||
@@ -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.
|
||||
*******************************************************************************/
|
||||
#include <orbbec_camera/ob_camera_node.h>
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -177,16 +177,18 @@ class ObBenchmark : public rclcpp::Node {
|
||||
std::ofstream file;
|
||||
file.open(filename, std::ios_base::app);
|
||||
if (file.is_open()) {
|
||||
file << "Time,CPU,Memory(MB)" << "\n";
|
||||
file << "Time,CPU,Memory(MB)"
|
||||
<< "\n";
|
||||
for (int i = skip_number_; i < usage_count_ - 1; i++) {
|
||||
file << current_time_[i] << "," << cpu_usage_[i] << "%" << "," << memory_usage_[i] << "\n";
|
||||
file << current_time_[i] << "," << cpu_usage_[i] << "%"
|
||||
<< "," << memory_usage_[i] << "\n";
|
||||
}
|
||||
float cpu_average =
|
||||
std::accumulate(cpu_usage_.begin() + skip_number_, cpu_usage_.begin() + usage_count_ - 1, 0.0f) /
|
||||
(usage_count_ - (skip_number_+1));
|
||||
float cpu_average = std::accumulate(cpu_usage_.begin() + skip_number_,
|
||||
cpu_usage_.begin() + usage_count_ - 1, 0.0f) /
|
||||
(usage_count_ - (skip_number_ + 1));
|
||||
float memory_average = std::accumulate(memory_usage_.begin() + skip_number_,
|
||||
memory_usage_.begin() + usage_count_ - 1, 0.0f) /
|
||||
(usage_count_ - (skip_number_+1));
|
||||
(usage_count_ - (skip_number_ + 1));
|
||||
file << "Average: ," << cpu_average << "%, " << memory_average << "\n";
|
||||
RCLCPP_INFO_STREAM(rclcpp::get_logger("ObBenchmark"),
|
||||
"Average: " << cpu_average << "%" << memory_average << "MB");
|
||||
@@ -200,7 +202,7 @@ class ObBenchmark : public rclcpp::Node {
|
||||
usage_count_ = 0;
|
||||
++launch_count_;
|
||||
}
|
||||
void kill_process(const std::string& process_name) {
|
||||
void kill_process(const std::string& process_name) {
|
||||
std::string command = "ps aux | grep " + process_name + " | grep -v grep | awk '{print $2}'";
|
||||
|
||||
std::shared_ptr<FILE> pipe(popen(command.c_str(), "r"), pclose);
|
||||
@@ -224,15 +226,15 @@ void kill_process(const std::string& process_name) {
|
||||
}
|
||||
|
||||
for (int pid : pids) {
|
||||
if (kill(pid, SIGINT) == 0) {
|
||||
RCLCPP_INFO_STREAM(rclcpp::get_logger("ObBenchmark"),
|
||||
"Successfully sent SIGINT (Ctrl+C) to process with PID " << pid);
|
||||
} else {
|
||||
RCLCPP_ERROR_STREAM(this->get_logger(),
|
||||
"Failed to send SIGINT to process with PID " << pid);
|
||||
}
|
||||
if (kill(pid, SIGINT) == 0) {
|
||||
RCLCPP_INFO_STREAM(rclcpp::get_logger("ObBenchmark"),
|
||||
"Successfully sent SIGINT (Ctrl+C) to process with PID " << pid);
|
||||
} else {
|
||||
RCLCPP_ERROR_STREAM(this->get_logger(),
|
||||
"Failed to send SIGINT to process with PID " << pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void stat_process() {
|
||||
const char* ros2_launch = "/opt/ros/humble/bin/ros2";
|
||||
std::string start_launch = "ob_benchmark_" + std::to_string(launch_count_) + ".launch.py";
|
||||
@@ -272,9 +274,8 @@ void kill_process(const std::string& process_name) {
|
||||
current_time_.push_back(getCurrentTimes());
|
||||
RCLCPP_INFO_STREAM(rclcpp::get_logger("ObBenchmark"),
|
||||
"CurrentTimes: " << current_time_[usage_count_]);
|
||||
RCLCPP_INFO_STREAM(rclcpp::get_logger("ObBenchmark"), "CPU Usage of "
|
||||
<< process_name_ << ":"
|
||||
<< cpu_usage_[usage_count_] << "%");
|
||||
RCLCPP_INFO_STREAM(rclcpp::get_logger("ObBenchmark"),
|
||||
"CPU Usage of " << process_name_ << ":" << cpu_usage_[usage_count_] << "%");
|
||||
RCLCPP_INFO_STREAM(
|
||||
rclcpp::get_logger("ObBenchmark"),
|
||||
"Memory Usage of " << process_name_ << ":" << memory_usage_[usage_count_] << "MB");
|
||||
|
||||
@@ -68,7 +68,6 @@ class StartBenchmark : public rclcpp::Node {
|
||||
std::vector<rclcpp::Subscription<sensor_msgs::msg::PointCloud2>::SharedPtr>
|
||||
color_point_cloud_subs_;
|
||||
|
||||
|
||||
std::vector<std::string> camera_name_;
|
||||
std::vector<std::string> color_topics_;
|
||||
std::vector<std::string> depth_topics_;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "topic_statistics.hpp"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::spin(std::make_shared<orbbec_camera::tools::TopicStatistics>());
|
||||
rclcpp::shutdown();
|
||||
|
||||
Reference in New Issue
Block a user