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

Merging changes from the Summer 2019 ADA Demo #542

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion include/aikido/common/detail/memory-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace aikido {
namespace common {

//==============================================================================
template<typename T, typename... Args>
template <typename T, typename... Args>
::std::unique_ptr<T> make_unique(Args&&... args)
{
#if __cplusplus < 201300
Expand Down
2 changes: 1 addition & 1 deletion include/aikido/io/detail/yaml_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <sstream>
#include <unordered_map>
#include <Eigen/Dense>
#include "aikido/common/memory.hpp"
#include <yaml-cpp/yaml.h>
#include "aikido/common/memory.hpp"

namespace aikido {
namespace io {
Expand Down
4 changes: 2 additions & 2 deletions include/aikido/rviz.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "rviz/BodyNodeMarker.hpp"
#include "rviz/FrameMarker.hpp"
#include "rviz/InteractiveMarkerViewer.hpp"
#include "rviz/pointers.hpp"
#include "rviz/ResourceServer.hpp"
#include "rviz/shape_conversions.hpp"
#include "rviz/ShapeFrameMarker.hpp"
#include "rviz/SkeletonMarker.hpp"
#include "rviz/TSRMarker.hpp"
#include "rviz/WorldInteractiveMarkerViewer.hpp"
#include "rviz/pointers.hpp"
#include "rviz/shape_conversions.hpp"
7 changes: 6 additions & 1 deletion include/aikido/trajectory/util.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef AIKIDO_TRAJECTORY_UTIL_HPP_
#define AIKIDO_TRAJECTORY_UTIL_HPP_

#include <dart/dart.hpp>
#include "aikido/statespace/dart/MetaSkeletonStateSpace.hpp"
#include "aikido/trajectory/Interpolated.hpp"
#include "aikido/trajectory/Spline.hpp"

Expand Down Expand Up @@ -46,10 +48,13 @@ UniqueInterpolatedPtr concatenate(
/// \param[in] traj Input trajectory
/// \param[in] referenceState Reference state
/// \param[in] timeStep Time step in finding the closest state
/// \param[out] distance Distance to the closest state
/// \return The time of the closest state on the input trajectory
double findTimeOfClosestStateOnTrajectory(
const Trajectory& traj,
const Eigen::VectorXd& referenceState,
const ::dart::dynamics::MetaSkeletonPtr& metaSkeleton,
const statespace::StateSpace::State* referenceState,
double& distance,
double timeStep = 0.01);

/// Retrieves part of a given spline trajectory
Expand Down
23 changes: 16 additions & 7 deletions src/constraint/dart/CollisionFree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,22 @@ statespace::ConstStateSpacePtr CollisionFree::getStateSpace() const
//==============================================================================
bool CollisionFree::isSatisfied(
const aikido::statespace::StateSpace::State* _state,
TestableOutcome* outcome) const
__attribute__((unused)) TestableOutcome* outcome) const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be deleted (or at least the parameter name, if we're not using it)?

{
// CollisionFreeOutcome* collisionFreeOutcome
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be deleted?

// = dynamic_cast_or_throw<CollisionFreeOutcome>(outcome);

// if (collisionFreeOutcome)
// {
// collisionFreeOutcome->clear();
// }
// else
// {
// collisionFreeOutcome = new CollisionFreeOutcome();
// }
auto _outcome = this->createOutcome();
auto collisionFreeOutcome
= dynamic_cast_or_throw<CollisionFreeOutcome>(outcome);

if (collisionFreeOutcome)
{
collisionFreeOutcome->clear();
}
= dynamic_cast<CollisionFreeOutcome*>(_outcome.get());

auto skelStatePtr = static_cast<const aikido::statespace::dart::
MetaSkeletonStateSpace::State*>(_state);
Expand All @@ -65,6 +72,7 @@ bool CollisionFree::isSatisfied(
{
collisionFreeOutcome->mPairwiseContacts = collisionResult.getContacts();
}
std::cout << collisionFreeOutcome->toString() << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for debugging?

return false;
}
}
Expand All @@ -79,6 +87,7 @@ bool CollisionFree::isSatisfied(
{
collisionFreeOutcome->mSelfContacts = collisionResult.getContacts();
}
std::cout << collisionFreeOutcome->toString() << std::endl;
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/constraint/dart/InverseKinematicsSampleable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ bool IkSampleGenerator::sample(statespace::StateSpace::State* _state)

mInverseKinematics->getTarget()->setTransform(poseState.getIsometry());

// Run the IK solver. If an exact solution is computed, apply it to the skeleton.
// Run the IK solver. If an exact solution is computed, apply it to the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this comment inside the #if? Would that help the formatter put it at the right indentation level?

// skeleton.
#if DART_VERSION_AT_LEAST(6, 8, 0)
if (mInverseKinematics->solveAndApply(true))
#else
Expand Down
2 changes: 1 addition & 1 deletion src/constraint/dart/TSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <vector>
#include <boost/format.hpp>
#include <dart/common/Console.hpp>
#include "aikido/common/memory.hpp"
#include <dart/math/Geometry.hpp>
#include "aikido/common/memory.hpp"

#undef dtwarn
#define dtwarn (::dart::common::colorErr("Warning", __FILE__, __LINE__, 33))
Expand Down
1 change: 1 addition & 0 deletions src/control/KinematicSimulationTrajectoryExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void KinematicSimulationTrajectoryExecutor::step(
// Check if trajectory has completed.
if (executionTime >= mTraj->getEndTime())
{
std::cout << "Trajectory completed" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

mTraj.reset();
mStateSpace.reset();
mMetaSkeleton.reset();
Expand Down
59 changes: 51 additions & 8 deletions src/control/ros/Conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
#include "aikido/control/ros/Conversions.hpp"
#include "aikido/statespace/dart/RnJoint.hpp"
#include "aikido/statespace/dart/SO2Joint.hpp"
#include "aikido/trajectory/Interpolated.hpp"

using aikido::statespace::CartesianProduct;
using aikido::statespace::dart::MetaSkeletonStateSpace;
using SplineTrajectory = aikido::trajectory::Spline;
using aikido::statespace::dart::R1Joint;
using aikido::statespace::dart::SO2Joint;
using aikido::statespace::InterpolatorPtr;

namespace aikido {
namespace control {
Expand Down Expand Up @@ -96,13 +98,20 @@ void extractJointTrajectoryPoint(
/// Extract a state on the trajectory given a timepoint.
/// \param[in] space MetaSkeletonStateSpace of the trajectory.
/// \param[in] trajectory Trajectory to extract point from.
/// \param[in] interpolator Interpolator used to maintain continuity in
/// extraction.
/// \param[in] timeFromStart Timepoint to extract trajectory point at.
/// \param[out] waypoint The extracted trajectory point.
/// \param[in] waypoint The extracted trajectory point.
/// \param[in] previousPoint Previously extracted trajectory point to
/// ensure continuity in representation when extracting multiple points.
/// Set to zero vector if not required.
void extractTrajectoryPoint(
const std::shared_ptr<const MetaSkeletonStateSpace>& space,
const aikido::trajectory::ConstTrajectoryPtr& trajectory,
const aikido::statespace::InterpolatorPtr& interpolator,
double timeFromStart,
trajectory_msgs::JointTrajectoryPoint& waypoint);
trajectory_msgs::JointTrajectoryPoint& waypoint,
Eigen::VectorXd& previousPoint);

//==============================================================================
void reorder(
Expand Down Expand Up @@ -255,8 +264,10 @@ void extractJointTrajectoryPoint(
void extractTrajectoryPoint(
const std::shared_ptr<const MetaSkeletonStateSpace>& space,
const aikido::trajectory::ConstTrajectoryPtr& trajectory,
const aikido::statespace::InterpolatorPtr& interpolator,
double timeFromStart,
trajectory_msgs::JointTrajectoryPoint& waypoint)
trajectory_msgs::JointTrajectoryPoint& waypoint,
Eigen::VectorXd& previousPoint)
{
const auto numDerivatives = std::min<int>(trajectory->getNumDerivatives(), 1);
const auto timeAbsolute = trajectory->getStartTime() + timeFromStart;
Expand All @@ -265,8 +276,29 @@ void extractTrajectoryPoint(

Eigen::VectorXd tangentVector;
auto state = space->createState();

auto prevState = space->createState();
space->convertPositionsToState(previousPoint, prevState);

trajectory->evaluate(timeAbsolute, state);
space->logMap(state, tangentVector);
space->convertStateToPositions(state, tangentVector);

auto geodesicInterpolator
= std::dynamic_pointer_cast<aikido::statespace::GeodesicInterpolator>(
interpolator);
if (!geodesicInterpolator)
{
throw std::invalid_argument(
"The interpolator of trajectory should be a GeodesicInterpolator");
}

auto diff = geodesicInterpolator->getTangentVector(prevState, state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this seems to all be part of the SO(2) and R1 conversion that was originally part of #496. AVK and I decided at the time to address this in rewd_controllers instead (personalrobotics/rewd_controllers#30). Has that changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brianhou It probably hasn't. Some of these changes may be holdovers from an earlier branch. I'm actually considering completely abandoning this branch, as it seems a lot of the changes are redundant.

tangentVector = previousPoint + diff;

for (int i = 0; i < tangentVector.size(); ++i)
{
previousPoint(i) = tangentVector(i);
}

assert(tangentVector.size() == numDof);

Expand Down Expand Up @@ -583,14 +615,25 @@ trajectory_msgs::JointTrajectory toRosJointTrajectory(
jointTrajectory.joint_names.emplace_back(jointDofName);
}

Eigen::VectorXd previousPoint(Eigen::VectorXd::Zero(space->getDimension()));

// Evaluate trajectory at each timestep and insert it into jointTrajectory
jointTrajectory.points.reserve(numWaypoints);
for (const auto& timeFromStart : timeSequence)
{
trajectory_msgs::JointTrajectoryPoint waypoint;

extractTrajectoryPoint(space, trajectory, timeFromStart, waypoint);
// Create the geodesic interpolator used to extract trajectory points.
auto interpolator
= std::make_shared<aikido::statespace::GeodesicInterpolator>(space);

for (std::size_t i = 0; i < numWaypoints; ++i)
{
trajectory_msgs::JointTrajectoryPoint waypoint;
extractTrajectoryPoint(
space,
trajectory,
interpolator,
timeSequence[i],
waypoint,
previousPoint);
jointTrajectory.points.emplace_back(waypoint);
}

Expand Down
1 change: 1 addition & 0 deletions src/control/ros/RosTrajectoryExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ std::future<void> RosTrajectoryExecutor::execute(
goal,
boost::bind(&RosTrajectoryExecutor::transitionCallback, this, _1));

std::cout << "Returning future" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete?

return mPromise->get_future();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/planner/SnapConfigurationToConfigurationPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "aikido/common/VanDerCorput.hpp"
#include "aikido/constraint/Testable.hpp"
#include "aikido/constraint/dart/CollisionFreeOutcome.hpp"
#include "aikido/statespace/StateSpace.hpp"

namespace aikido {
Expand Down Expand Up @@ -37,6 +38,7 @@ trajectory::TrajectoryPtr SnapConfigurationToConfigurationPlanner::plan(
auto constraint = problem.getConstraint();

aikido::common::VanDerCorput vdc{1, true, true, 0.02}; // TODO junk resolution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete?

for (const auto alpha : vdc)
{
mInterpolator->interpolate(startState, goalState, alpha, testState);
Expand Down
2 changes: 1 addition & 1 deletion src/planner/kunzretimer/KunzRetimer.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "aikido/planner/kunzretimer/KunzRetimer.hpp"

#include "aikido/common/memory.hpp"
#include "aikido/common/Spline.hpp"
#include "aikido/common/StepSequence.hpp"
#include "aikido/common/memory.hpp"
#include "aikido/statespace/dart/MetaSkeletonStateSpace.hpp"
#include "aikido/trajectory/Interpolated.hpp"
#include "aikido/trajectory/Spline.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/planner/parabolic/ParabolicSmoother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <cassert>
#include <set>
#include "aikido/common/memory.hpp"
#include "aikido/common/Spline.hpp"
#include "aikido/common/memory.hpp"
#include "aikido/planner/parabolic/ParabolicTimer.hpp"
#include "DynamicPath.h"
#include "HauserParabolicSmootherHelpers.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/planner/parabolic/ParabolicTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <cassert>
#include <set>
#include "aikido/common/memory.hpp"
#include "aikido/common/Spline.hpp"
#include "aikido/common/memory.hpp"
#include "aikido/trajectory/Interpolated.hpp"
#include "DynamicPath.h"
#include "ParabolicUtil.hpp"
Expand Down
7 changes: 4 additions & 3 deletions src/planner/parabolic/ParabolicUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <cassert>
#include <set>

#include "aikido/common/memory.hpp"
#include <dart/dart.hpp>
#include "aikido/common/Spline.hpp"
#include "aikido/common/memory.hpp"
#include "aikido/statespace/GeodesicInterpolator.hpp"
#include "aikido/statespace/dart/MetaSkeletonStateSpace.hpp"
#include "aikido/trajectory/Interpolated.hpp"
Expand Down Expand Up @@ -101,8 +101,9 @@ std::unique_ptr<aikido::trajectory::Spline> convertToSpline(
Eigen::VectorXd positionPrev, velocityPrev;
evaluateAtTime(_inputPath, timePrev, positionPrev, velocityPrev);

auto _outputTrajectory = ::aikido::common::make_unique<aikido::trajectory::Spline>(
_stateSpace, timePrev + _startTime);
auto _outputTrajectory
= ::aikido::common::make_unique<aikido::trajectory::Spline>(
_stateSpace, timePrev + _startTime);
auto segmentStartState = _stateSpace->createState();

for (const auto timeCurr : transitionTimes)
Expand Down
2 changes: 1 addition & 1 deletion src/planner/vectorfield/detail/VectorFieldIntegrator.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "VectorFieldIntegrator.hpp"
#include <exception>
#include <string>
#include <aikido/common/memory.hpp>
#include <aikido/common/Spline.hpp>
#include <aikido/common/memory.hpp>
#include <aikido/planner/vectorfield/VectorFieldUtil.hpp>
#include <aikido/statespace/GeodesicInterpolator.hpp>
#include "VectorFieldPlannerExceptions.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/robot/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <algorithm>
#include <dart/common/Console.hpp>
#include "aikido/common/memory.hpp"
#include <dart/common/Timer.hpp>
#include <ompl/geometric/planners/rrt/RRTConnect.h>
#include "aikido/common/RNG.hpp"
#include "aikido/common/memory.hpp"
#include "aikido/constraint/CyclicSampleable.hpp"
#include "aikido/constraint/FiniteSampleable.hpp"
#include "aikido/constraint/NewtonsMethodProjectable.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/rviz/InteractiveMarkerViewer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <aikido/rviz/InteractiveMarkerViewer.hpp>

#include "aikido/common/memory.hpp"
#include <dart/dart.hpp>
#include "aikido/common/memory.hpp"
#include <aikido/rviz/FrameMarker.hpp>
#include <aikido/rviz/SkeletonMarker.hpp>
#include <aikido/rviz/TrajectoryMarker.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/rviz/ShapeFrameMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ShapeFrameMarker::ShapeFrameMarker(
, mForceUpdate(true)
, mVersion()
, mShowVisual(true)
, mShowCollision(false)
, mShowCollision(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this default?

{
using std::placeholders::_1;
using std::placeholders::_2;
Expand Down
2 changes: 1 addition & 1 deletion src/trajectory/BSpline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <sstream>
#include <Eigen/Core>
#include "aikido/common/memory.hpp"
#include "aikido/common/StepSequence.hpp"
#include "aikido/common/memory.hpp"

namespace aikido {
namespace trajectory {
Expand Down
3 changes: 2 additions & 1 deletion src/trajectory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_library("${PROJECT_NAME}_trajectory" SHARED ${sources})
target_link_libraries("${PROJECT_NAME}_trajectory"
PUBLIC
"${PROJECT_NAME}_common"
"${PROJECT_NAME}_distance"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep this dependency, we should make sure to update the comments of src/CMakeLists.txt too.

"${PROJECT_NAME}_statespace"
)
target_compile_options("${PROJECT_NAME}_trajectory"
Expand All @@ -17,6 +18,6 @@ target_compile_options("${PROJECT_NAME}_trajectory"

add_component(${PROJECT_NAME} trajectory)
add_component_targets(${PROJECT_NAME} trajectory "${PROJECT_NAME}_trajectory")
add_component_dependencies(${PROJECT_NAME} trajectory common statespace)
add_component_dependencies(${PROJECT_NAME} trajectory common statespace distance)

clang_format_add_sources(${sources})
Loading