Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(hesai): remove decoder thread and MtQueue, make everything single-threaded #226

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions nebula_ros/include/nebula_ros/hesai/hesai_ros_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "nebula_common/hesai/hesai_common.hpp"
#include "nebula_common/nebula_common.hpp"
#include "nebula_common/nebula_status.hpp"
#include "nebula_ros/common/mt_queue.hpp"
#include "nebula_ros/hesai/decoder_wrapper.hpp"
#include "nebula_ros/hesai/hw_interface_wrapper.hpp"
#include "nebula_ros/hesai/hw_monitor_wrapper.hpp"
Expand Down Expand Up @@ -98,11 +97,6 @@ class HesaiRosWrapper final : public rclcpp::Node

std::shared_ptr<const nebula::drivers::HesaiSensorConfiguration> sensor_cfg_ptr_{};

/// @brief Stores received packets that have not been processed yet by the decoder thread
MtQueue<std::unique_ptr<nebula_msgs::msg::NebulaPacket>> packet_queue_;
/// @brief Thread to isolate decoding from receiving
std::thread decoder_thread_;

rclcpp::Subscription<pandar_msgs::msg::PandarScan>::SharedPtr packets_sub_{};

bool launch_hw_;
Expand Down
13 changes: 2 additions & 11 deletions nebula_ros/src/hesai/hesai_ros_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
: rclcpp::Node("hesai_ros_wrapper", rclcpp::NodeOptions(options).use_intra_process_comms(true)),
wrapper_status_(Status::NOT_INITIALIZED),
sensor_cfg_ptr_(nullptr),
packet_queue_(3000),
hw_interface_wrapper_(),
hw_monitor_wrapper_(),
decoder_wrapper_()
Expand Down Expand Up @@ -82,12 +81,6 @@

RCLCPP_DEBUG(get_logger(), "Starting stream");

decoder_thread_ = std::thread([this]() {
while (true) {
decoder_wrapper_->process_cloud_packet(packet_queue_.pop());
}
});

if (launch_hw_) {
hw_interface_wrapper_->hw_interface()->RegisterScanCallback(
std::bind(&HesaiRosWrapper::receive_cloud_packet_callback, this, std::placeholders::_1));
Expand Down Expand Up @@ -289,7 +282,7 @@
nebula_pkt_ptr->stamp = pkt.stamp;
std::copy(pkt.data.begin(), pkt.data.end(), std::back_inserter(nebula_pkt_ptr->data));

packet_queue_.push(std::move(nebula_pkt_ptr));
decoder_wrapper_->process_cloud_packet(std::move(nebula_pkt_ptr));

Check warning on line 285 in nebula_ros/src/hesai/hesai_ros_wrapper.cpp

View check run for this annotation

Codecov / codecov/patch

nebula_ros/src/hesai/hesai_ros_wrapper.cpp#L285

Added line #L285 was not covered by tests
}
}

Expand Down Expand Up @@ -428,9 +421,7 @@
msg_ptr->stamp.nanosec = static_cast<int>(timestamp_ns % 1'000'000'000);
msg_ptr->data.swap(packet);

if (!packet_queue_.try_push(std::move(msg_ptr))) {
RCLCPP_ERROR_THROTTLE(get_logger(), *get_clock(), 500, "Packet(s) dropped");
}
decoder_wrapper_->process_cloud_packet(std::move(msg_ptr));

Check warning on line 424 in nebula_ros/src/hesai/hesai_ros_wrapper.cpp

View check run for this annotation

Codecov / codecov/patch

nebula_ros/src/hesai/hesai_ros_wrapper.cpp#L424

Added line #L424 was not covered by tests
}

std::string HesaiRosWrapper::get_calibration_parameter_name(drivers::SensorModel model) const
Expand Down
Loading