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 B-spline trajectory #453

Merged
merged 13 commits into from
Oct 13, 2018
Merged

Add B-spline trajectory #453

merged 13 commits into from
Oct 13, 2018

Conversation

jslee02
Copy link
Member

@jslee02 jslee02 commented Aug 6, 2018

(This is a work-in-progress pull request to get early feedback.)

This PR adds trajectory::BSpline, implementation of B-spline trajectory, and necessary classes in common namespace.

Unlike trajectory::Spline, trajectory::BSpline guarantees class C^k continuity (k - 1 times differentiable) over the whole trajectory where k is the order of B-spline.

Eigen::Spline (renamed to aikido::common::BSpline) and Eigen::SplineTraits are copied into AIKIDO code base with some modifications. The motivation of the adjustment is that Eigen's B-spline module doesn't allow changing control points after construction while we need this feature for trajectory optimization, which we will introduce soon.

Unit tests will be added before merging this PR.


Before creating a pull request

  • Document new methods and classes
  • Format code with make format

Before merging a pull request

  • Set version target by selecting a milestone on the right side
  • Summarize this change in CHANGELOG.md
  • Add unit test(s) for this change

@jslee02 jslee02 added the pr: work-in-progress Calls for preliminary review of the PR. Remove when PR is ready for complete review. label Aug 6, 2018
@jslee02 jslee02 added this to the Aikido 0.3.0 milestone Aug 6, 2018
@jslee02 jslee02 requested review from brianhou and dqyi11 August 6, 2018 01:12
@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

Merging #453 into master will decrease coverage by 1.29%.
The diff coverage is 50%.

@@            Coverage Diff            @@
##           master     #453     +/-   ##
=========================================
- Coverage   78.88%   77.59%   -1.3%     
=========================================
  Files         258      260      +2     
  Lines        6300     6588    +288     
=========================================
+ Hits         4970     5112    +142     
- Misses       1330     1476    +146
Impacted Files Coverage Δ
include/aikido/common/BSpline.hpp 100% <100%> (ø)
src/trajectory/BSpline.cpp 37.39% <37.39%> (ø)
src/common/StepSequence.cpp 92.85% <90%> (-0.7%) ⬇️
src/planner/ompl/CRRT.cpp 75.58% <0%> (-0.59%) ⬇️

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 20010-2011 Hauke Heibel <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to update the head description?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should keep this license as we copied this code from Eigen, and will add our license on top of this license for the part we modify/add.

};

/** \brief 2D float B-spline with dynamic degree. */
typedef BSpline<float, 2> BSpline2f;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we change it to using BSpline2f = BSpline<float, 2> to follow aikido style?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure whether we want to fully change this code or keep the changes as minimum as possible. Let's leave this code as it is and then revisit.

using ControlPointVectorType = typename SplineType::ControlPointVectorType;

/// Constructs BSpline from control points and knots. The degree is
/// automatically determined by the
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfinished?

/// Sets start point of one sub space of the state space.
///
/// \param[in] stateSpaceIndex The index to the state space to set the start
/// point.
Copy link
Contributor

Choose a reason for hiding this comment

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

The docstring of value is missed

bool withStartControlPoint = true,
bool withEndControlPoint = true);

const ControlPointVectorType& getControlPoints(
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstring is missed.

const ControlPointVectorType& getControlPoints(
std::size_t stateSpaceIndex) const;

ControlPointVectorType getControlPoints(
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstring is missed.

//==============================================================================
void BSpline::evaluate(double t, statespace::StateSpace::State* state) const
{
Eigen::VectorXd values(mStateSpace->getDimension());
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we check t is in [startTime, endTime]?

{
const auto numControlPoints
= static_cast<ControlPointVectorType::Index>(getNumControlPoints());

Copy link
Contributor

Choose a reason for hiding this comment

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

Shall stateSpaceIndex be checked?

const BSpline::ControlPointVectorType& BSpline::getControlPoints(
std::size_t stateSpaceIndex) const
{
return mSplines[stateSpaceIndex].ctrls();
Copy link
Contributor

Choose a reason for hiding this comment

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

shall the stateSpaceIndex be checked?


const common::StepSequence internalKnots(
startTime, endTime, numControlPoints + 1u - degree, true);
ControlPointVectorType::Index index = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

why index==0 is not updated?

Copy link
Member Author

Choose a reason for hiding this comment

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

This line should be fixed to index = degree. We use multiple knots of the number of degree at the start and end knots so that the start and end of the trajectory are placed at the first and last control points, respectively. Let me document this to be clear.

double /*t*/, int derivative, Eigen::VectorXd& /*tangentVector*/) const
{
if (derivative < 1)
throw std::logic_error("Derivative must be positive.");
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we just use std::argument_error?

@jslee02
Copy link
Member Author

jslee02 commented Sep 3, 2018

@dqyi11 I believe the comments are addressed. Could you do a second round review?

@jslee02 jslee02 removed the pr: work-in-progress Calls for preliminary review of the PR. Remove when PR is ready for complete review. label Sep 3, 2018
@jslee02 jslee02 merged commit 1d92d1c into master Oct 13, 2018
@jslee02 jslee02 deleted the enhance/bspline_v2 branch October 13, 2018 18:47
gilwoolee pushed a commit that referenced this pull request Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants