0

I don't know why I am getting this error :

terminate called after throwing an instance of 'YAML::TypedBadConversion<double>'
what():  yaml-cpp: error at line 0, column 0: bad conversion
Aborted (core dumped)

I reduced my constant.yaml file to : MAX_FINGER_APERTURE: 0.120 And my code is as follows :

//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>();

Do you have any idea where that comes from ?

sduminy
  • 1
  • 1
  • What does your debugger say? – user3389943 Apr 01 '20 at 18:17
  • In particular, consider dumping the `YAML::Node` to stdout so you can make sure it's parsing the way you expect. – Jesse Beder Apr 01 '20 at 18:30
  • The error came from the fact that the program wasn't finding the right path. Parsing the yaml file as public member of my class and directly retrieve the constant variables solved the problem. – sduminy Apr 02 '20 at 23:33

1 Answers1

0

The error came from the fact that the program wasn't finding the right path. I was parsing the file in my class and then retrieving the constant variables in a method, so I think the link between the yaml node or the yaml path was broken in my method. Parsing the yaml file as public member of my class and directly retrieve the constant variables solved the problem.

sduminy
  • 1
  • 1