chore: Update connection delay default value to 10 milliseconds

This commit is contained in:
Joe Dong
2024-07-31 16:00:13 +08:00
parent 87c6ee7d97
commit e78783ed48
2 changed files with 11 additions and 3 deletions
@@ -59,7 +59,7 @@ def generate_launch_description():
DeclareLaunchArgument('point_cloud_qos', default_value='default'), DeclareLaunchArgument('point_cloud_qos', default_value='default'),
DeclareLaunchArgument('enable_point_cloud', default_value='false'), DeclareLaunchArgument('enable_point_cloud', default_value='false'),
DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'), DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'),
DeclareLaunchArgument('connection_delay', default_value='100'), DeclareLaunchArgument('connection_delay', default_value='10'),
DeclareLaunchArgument('color_width', default_value='0'), DeclareLaunchArgument('color_width', default_value='0'),
DeclareLaunchArgument('color_height', default_value='0'), DeclareLaunchArgument('color_height', default_value='0'),
DeclareLaunchArgument('color_fps', default_value='0'), DeclareLaunchArgument('color_fps', default_value='0'),
+10 -2
View File
@@ -334,7 +334,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
RCLCPP_INFO_STREAM(logger_, "device unique id: " << device_unique_id_); RCLCPP_INFO_STREAM(logger_, "device unique id: " << device_unique_id_);
RCLCPP_INFO_STREAM(logger_, "Current node pid: " << getpid()); RCLCPP_INFO_STREAM(logger_, "Current node pid: " << getpid());
auto time_cost = std::chrono::duration_cast<std::chrono::milliseconds>( auto time_cost = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - start_time_); std::chrono::high_resolution_clock::now() - start_time_);
RCLCPP_INFO_STREAM(logger_, "Start device cost " << time_cost.count() << " ms"); RCLCPP_INFO_STREAM(logger_, "Start device cost " << time_cost.count() << " ms");
} }
@@ -360,7 +360,7 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
RCLCPP_WARN(logger_, "No device found"); RCLCPP_WARN(logger_, "No device found");
return; return;
} }
start_time_ = std::chrono::system_clock::now(); start_time_ = std::chrono::high_resolution_clock::now();
if (device_) { if (device_) {
device_.reset(); device_.reset();
} }
@@ -370,14 +370,22 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
[this](int *) { pthread_mutex_unlock(orb_device_lock_); }); [this](int *) { pthread_mutex_unlock(orb_device_lock_); });
bool start_device_failed = false; bool start_device_failed = false;
try { try {
auto start_time = std::chrono::high_resolution_clock::now();
auto device = selectDevice(list); auto device = selectDevice(list);
auto end_time = std::chrono::high_resolution_clock::now();
auto time_cost = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
RCLCPP_INFO_STREAM(logger_, "Select device cost " << time_cost.count() << " ms");
if (device == nullptr) { if (device == nullptr) {
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with serial number %s not found", RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with serial number %s not found",
serial_number_.c_str()); serial_number_.c_str());
device_connected_ = false; device_connected_ = false;
return; return;
} }
start_time = std::chrono::high_resolution_clock::now();
initializeDevice(device); initializeDevice(device);
end_time = std::chrono::high_resolution_clock::now();
time_cost = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
RCLCPP_INFO_STREAM(logger_, "Initialize device cost " << time_cost.count() << " ms");
} catch (ob::Error &e) { } catch (ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << e.getMessage()); RCLCPP_ERROR_STREAM(logger_, "Failed to initialize device " << e.getMessage());
start_device_failed = true; start_device_failed = true;