Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retimePathWithKunz to Robot #505

Merged
merged 5 commits into from
Feb 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
* Robot

* Added Robot, Manipulator, Hand interfaces, and ConcreteRobot, ConcreteManipulator classes: [#325](https://github.com/personalrobotics/aikido/pull/325), [#392](https://github.com/personalrobotics/aikido/pull/392)
* Added Kunz timer to Robot class: [#505](https://github.com/personalrobotics/aikido/pull/505)

* RViz

Expand Down
7 changes: 7 additions & 0 deletions include/aikido/robot/ConcreteManipulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class ConcreteManipulator : public Manipulator
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path) override;

// Documentation inherited.
virtual std::unique_ptr<aikido::trajectory::Spline> retimePathWithKunz(
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path,
double maxDeviation,
double timestep) override;

// Documentation inherited.
virtual std::future<void> executeTrajectory(
const trajectory::TrajectoryPtr& trajectory) const override;
Expand Down
7 changes: 7 additions & 0 deletions include/aikido/robot/ConcreteRobot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ class ConcreteRobot : public Robot
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path) override;

// Documentation inherited.
virtual std::unique_ptr<aikido::trajectory::Spline> retimePathWithKunz(
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path,
double maxDeviation,
double timestep) override;

// Documentation inherited.
virtual std::future<void> executeTrajectory(
const trajectory::TrajectoryPtr& trajectory) const override;
Expand Down
12 changes: 12 additions & 0 deletions include/aikido/robot/Robot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ class Robot
const aikido::trajectory::Trajectory* path)
= 0;

/// Returns a timed trajectory computed with KunzRetimer
/// \param[in] metaSkeleton Metaskeleton of the path.
/// \param[in] path Geometric path to execute.
/// \param[in] maxDeviation Maximum deviation allowed from original path.
/// \param[in] timestep Time step between trajectory points.
virtual std::unique_ptr<aikido::trajectory::Spline> retimePathWithKunz(
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path,
double maxDeviation,
double timestep)
= 0;

/// Executes a trajectory
/// \param[in] trajectory Timed trajectory to execute
virtual std::future<void> executeTrajectory(
Expand Down
1 change: 1 addition & 0 deletions src/robot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_link_libraries("${PROJECT_NAME}_robot"
"${PROJECT_NAME}_planner"
"${PROJECT_NAME}_planner_ompl"
"${PROJECT_NAME}_planner_parabolic"
"${PROJECT_NAME}_planner_kunzretimer"
"${PROJECT_NAME}_planner_vectorfield"
"${PROJECT_NAME}_constraint"
"${PROJECT_NAME}_distance"
Expand Down
11 changes: 11 additions & 0 deletions src/robot/ConcreteManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ std::unique_ptr<aikido::trajectory::Spline> ConcreteManipulator::retimePath(
return mRobot->retimePath(metaSkeleton, path);
}

//==============================================================================
std::unique_ptr<aikido::trajectory::Spline>
ConcreteManipulator::retimePathWithKunz(
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path,
double maxDeviation,
double timestep)
{
return mRobot->retimePathWithKunz(metaSkeleton, path, maxDeviation, timestep);
}

//==============================================================================
std::future<void> ConcreteManipulator::executeTrajectory(
const trajectory::TrajectoryPtr& trajectory) const
Expand Down
25 changes: 25 additions & 0 deletions src/robot/ConcreteRobot.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "aikido/robot/ConcreteRobot.hpp"
#include "aikido/constraint/TestableIntersection.hpp"
#include "aikido/planner/kunzretimer/KunzRetimer.hpp"
#include "aikido/robot/util.hpp"
#include "aikido/statespace/StateSpace.hpp"

Expand All @@ -11,6 +12,7 @@ using constraint::dart::TSRPtr;
using constraint::TestablePtr;
using constraint::ConstTestablePtr;
using planner::TrajectoryPostProcessor;
using planner::kunzretimer::KunzRetimer;
using planner::parabolic::ParabolicSmoother;
using planner::parabolic::ParabolicTimer;
using statespace::dart::MetaSkeletonStateSpace;
Expand Down Expand Up @@ -161,6 +163,29 @@ UniqueSplinePtr ConcreteRobot::retimePath(
throw std::invalid_argument("Path should be either Spline or Interpolated.");
}

//==============================================================================
UniqueSplinePtr ConcreteRobot::retimePathWithKunz(
const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const aikido::trajectory::Trajectory* path,
double maxDeviation,
double timestep)
{
Eigen::VectorXd velocityLimits = getVelocityLimits(*metaSkeleton);
Eigen::VectorXd accelerationLimits = getAccelerationLimits(*metaSkeleton);
auto retimer = std::make_shared<KunzRetimer>(
velocityLimits, accelerationLimits, maxDeviation, timestep);

auto interpolated = dynamic_cast<const Interpolated*>(path);
if (interpolated)
return retimer->postprocess(*interpolated, *(cloneRNG().get()));

auto spline = dynamic_cast<const Spline*>(path);
if (spline)
return retimer->postprocess(*spline, *(cloneRNG().get()));

throw std::invalid_argument("Path should be either Spline or Interpolated.");
}

//==============================================================================
std::future<void> ConcreteRobot::executeTrajectory(
const TrajectoryPtr& trajectory) const
Expand Down