-
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
Add B-spline trajectory #453
Conversation
Codecov Report
@@ 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
|
// This file is part of Eigen, a lightweight C++ template library | ||
// for linear algebra. | ||
// | ||
// Copyright (C) 20010-2011 Hauke Heibel <[email protected]> |
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.
Are we going to update the head description?
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.
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; |
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.
Shall we change it to using BSpline2f = BSpline<float, 2>
to follow aikido style?
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.
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 |
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.
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. |
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.
The docstring of value
is missed
bool withStartControlPoint = true, | ||
bool withEndControlPoint = true); | ||
|
||
const ControlPointVectorType& getControlPoints( |
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.
Docstring is missed.
const ControlPointVectorType& getControlPoints( | ||
std::size_t stateSpaceIndex) const; | ||
|
||
ControlPointVectorType getControlPoints( |
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.
Docstring is missed.
src/trajectory/BSpline.cpp
Outdated
//============================================================================== | ||
void BSpline::evaluate(double t, statespace::StateSpace::State* state) const | ||
{ | ||
Eigen::VectorXd values(mStateSpace->getDimension()); |
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.
shall we check t
is in [startTime, endTime]
?
src/trajectory/BSpline.cpp
Outdated
{ | ||
const auto numControlPoints | ||
= static_cast<ControlPointVectorType::Index>(getNumControlPoints()); | ||
|
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.
Shall stateSpaceIndex
be checked?
src/trajectory/BSpline.cpp
Outdated
const BSpline::ControlPointVectorType& BSpline::getControlPoints( | ||
std::size_t stateSpaceIndex) const | ||
{ | ||
return mSplines[stateSpaceIndex].ctrls(); |
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.
shall the stateSpaceIndex
be checked?
src/trajectory/BSpline.cpp
Outdated
|
||
const common::StepSequence internalKnots( | ||
startTime, endTime, numControlPoints + 1u - degree, true); | ||
ControlPointVectorType::Index index = 1; |
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.
why index
==0 is not updated?
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.
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.
src/trajectory/BSpline.cpp
Outdated
double /*t*/, int derivative, Eigen::VectorXd& /*tangentVector*/) const | ||
{ | ||
if (derivative < 1) | ||
throw std::logic_error("Derivative must be positive."); |
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.
shall we just use std::argument_error
?
@dqyi11 I believe the comments are addressed. Could you do a second round review? |
(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 incommon
namespace.Unlike
trajectory::Spline
,trajectory::BSpline
guarantees classC^k
continuity (k - 1
times differentiable) over the whole trajectory wherek
is the order of B-spline.Eigen::Spline
(renamed toaikido::common::BSpline
) andEigen::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
make format
Before merging a pull request
CHANGELOG.md