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(robosense): remove mtqueue #277

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion nebula_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ if(BUILD_TESTING)

ament_lint_auto_find_test_dependencies()

foreach(MODEL Pandar40P Pandar64 PandarQT64 PandarQT128 Pandar128E4X PandarAT128 PandarXT16 PandarXT32 PandarXT32M)
foreach(MODEL Pandar40P Pandar64 PandarQT64 PandarQT128 Pandar128E4X PandarAT128 PandarXT16 PandarXT32 PandarXT32M Helios Bpearl)
string(TOLOWER ${MODEL}_smoke_test test_name)
add_ros_test(
test/smoke_test.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include "nebula_ros/common/mt_queue.hpp"
#include "nebula_ros/robosense/decoder_wrapper.hpp"
#include "nebula_ros/robosense/hw_interface_wrapper.hpp"
#include "nebula_ros/robosense/hw_monitor_wrapper.hpp"
Expand Down Expand Up @@ -84,11 +83,6 @@ class RobosenseRosWrapper final : public rclcpp::Node

std::shared_ptr<const nebula::drivers::RobosenseSensorConfiguration> 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::Publisher<robosense_msgs::msg::RobosenseInfoPacket>::SharedPtr info_packets_pub_;

rclcpp::Subscription<robosense_msgs::msg::RobosenseScan>::SharedPtr packets_sub_;
Expand Down
20 changes: 7 additions & 13 deletions nebula_ros/src/robosense/robosense_ros_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
RobosenseRosWrapper::RobosenseRosWrapper(const rclcpp::NodeOptions & options)
: rclcpp::Node("robosense_ros_wrapper", rclcpp::NodeOptions(options).use_intra_process_comms(true)),
wrapper_status_(Status::NOT_INITIALIZED),
sensor_cfg_ptr_(nullptr),
packet_queue_(3000)
sensor_cfg_ptr_(nullptr)
{
setvbuf(stdout, NULL, _IONBF, BUFSIZ);

Expand All @@ -48,13 +47,6 @@

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

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

if (launch_hw_) {
info_packets_pub_ =
create_publisher<robosense_msgs::msg::RobosenseInfoPacket>("robosense_info_packets", 10);
Expand Down Expand Up @@ -158,12 +150,16 @@
return;
}

if (!decoder_wrapper_ || decoder_wrapper_->status() != Status::OK) {
return;

Check warning on line 154 in nebula_ros/src/robosense/robosense_ros_wrapper.cpp

View check run for this annotation

Codecov / codecov/patch

nebula_ros/src/robosense/robosense_ros_wrapper.cpp#L154

Added line #L154 was not covered by tests
}

for (auto & pkt : scan_msg->packets) {
auto nebula_pkt_ptr = std::make_unique<nebula_msgs::msg::NebulaPacket>();
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));
}
}

Expand Down Expand Up @@ -312,9 +308,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));
}

RCLCPP_COMPONENTS_REGISTER_NODE(RobosenseRosWrapper)
Expand Down
2 changes: 1 addition & 1 deletion nebula_ros/test/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def generate_test_description():
class TestCorrectStartup(unittest.TestCase):
def test_wait_for_startup_then_shutdown(self):
self.proc_output: launch_testing.ActiveIoHandler
self.proc_output.assertWaitFor("Wrapper=OK", timeout=2)
self.proc_output.assertWaitFor("Hardware connection disabled", timeout=2)


@launch_testing.post_shutdown_test()
Expand Down