Skip to content
Snippets Groups Projects
Commit f171f5b5 authored by Fabian Reister's avatar Fabian Reister
Browse files

trajectory duration

parent afb6fb60
No related branches found
No related tags found
No related merge requests found
......@@ -585,8 +585,36 @@ namespace armarx::navigation::core
float
Trajectory::duration(const core::VelocityInterpolation interpolation) const
{
throw LocalException("not implemented yet");
return 0; // FIXME
float dur = 0;
for (int i = 0; i < static_cast<int>(pts.size() - 1); i++)
{
const auto& start = pts.at(i);
const auto& goal = pts.at(i + 1);
const float distance =
(goal.waypoint.pose.translation() - start.waypoint.pose.translation()).norm();
const float startVelocity = start.velocity;
const float goalVelocity = goal.velocity;
constexpr int nSamples = 100;
for(int j = 0; j < nSamples; j++)
{
const float progress = static_cast<float>(j) / nSamples;
const float v = startVelocity + progress * (goalVelocity - startVelocity);
const float s = distance / nSamples;
const float t = s / v;
dur += t;
}
}
return dur;
}
bool
......
......@@ -114,6 +114,7 @@ namespace armarx::navigation::core
*/
Indices allConnectedPointsInRange(std::size_t idx, float radius) const;
private:
std::vector<TrajectoryPoint> pts;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment