transformationfile_manager_XML.cpp
Go to the documentation of this file.
1 
19 #include <iostream>
20 #include <fstream>
21 #include <string>
22 #include <ros/ros.h>
23 #ifndef Q_MOC_RUN
24 #include <boost/foreach.hpp>
25 #include <boost/property_tree/ptree.hpp>
26 #include <boost/property_tree/xml_parser.hpp>
27 #endif
28 
29 using namespace std;
30 
32 
34 {
35  boost::property_tree::ptree pt;
36  ifstream infile(this->filePath);
37  if (infile.good()) boost::property_tree::read_xml(this->filePath, pt); //If file exists, append new data
38 
39  boost::property_tree::ptree dataNode;
40  boost::property_tree::ptree transformLaserScan_Node;
41  boost::property_tree::ptree transformPTU_Node;
42 
43  dataNode.put<double>("<xmlattr>.Pan", data.pan);
44  dataNode.put<double>("<xmlattr>.Tilt", data.tilt);
45 
46  for (unsigned int i = 0; i < 4; i++)
47  {
48  for (unsigned int j = 0; j < 4; j++)
49  {
50  std::string name = "<xmlattr>.x_" + std::to_string(i) + std::to_string(j);
51  transformLaserScan_Node.put<double>(name, data.LaserScan_Frame(i,j));
52  transformPTU_Node.put<double>(name, data.PTU_Frame(i,j));
53  }
54  }
55  dataNode.add_child("FrameLaserscan", transformLaserScan_Node);
56  dataNode.add_child("FramePTU", transformPTU_Node);
57  pt.add_child("TransformationData.DataSet", dataNode);
58  //boost::property_tree::xml_writer_settings<char> settings('\t', 1);
59  boost::property_tree::write_xml(this->filePath, pt,std::locale());
60  return true;
61 }
62 
63 std::vector<Transformation_Data> TransformationFile_Manager_XML::readFromFile(string filePath)
64 {
65  std::vector<Transformation_Data> output;
66  boost::property_tree::ptree pt;
67  //open the archive
68  read_xml(filePath, pt);
69 
70  BOOST_FOREACH(boost::property_tree::ptree::value_type &node, pt.get_child("TransformationData"))
71  {
72  if (node.first == "DataSet")
73  {
75  data.pan = node.second.get<double>("<xmlattr>.Pan");
76  data.tilt = node.second.get<double>("<xmlattr>.Tilt");
77  boost::property_tree::ptree transformLaserScan_Node = node.second.get_child("FrameLaserscan");
78  boost::property_tree::ptree transformPTU_Node = node.second.get_child("FramePTU");
79  for (unsigned int i = 0; i < 4; i++)
80  {
81  for (unsigned int j = 0; j < 4; j++)
82  {
83  std::string name = "<xmlattr>.x_" + std::to_string(i) + std::to_string(j);
84  data.LaserScan_Frame(i, j) = transformLaserScan_Node.get<double>(name);
85  data.PTU_Frame(i, j) = transformPTU_Node.get<double>(name);
86  }
87  }
88  output.push_back(data);
89  }
90  }
91  return output;
92 }
93 
94 std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d>> TransformationFile_Manager_XML::readTransformationFromFile(string filePath)
95 {
96  std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d>> re;
97  return re;
98 }
99 
100 bool TransformationFile_Manager_XML::writeTransformationToFile(const std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d>> transformation)
101 {
102  return false;
103 }
104 
106 {
107  return true;
108 }
bool writeCameraOffsetToFile(const PanTiltOffsetTupleList &offsetData)
std::vector< PanTiltOffsetTuple, Eigen::aligned_allocator< Eigen::Vector4f > > PanTiltOffsetTupleList
bool writeTransformationToFile(const std::vector< Eigen::Matrix4d, Eigen::aligned_allocator< Eigen::Matrix4d >> transformation)
bool writeToFile(Transformation_Data data)
std::vector< Eigen::Matrix4d, Eigen::aligned_allocator< Eigen::Matrix4d > > readTransformationFromFile(string filePath)
Eigen::Matrix4d PTU_Frame
std::vector< Transformation_Data > readFromFile()
Eigen::Matrix4d LaserScan_Frame


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Mon Dec 2 2019 03:11:43