【发布时间】:2020-04-01 17:56:39
【问题描述】:
我不知道为什么会出现这个错误:
terminate called after throwing an instance of 'YAML::TypedBadConversion<double>'
what(): yaml-cpp: error at line 0, column 0: bad conversion
Aborted (core dumped)
我将我的 constant.yaml 文件缩减为:
MAX_FINGER_APERTURE: 0.120
我的代码如下:
//Path to the constants yaml file
std::string pkg_path = ros::package::getPath("frasier_motion");
std::string constants_path = pkg_path + "/config/constant.yaml";
YAML::Node constants = YAML::LoadFile(constants_path);
double MAX_FINGER_APERTURE = constants["MAX_FINGER_APERTURE"].as<double>();
你知道这是从哪里来的吗?
【问题讨论】:
-
你的调试器说什么?
-
特别是,考虑将
YAML::Node转储到标准输出,这样您就可以确保它以您期望的方式进行解析。 -
错误来自程序没有找到正确的路径。将yaml文件解析为我的类的公共成员并直接检索常量变量解决了问题。