20 #include "../utility/TableHelper.hpp" 21 #include "../utility/GeometryHelper.hpp" 32 std::ifstream source(sourceFile, std::fstream::binary);
33 std::ofstream target(targetFile, std::fstream::trunc|std::fstream::binary);
34 target << source.rdbuf();
39 targetHelper.
dropTable(
"recorded_objects");
47 while (currentSet->objects.size() != 0)
49 std::cout <<
"Processing object set " << counter <<
"..." << std::endl;
67 Eigen::Vector3d rotationAxis = objectAxis.cross(referenceAxis);
68 rotationAxis.normalize();
72 return Eigen::AngleAxisd(0, unitAxis);
74 else if (fabs(angle - M_PI) < 0.001)
76 return Eigen::AngleAxisd(M_PI, unitAxis);
80 return Eigen::AngleAxisd(angle, rotationAxis);
87 Eigen::Quaterniond orientationRef = quat;
88 Eigen::Vector3d yUnitVector = yUnitVector = Eigen::Vector3d::UnitY();
89 orientationRef.normalize();
93 if (std::find(rotationInvariantTypes.begin(), rotationInvariantTypes.end(),
object->type) != rotationInvariantTypes.end())
96 orientation.normalize();
99 Eigen::AngleAxisd yTransform =
calculateTransform(objYAxis, refYAxis, Eigen::Vector3d::UnitX());
100 Eigen::Quaterniond yAlignedOrientation = (yTransform * orientation).normalized();
103 object->pose->quat->eigen = (yTransform.inverse() *
calculateTransform(objXAxis, refXAxis, Eigen::Vector3d::UnitY())).normalized() * yAlignedOrientation;
110 std::vector<ObjectPtr> objects = oset->objects;
112 for (
unsigned int i = 0; i < objects.size(); i++)
114 currentObject = objects.at(i);
115 if ((currentObject->type == type) && (currentObject->observedId ==
id))
117 std::cout <<
"Found reference object." << std::endl;
118 return currentObject;
121 std::cerr <<
"Reference object is missing in current Object set" << std::endl;
const ObjectSetPtr getRecordedObjectSet(int setId) const
Eigen::AngleAxisd calculateTransform(const Eigen::Vector3d &objectAxis, const Eigen::Vector3d &referenceAxis, const Eigen::Vector3d &unitAxis)
calculateTransform Calculate transform between two axis
static Eigen::Vector3d getAxisFromQuat(const QuaternionPtr &quat, const Eigen::Vector3d &viewport=Eigen::Vector3d::UnitX())
static Eigen::Quaternion< double > quatToEigenQuat(const QuaternionPtr &q)
void rotateRotationInvariantObjects(const std::string &sourceFile, const std::string &targetFile, const std::string &objectType, const std::string &objectId, bool useMapFrame, const std::vector< std::string > &rotationInvariantTypes)
int insertRecordedObjectSet(const boost::shared_ptr< ObjectSet > &os, const std::string &patternName)
static double getAngleBetweenAxes(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
void dropTable(const std::string &tablename) const
ObjectPtr getReferenceObject(ObjectSetPtr oset, const std::string &type, const std::string &id)
getReferenceObject Search for reference object in a set
void normalizeRotationInvarienceObjects(ISM::ObjectSetPtr objectSet, Eigen::Quaterniond quat, const std::vector< std::string > &rotationInvariantTypes)
normalizeRotationInvarienceObjects Rotate CS of rotation invariant objects in an object set...
boost::shared_ptr< ObjectSet > ObjectSetPtr
std::vector< std::string > getRecordedPatternNames() const
void createTablesIfNecessary() const
this namespace contains all generally usable classes.
static QuaternionPtr eigenQuatToQuat(const Eigen::Quaternion< double > &q)
boost::shared_ptr< Object > ObjectPtr