添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.