Skip to content

Commit

Permalink
Implmeneta THROTTLE_PERCENT constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Samahu committed May 15, 2024
1 parent 58cc094 commit 08fe4f8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lidar_packet_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class LidarPacketHandler {
lidar_scans[i] = std::make_unique<ouster::LidarScan>(
info.format.columns_per_frame, info.format.pixels_per_column,
info.format.udp_profile_lidar);
mutexes[i] = std::make_shared<std::mutex>(); // make_unique?
mutexes[i] = std::make_unique<std::mutex>();
}

lidar_scans_processing_thread = std::make_unique<std::thread>([this]() {
Expand Down Expand Up @@ -165,9 +165,11 @@ class LidarPacketHandler {
lidar_scan_estimated_msg_ts);
}

// why we hit percent amount of the ring_buffer capacity throttle
size_t read_step = 1;
if (ring_buffer.size() > 7) {
NODELET_WARN("lidar_scans full, THROTTLING");
if (ring_buffer.size() > THROTTLE_PERCENT * ring_buffer.capacity()) {
NODELET_WARN("lidar_scans %d%% full, THROTTLING",
static_cast<int>(100* THROTTLE_PERCENT));
read_step = 2;
}
ring_buffer.read(read_step);
Expand Down Expand Up @@ -342,10 +344,11 @@ class LidarPacketHandler {
private:
std::unique_ptr<ouster::ScanBatcher> scan_batcher;
const int LIDAR_SCAN_COUNT = 10;
const double THROTTLE_PERCENT = 0.7;
LockFreeRingBuffer ring_buffer;
std::mutex ring_buffer_mutex;
std::vector<std::unique_ptr<ouster::LidarScan>> lidar_scans;
std::vector<std::shared_ptr<std::mutex>> mutexes;
std::vector<std::unique_ptr<std::mutex>> mutexes;

uint64_t lidar_scan_estimated_ts;
ros::Time lidar_scan_estimated_msg_ts;
Expand Down

0 comments on commit 08fe4f8

Please sign in to comment.