Realsense相机驱动在使用imu数据时出现Qos问题,报错如下:
bash
[camera.camera]: New subscription discovered on topic '/camera/camera/imu', requesting incompatible QoS. No messages will be sent to it. Last incompatible policy: RELIABILITY_QOS_POLICY
解决
对驱动源码https://github.com/IntelRealSense/realsense-ros/blob/ros2-development/realsense2_camera/src/rs_node_setup.cpp
的以下位置进行修改:
源码:
cpp
if (_is_accel_enabled && _is_gyro_enabled && (_imu_sync_method > imu_sync_method::NONE))
{
rmw_qos_profile_t qos = _use_intra_process ? qos_string_to_qos(DEFAULT_QOS) : qos_string_to_qos(HID_QOS);
_synced_imu_publisher = std::make_shared<SyncedImuPublisher>(_node.create_publisher<sensor_msgs::msg::Imu>("~/imu",
rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos), qos)));
}
修改:
cpp
if (_is_accel_enabled && _is_gyro_enabled && (_imu_sync_method > imu_sync_method::NONE))
{
// changed 20241028
rmw_qos_profile_t qos;
qos = rmw_qos_profile_default;
qos.depth = 20;
// delete 20241028
//rmw_qos_profile_t qos = _use_intra_process ? qos_string_to_qos(DEFAULT_QOS) : qos_string_to_qos(HID_QOS);
_synced_imu_publisher = std::make_shared<SyncedImuPublisher>(_node.create_publisher<sensor_msgs::msg::Imu>("~/imu",
rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos), qos)));
}