Zejiang Zeng
Zejiang Zeng

Reputation: 13

Getting error : YAML::TypedBadConversion<double>'

I was trying to convert the camera info from a yaml file to sensor_msgs/CameraInfo. The yaml file was loaded successfully. And the error occurs when trying to get the distortion coefficient value :

YAML::Node conf = YAML::LoadFile(yaml_file); 
std::vector<double> dd;
dd = conf["distortion_coefficients"]["data"].as<std::vector<double> >();

And the error is like: " terminat called after throwing an instance of

'YAML::TypedBadConversion' what(): yaml-cpp: error at line 0, column 0: bad conversion "

My YAML file for distortion_coefficients is like

distortion_coefficients:   
  rows: 1  
  cols: 5  
  data: [0.013750 -0.162804 0.008105 0.002423 0.000000]

Any idea how to solve it?

Upvotes: 1

Views: 3925

Answers (1)

Jesse Beder
Jesse Beder

Reputation: 34044

Your data doesn't have any commas separating the values, so it can't be read as a sequence of numbers.

If you change it to

distortion_coefficients:   
  rows: 1  
  cols: 5  
  data: [0.013750, -0.162804, 0.008105, 0.002423, 0.000000]

then it should work as expected.

Upvotes: 1

Related Questions