ROS. In the last 10s: depthimage_to_laserscan
浅记录几个ros图像相关的点。
(1)ros中针对图像传输,设计了专门的类,image_transport,处理图片的编解码和压缩问题,实现图片透明传输。
(2)image_transport类有两个子类可以创建图像订阅的话题。其中:
1)image_transport::create_subscription,普通的图片订阅功能;
2)image_transport::create_camera_subscription,比较复杂的图片订阅功能,包含了同步检查机制。传入要订阅的话题以后,会默认订阅同一个话题名下的camera_info话题(通过image_raw话题名/拆解,获得info话题名)。
同时,有一个同步滤波器:
内部开了三个订阅话题,分别订阅
camera_info;
image_raw;
以及一个捆绑话题:info+raw;
同步要求:单个话题的接收量不大于捆绑话题的3倍。
void checkImagesSynchronized()
{
77 int threshold = 3 * both_received_;
78 if (image_received_ > threshold || info_received_ > threshold) {}
并且,该订阅模式下,仅有捆绑话题接收到数据,才能触发用户传入的callback函数。
(具体,捆绑话题怎么触发,尚不清楚,猜测:间隔一定的时间段内的是否有两个话题的数据)
(3)详细的函数查询连接
https://docs.ros.org/en/kinetic/api/image_transport/html/camera__subscriber_8cpp_source.html
(4)camera_info的话题数据实际上是重复的,并不会每次更新。
(5)ROS2引入了服务质量策略(QOS),需要多加小心,话题发布与接收要设置同样的 qos,否则可能接收不到消息。
image_sub = image_transport::create_subscription(this,“camera/color/image_raw”,std::bind(&AprilTagNode::imageCallback, this, std::placeholders::_1),hints.getTransport(),rmw_qos_profile_sensor_data);