【发布时间】:2018-10-13 11:49:42
【问题描述】:
我正在尝试将带有相机校准的 .yaml 文件中的信息解析为 ROS 中的“sensor_msgs::CameraInfo”消息。
我设法解析了 INT 和字符串,但是当我到达双向量/矩阵时遇到了问题。
这是我的代码:
sensor_msgs::CameraInfo yamlToCameraInfo(std::string leftOrRightCam)
{
YAML::Node camera_info_yaml = YAML::LoadFile(leftOrRightCam + ".yaml");
sensor_msgs::CameraInfo camera_info_msg;
camera_info_msg.width = camera_info_yaml["image_width"].as<uint32_t>();
camera_info_msg.height = camera_info_yaml["image_height"].as<uint32_t>();
camera_info_msg.distortion_model = camera_info_yaml["distortion_model"].as<std::string>();
camera_info_msg.D = camera_info_yaml["distortion_coefficients"].as<double>();
camera_info_msg.K = camera_info_yaml["camera_matrix"].as<double>();
return camera_info_msg;
}
我得到的错误是这样的:
错误:'operator=' 不匹配(操作数类型为 'sensor_msgs::CameraInfo_ >::_D_type {aka std::vector >}' 和 'double')
camera_info_msg.D = camera_info_yaml["distortion_coefficients"].as();
cameraInfo 消息的文档位于此处:http://docs.ros.org/api/sensor_msgs/html/msg/CameraInfo.html
yaml-cpp 包教程:https://github.com/jbeder/yaml-cpp/wiki/Tutorial
我的 yaml 文件 lokk 的“失真系数”部分如下所示:
失真系数:
行数:1
列:5
数据:[-0.167477, 0.023595, 0.004069, -0.002996, 0.000000]
有谁知道我做错了什么?
【问题讨论】:
-
这里的
distortion_coefficients节点是一张地图。我猜你需要遍历distortion_coefficients节点并获取项目