Skip to content

Commit

Permalink
Correct buffer allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Samahu committed Oct 8, 2024
1 parent 1134b70 commit 2822961
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 2 additions & 6 deletions ouster-ros/src/os_pcap_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class OusterPcap : public OusterSensorNodeBase {
RCLCPP_DEBUG(get_logger(), "on_activate() is called.");
LifecycleNode::on_activate(state);
create_publishers();
if (imu_packet_pub) imu_packet_pub->on_activate();
if (lidar_packet_pub) lidar_packet_pub->on_activate();
allocate_buffers();
start_packet_read_thread();
return LifecycleNodeInterface::CallbackReturn::SUCCESS;
Expand Down Expand Up @@ -278,10 +276,8 @@ class OusterPcap : public OusterSensorNodeBase {
std::shared_ptr<PcapReader> pcap;
ouster_sensor_msgs::msg::PacketMsg lidar_packet;
ouster_sensor_msgs::msg::PacketMsg imu_packet;
rclcpp_lifecycle::LifecyclePublisher<ouster_sensor_msgs::msg::PacketMsg>::SharedPtr
lidar_packet_pub;
rclcpp_lifecycle::LifecyclePublisher<ouster_sensor_msgs::msg::PacketMsg>::SharedPtr
imu_packet_pub;
rclcpp::Publisher<ouster_sensor_msgs::msg::PacketMsg>::SharedPtr lidar_packet_pub;
rclcpp::Publisher<ouster_sensor_msgs::msg::PacketMsg>::SharedPtr imu_packet_pub;

std::atomic<bool> packet_read_active = {false};
std::unique_ptr<std::thread> packet_read_thread;
Expand Down
5 changes: 2 additions & 3 deletions ouster-ros/src/os_sensor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,11 +769,10 @@ void OusterSensor::create_publishers() {

void OusterSensor::allocate_buffers() {
auto& pf = sensor::get_format(info);

lidar_packet_msg.buf.resize(pf.lidar_packet_size);
lidar_packet.buf.resize(pf.lidar_packet_size);
lidar_packet_msg.buf.resize(pf.lidar_packet_size);
imu_packet.buf.resize(pf.imu_packet_size);
imu_packet.buf.resize(pf.imu_packet_size);
imu_packet_msg.buf.resize(pf.imu_packet_size);
}

bool OusterSensor::init_id_changed(const sensor::packet_format& pf,
Expand Down

0 comments on commit 2822961

Please sign in to comment.