From b932e6d50cc46f36d8f018391d57f801e5271a9a Mon Sep 17 00:00:00 2001 From: Philipp Schmidt <ufedv@student.kit.edu> Date: Thu, 24 Nov 2016 12:57:57 +0100 Subject: [PATCH] fixed names in trajectory class and getpart returns ptr --- source/RobotAPI/libraries/core/Trajectory.cpp | 23 ++++++++++--------- source/RobotAPI/libraries/core/Trajectory.h | 6 ++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/source/RobotAPI/libraries/core/Trajectory.cpp b/source/RobotAPI/libraries/core/Trajectory.cpp index b0dbfb34e..ee7495af9 100644 --- a/source/RobotAPI/libraries/core/Trajectory.cpp +++ b/source/RobotAPI/libraries/core/Trajectory.cpp @@ -44,7 +44,7 @@ namespace armarx std::vector< DoubleSeqPtr >& data = it->data; DoubleSeqSeq new2DVec; new2DVec.reserve(data.size()); - for (DoubleSeqPtr & subVec : data) + for (DoubleSeqPtr& subVec : data) { if (subVec) { @@ -63,12 +63,12 @@ namespace armarx void Trajectory::ice_postUnmarshal() { int i = 0; - for (DoubleSeqSeq & _2DVec : dataVec) + for (DoubleSeqSeq& _2DVec : dataVec) { double t = timestamps.at(i); int d = 0; - for (auto & vec : _2DVec) + for (auto& vec : _2DVec) { setEntries(t, d++, vec); } @@ -425,9 +425,9 @@ namespace armarx return toEigen(derivation, begin()->getTimestamp(), rbegin()->getTimestamp()); } - Trajectory Trajectory::getPart(double startTime, double endTime, size_t numberOfDerivations) const + TrajectoryPtr Trajectory::getPart(double startTime, double endTime, size_t numberOfDerivations) const { - Trajectory result; + TrajectoryPtr result(new Trajectory()); const ordered_view& ordv = dataMap.get<TagOrdered>(); ordered_view::iterator itO = ordv.lower_bound(startTime); @@ -446,11 +446,11 @@ namespace armarx derivs.push_back(itO->getDeriv(d, i)); } - result.addDerivationsToDimension(d, itO->getTimestamp(), derivs); + result->addDerivationsToDimension(d, itO->getTimestamp(), derivs); } // result.addPositionsToDimension(d, itO->getTimestamp(), itO->getDeriv(d, 0)); } - + result->setDimensionNames(getDimensionNames()); return result; } @@ -1508,9 +1508,9 @@ namespace armarx for (size_t dim = 0; dim < source.dim(); dim++) { - destination.addDimension(source.getDimensionData(dim), timestamps, source.getDimensionName(dim)); + destination.addDimension(source.getDimensionData(dim), timestamps); } - + destination.setDimensionNames(source.getDimensionNames()); } void Trajectory::clear() @@ -1584,7 +1584,7 @@ namespace armarx Ice::DoubleSeq dimensionData = traj.getDimensionData(dim); normExampleTraj.addDimension(dimensionData, normTimestamps); } - + normExampleTraj.setDimensionNames(traj.getDimensionNames()); return normExampleTraj; @@ -1593,7 +1593,8 @@ namespace armarx TrajectoryPtr Trajectory::normalize(const double startTime, const double endTime) { Trajectory normTraj = NormalizeTimestamps(*this, startTime, endTime); - return new Trajectory(normTraj); + TrajectoryPtr newTraj = new Trajectory(normTraj); + return newTraj; } diff --git a/source/RobotAPI/libraries/core/Trajectory.h b/source/RobotAPI/libraries/core/Trajectory.h index 2eee73d30..e6805755c 100644 --- a/source/RobotAPI/libraries/core/Trajectory.h +++ b/source/RobotAPI/libraries/core/Trajectory.h @@ -100,7 +100,7 @@ namespace armarx timestamp = s.timestamp; data.resize(s.data.size()); int i = 0; - for (auto & elem : s.data) + for (auto& elem : s.data) { data[i++] = elem; } @@ -227,7 +227,7 @@ namespace armarx } const auto& tempTimestamps = timestamps.size() > 0 ? timestamps : GenerateTimestamps(data.at(0)); size_t i = 0; - for (const auto & subvec : data) + for (const auto& subvec : data) { Ice::DoubleSeq dvec(subvec.begin(), subvec.end()); addDimension(dvec, tempTimestamps, i < dimensionNames.size() ? dimensionNames.at(i++) : ""); @@ -311,7 +311,7 @@ namespace armarx Eigen::VectorXd getDimensionDataAsEigen(size_t dimension, size_t derivation, double startTime, double endTime) const; Eigen::MatrixXd toEigen(size_t derivation, double startTime, double endTime) const; Eigen::MatrixXd toEigen(size_t derivation = 0) const; - Trajectory getPart(double startTime, double endTime, size_t numberOfDerivations = 0) const; + TrajectoryPtr getPart(double startTime, double endTime, size_t numberOfDerivations = 0) const; /** * @brief dim returns the trajectory dimension count for this trajectory (e.g. taskspace w/o orientation would be 3) * @return -- GitLab