Skip to content

Commit b897430

Browse files
authored
Merge pull request #162 from namiota/ros-queue-length-as-param
Added ros_queue_length parameter
2 parents b8fe130 + 0c6f441 commit b897430

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

config/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ lidar:
4141
ros_send_packet_topic: /rslidar_packets #Topic used to send lidar packets through ROS
4242
ros_send_imu_data_topic: /rslidar_imu_data #Topic used to send imu data through ROS
4343
ros_send_point_cloud_topic: /rslidar_points #Topic used to send point cloud through ROS
44+
ros_queue_length: 100 #Topic QoS history depth

src/source/source_packet_ros.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,15 @@ inline void DestinationPacketRos::init(const YAML::Node& config)
326326
yamlRead<std::string>(config["ros"], "ros_send_packet_topic",
327327
ros_send_topic, "rslidar_packets");
328328

329+
size_t ros_queue_length;
330+
yamlRead<size_t>(config["ros"], "ros_queue_length", ros_queue_length, 100);
331+
329332
static int node_index = 0;
330333
std::stringstream node_name;
331334
node_name << "rslidar_packets_destination_" << node_index++;
332335

333336
node_ptr_.reset(new rclcpp::Node(node_name.str()));
334-
pkt_pub_ = node_ptr_->create_publisher<rslidar_msg::msg::RslidarPacket>(ros_send_topic, 100);
337+
pkt_pub_ = node_ptr_->create_publisher<rslidar_msg::msg::RslidarPacket>(ros_send_topic, ros_queue_length);
335338
}
336339

337340
inline void DestinationPacketRos::sendPacket(const Packet& msg)

src/source/source_pointcloud_ros.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,24 @@ inline void DestinationPointCloudRos::init(const YAML::Node& config)
464464
yamlRead<std::string>(config["ros"],
465465
"ros_send_point_cloud_topic", ros_send_topic, "rslidar_points");
466466

467+
size_t ros_queue_length;
468+
yamlRead<size_t>(config["ros"], "ros_queue_length", ros_queue_length, 100);
467469

468470
static int node_index = 0;
469471
std::stringstream node_name;
470472
node_name << "rslidar_points_destination_" << node_index++;
471473

472474
node_ptr_.reset(new rclcpp::Node(node_name.str()));
473-
pub_ = node_ptr_->create_publisher<sensor_msgs::msg::PointCloud2>(ros_send_topic, 100);
475+
476+
pub_ = node_ptr_->create_publisher<sensor_msgs::msg::PointCloud2>(ros_send_topic, ros_queue_length);
474477

475478
#ifdef ENABLE_IMU_DATA_PARSE
476479
std::string ros_send_imu_data_topic;
477480
yamlRead<std::string>(config["ros"],
478481
"ros_send_imu_data_topic", ros_send_imu_data_topic, "rslidar_imu_data");
479482
imu_pub_ = node_ptr_->create_publisher<sensor_msgs::msg::Imu>(ros_send_imu_data_topic, 1000);
480483
#endif
484+
481485
}
482486

483487
inline void DestinationPointCloudRos::sendPointCloud(const LidarPointCloudMsg& msg)

0 commit comments

Comments
 (0)