24 #include <boost/algorithm/string.hpp> 35 myfile.open (this->
filePath, std::ofstream::out | std::ofstream::app);
38 Eigen::Matrix3d rotation = tr.rotation();
44 Eigen::Quaterniond quaternion(rotation);
46 myfile << quaternion.x() <<
"; " << quaternion.y() <<
"; " << quaternion.z() <<
"; " << quaternion.w() <<
"; " << translation[0] <<
"; " << translation[1] <<
"; " << translation[2]<<
"; ";
56 myfile << data.
pan <<
"; " << data.
tilt << std::endl;
65 std::vector<Transformation_Data> output;
66 std::ifstream input(filePath);
68 unsigned int lineNumber = 1;
69 while(std::getline( input, line ))
71 std::vector<std::string> strs;
72 boost::split(strs, line, boost::is_any_of(
";"));
75 std::vector<double> numericValues;
77 for (
unsigned int i = 0; i < strs.size(); i++)
81 std::string temp = strs.at(i);
82 boost::algorithm::trim(temp);
83 numericValues.push_back(boost::lexical_cast<double>(temp));
85 catch (boost::bad_lexical_cast
const&)
87 ROS_ERROR_STREAM(
"Line " << lineNumber <<
": " <<strs.at(i) <<
" is not a number.");
94 Eigen::Affine3d rotation(Eigen::Quaterniond(numericValues.at(3),numericValues.at(0),numericValues.at(1),numericValues.at(2)));
98 Eigen::Affine3d translation(Eigen::Translation3d(Eigen::Vector3d(numericValues.at(4),numericValues.at(5),numericValues.at(6))));
99 Eigen::Affine3d transformation = translation * rotation;
101 data.
PTU_Frame = transformation.matrix();
102 data.
pan = numericValues.at(7);
103 data.
tilt = numericValues.at(8);
104 output.push_back(data);
109 ROS_ERROR_STREAM(
"Line " << lineNumber <<
": Expected 8 items, got " << strs.size());
119 std::vector<Eigen::Matrix4d, Eigen::aligned_allocator<Eigen::Matrix4d>> output;
120 std::ifstream input(filePath);
122 unsigned int lineNumber = 1;
123 while(std::getline( input, line ))
125 std::vector<std::string> strs;
126 boost::split(strs, line, boost::is_any_of(
";"));
127 if (strs.size() == 7)
129 std::vector<double> numericValues;
131 for (
unsigned int i = 0; i < strs.size(); i++)
135 std::string temp = strs.at(i);
136 boost::algorithm::trim(temp);
137 numericValues.push_back(boost::lexical_cast<double>(temp));
139 catch (boost::bad_lexical_cast
const&)
141 ROS_ERROR_STREAM(
"Line " << lineNumber <<
": " <<strs.at(i) <<
" is not a number.");
148 Eigen::Affine3d rotation(Eigen::Quaterniond(numericValues.at(3),numericValues.at(0),numericValues.at(1),numericValues.at(2)));
152 Eigen::Affine3d translation(Eigen::Translation3d(Eigen::Vector3d(numericValues.at(4),numericValues.at(5),numericValues.at(6))));
153 Eigen::Affine3d transformation = rotation * translation;
154 Eigen::Matrix4d data;
155 data = transformation.matrix();
156 output.push_back(data);
161 ROS_ERROR_STREAM(
"Line " << lineNumber <<
": Expected 7 items, got " << strs.size());
172 myfile.open (this->
filePath, std::ofstream::out | std::ofstream::app);
173 for (
unsigned int i = 0; i < transformation.size(); i++)
176 Eigen::Matrix4d temp = transformation.at(i);
177 Eigen::Affine3d tr(temp);
178 Eigen::Matrix3d rotation = tr.rotation();
179 Eigen::Quaterniond quaternion(rotation);
180 Eigen::Vector3d translation(Eigen::Vector3d(temp(0, 3), temp(1, 3), temp(2, 3)));
182 myfile << quaternion.x() <<
"; " << quaternion.y() <<
"; " << quaternion.z() <<
"; " << quaternion.w() <<
"; " << translation[0] <<
"; " << translation[1] <<
"; " << translation[2] << std::endl;
200 myfile.open (this->
filePath, std::ofstream::out | std::ofstream::app);
201 for (
unsigned int i = 0; i < offsetData.size(); i++)
204 double pan = std::get<0>(currentTuple);
205 double tilt = std::get<1>(currentTuple);
206 Eigen::Matrix4d temp = std::get<2>(currentTuple);
207 Eigen::Matrix4d tempOld = std::get<3>(currentTuple);
209 myfile << pan <<
"; " << tilt <<
"; " << temp(0,3) <<
"; " << temp(1,3) <<
"; " << temp(2,3) <<
"; "<< tempOld(0,3) <<
"; " << tempOld(1,3) <<
"; " << tempOld(2,3) <<
"; " << std::endl;
#define ROS_ERROR_STREAM(args)