20 #include "../utility/TableHelper.hpp" 21 #include "../utility/GeometryHelper.hpp" 32 std::cerr <<
"stepNumber is < 1!" << std::endl;
37 std::ifstream source(sourceFile, std::fstream::binary);
38 std::ofstream target(targetFile, std::fstream::trunc|std::fstream::binary);
39 target << source.rdbuf();
44 targetHelper.
dropTable(
"recorded_objects");
54 while (from->objects.size() != 0 && to->objects.size() != 0)
56 std::cout <<
"Interpolating between object sets " << counter <<
" and " << counter + 1 <<
"..." << std::endl;
68 std::cout <<
"Finished!" << std::endl;
73 std::vector<PosePtr> result;
74 int divisor = stepNumber + 1;
79 Eigen::Vector3d interpolatedPosition;
80 Eigen::Quaterniond interpolatedQuat;
81 for (
int i = 1; i <= stepNumber; i++)
83 interpolatedPosition = fromPosition * (divisor - i)/divisor + toPosition * i/divisor;
84 interpolatedQuat = fromOrient.slerp((
double)i/divisor, toOrient);
93 std::vector<ObjectSetPtr> result;
95 for (
int i = 0; i < stepNumber; i++)
99 std::vector<PosePtr> interpolatedPoses;
102 for (
unsigned i = 0; i < from->objects.size(); i++)
104 interpolatedPoses =
interpolatePoses(from->objects.at(i)->pose, to->objects.at(i)->pose, stepNumber);
105 for (
unsigned j = 0; j < interpolatedPoses.size(); j++)
107 pose = interpolatedPoses.at(j);
108 interpolatedObject =
ObjectPtr(
new Object(*(from->objects.at(i).get())));
109 interpolatedObject->pose = pose;
110 result.at(j)->insert(interpolatedObject);
const ObjectSetPtr getRecordedObjectSet(int setId) const
static PointPtr vectorToPoint(const Eigen::Vector3d &v)
static Eigen::Quaternion< double > quatToEigenQuat(const QuaternionPtr &q)
void interpolate(const std::string &sourceFile, const std::string &targetFile, int stepNumber)
int insertRecordedObjectSet(const boost::shared_ptr< ObjectSet > &os, const std::string &patternName)
void dropTable(const std::string &tablename) const
std::vector< ObjectSetPtr > interpolateSets(const ObjectSetPtr from, const ObjectSetPtr to, const int stepNumber)
interpolate poses between two given ObjectSets
std::vector< PosePtr > interpolatePoses(PosePtr from, PosePtr to, int stepNumber)
interpolate poses between two given poses
boost::shared_ptr< ObjectSet > ObjectSetPtr
static Eigen::Vector3d pointToVector(const PointPtr &p)
boost::shared_ptr< Pose > PosePtr
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