title: Qt-ros创建yaml文件
date: 2020-07-15 16:49:32
tags: 记录
写入文件
scan_pub.cpp
#include "ros/ros.h"
#include <yaml-cpp/yaml.h>
#include<fstream>
int main(int argc, char **argv)
{
ros::init(argc, argv, "scan_pub");
YAML::Node camera_config_nodes;
camera_config_nodes["width"] = 1920;
camera_config_nodes["height"] = 1080;
camera_config_nodes["cam0"]["intrinsics"][0] = 1000;
camera_config_nodes["cam0"]["intrinsics"][1] = 1000;
camera_config_nodes["cam0"]["intrinsics"][2] = 99;
camera_config_nodes["cam0"]["intrinsics"][3] = 0;
std::ofstream fout("/home/teabot/test/test1.yaml");
fout << camera_config_nodes;
fout.close();
while (ros::ok())
{
}
return 0;
}
CmakeLists.txt
add_executable(scan_pub src/scan_pub.cpp)
target_link_libraries(scan_pub ${catkin_LIBRARIES} yaml-cpp)
test1.yaml
width: 1920
height: 1080
cam0:
intrinsics:
- 1000
- 1000
- 99
- 0