-
Notifications
You must be signed in to change notification settings - Fork 30
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
Changes from all commits
0fcbf75
be76329
fe0d122
f7c046f
5f35b80
e2c97c2
c124007
14ae219
cab437b
4fce133
17868bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
{ | ||
// CollisionFreeOutcome* collisionFreeOutcome | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
@@ -65,6 +72,7 @@ bool CollisionFree::isSatisfied( | |
{ | ||
collisionFreeOutcome->mPairwiseContacts = collisionResult.getContacts(); | ||
} | ||
std::cout << collisionFreeOutcome->toString() << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this for debugging? |
||
return false; | ||
} | ||
} | ||
|
@@ -79,6 +87,7 @@ bool CollisionFree::isSatisfied( | |
{ | ||
collisionFreeOutcome->mSelfContacts = collisionResult.getContacts(); | ||
} | ||
std::cout << collisionFreeOutcome->toString() << std::endl; | ||
return false; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this comment inside the |
||
// skeleton. | ||
#if DART_VERSION_AT_LEAST(6, 8, 0) | ||
if (mInverseKinematics->solveAndApply(true)) | ||
#else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,7 @@ void KinematicSimulationTrajectoryExecutor::step( | |
// Check if trajectory has completed. | ||
if (executionTime >= mTraj->getEndTime()) | ||
{ | ||
std::cout << "Trajectory completed" << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove? |
||
mTraj.reset(); | ||
mStateSpace.reset(); | ||
mMetaSkeleton.reset(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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( | ||
|
@@ -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; | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
||
|
@@ -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); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,7 @@ std::future<void> RosTrajectoryExecutor::execute( | |
goal, | ||
boost::bind(&RosTrajectoryExecutor::transitionCallback, this, _1)); | ||
|
||
std::cout << "Returning future" << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete? |
||
return mPromise->get_future(); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -37,6 +38,7 @@ trajectory::TrajectoryPtr SnapConfigurationToConfigurationPlanner::plan( | |
auto constraint = problem.getConstraint(); | ||
|
||
aikido::common::VanDerCorput vdc{1, true, true, 0.02}; // TODO junk resolution | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete? |
||
for (const auto alpha : vdc) | ||
{ | ||
mInterpolator->interpolate(startState, goalState, alpha, testState); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ ShapeFrameMarker::ShapeFrameMarker( | |
, mForceUpdate(true) | ||
, mVersion() | ||
, mShowVisual(true) | ||
, mShowCollision(false) | ||
, mShowCollision(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change this default? |
||
{ | ||
using std::placeholders::_1; | ||
using std::placeholders::_2; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ add_library("${PROJECT_NAME}_trajectory" SHARED ${sources}) | |
target_link_libraries("${PROJECT_NAME}_trajectory" | ||
PUBLIC | ||
"${PROJECT_NAME}_common" | ||
"${PROJECT_NAME}_distance" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
"${PROJECT_NAME}_statespace" | ||
) | ||
target_compile_options("${PROJECT_NAME}_trajectory" | ||
|
@@ -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}) |
There was a problem hiding this comment.
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)?