MarkerRotator.hpp
Go to the documentation of this file.
1 
19 #pragma once
20 
21 #include "../utility/TableHelper.hpp"
22 #include "../utility/GeometryHelper.hpp"
23 
24 #include <string>
25 #include <vector>
26 #include <fstream>
27 
28 
29 namespace ISM
30 {
31 
36 {
37  public:
38 
42  void rotateMarker(const std::string& sourceFile, const std::string& targetFile)
43  {
44  // copy source to target, so that only the copy will be modified
45  std::ifstream source(sourceFile, std::fstream::binary);
46  std::ofstream target(targetFile, std::fstream::trunc|std::fstream::binary);
47  target << source.rdbuf();
48 
49  TableHelper helper(targetFile);
50  std::vector<std::pair<int, ObjectPtr>> objectsWithDbIds = helper.getAllMarkerObjects();
51  std::cout << "Objects count: " << objectsWithDbIds.size() << std::endl;
52  Eigen::Quaterniond eigenQuat;
53  Eigen::Matrix3d A, B, C;
54  for (std::pair<int, ObjectPtr> objectPair : objectsWithDbIds)
55  {
56  ObjectPtr object = objectPair.second;
57  std::cout << objectPair.first << ": " << object->type << std::endl;
58  eigenQuat = GeometryHelper::quatToEigenQuat(object->pose->quat);
59  A = eigenQuat.toRotationMatrix();
60  B = Eigen::AngleAxisd(0.5 * M_PI, Eigen::Vector3d::UnitX())
61  * Eigen::AngleAxisd(0, Eigen::Vector3d::UnitY())
62  * Eigen::AngleAxisd(0, Eigen::Vector3d::UnitZ());
63  std::cout << B << std::endl;
64  C = A * B;
65  object->pose->quat = GeometryHelper::eigenQuatToQuat(Eigen::Quaterniond(C));
66  helper.updateObjectQuaternion(objectPair.first, object);
67  }
68  }
69 };
70 }
static Eigen::Quaternion< double > quatToEigenQuat(const QuaternionPtr &q)
const std::vector< std::pair< int, ObjectPtr > > getAllMarkerObjects()
void rotateMarker(const std::string &sourceFile, const std::string &targetFile)
this namespace contains all generally usable classes.
static QuaternionPtr eigenQuatToQuat(const Eigen::Quaternion< double > &q)
boost::shared_ptr< Object > ObjectPtr
Definition: Object.hpp:82
int updateObjectQuaternion(int dbId, ObjectPtr object)


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40