Skip to content

Commit

Permalink
init varying accel
Browse files Browse the repository at this point in the history
  • Loading branch information
hashb committed Oct 26, 2023
1 parent 730aa8a commit 2d6394d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
30 changes: 22 additions & 8 deletions cpp/src/toppra/constraint/linear_joint_acceleration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,36 @@ void LinearJointAcceleration::computeParams_impl(const GeometricPath& path,

Eigen::Index ndofs (nbVariables());

// Compute F and g
Matrix& _F = F[0];
_F. topRows(ndofs).setIdentity();
_F.bottomRows(ndofs).setZero();
_F.bottomRows(ndofs).diagonal().setConstant(-1);
Vector& _g = g[0];
_g.head(ndofs) = m_upper;
_g.tail(ndofs) = -m_lower;
if (constantF()) {
// Compute F and g
Matrix& _F = F[0];
_F.topRows(ndofs).setIdentity();
_F.bottomRows(ndofs).setZero();
_F.bottomRows(ndofs).diagonal().setConstant(-1);
Vector& _g = g[0];
_g.head(ndofs) = m_upper;
_g.tail(ndofs) = -m_lower;
}

assert(ndofs == path.dof());
for (std::size_t i = 0; i < N_1; ++i) {
computeAccelerationLimits(gridpoints[i]);

a[i] = path.eval_single(times[i], 1);
assert(a[i].size() == ndofs);
b[i] = path.eval_single(times[i], 2);
assert(b[i].size() == ndofs);
c[i].setZero();

if (!constantF()) {
Matrix& _F = F[i];
_F.topRows(ndofs).setIdentity();
_F.bottomRows(ndofs).setZero();
_F.bottomRows(ndofs).diagonal().setConstant(-1);
Vector& _g = g[i];
_g.head(ndofs) = m_upper;
_g.tail(ndofs) = -m_lower;
}
}
}

Expand Down
14 changes: 13 additions & 1 deletion cpp/src/toppra/constraint/linear_joint_acceleration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ class LinearJointAcceleration : public LinearConstraint {

virtual std::ostream& print(std::ostream& os) const;

protected:
LinearJointAcceleration (const int nDof)
: LinearConstraint (nDof * 2, nDof, false, false, false)
, m_lower (nDof)
, m_upper (nDof)
{
check();
}

virtual void computeAccelerationLimits(value_type time) { (void)time; }

Vector m_lower, m_upper;

private:
void check();

Expand All @@ -28,7 +41,6 @@ class LinearJointAcceleration : public LinearConstraint {
Matrices& F, Vectors& g,
Bounds& ubound, Bounds& xbound);

Vector m_lower, m_upper;
}; // class LinearJointAcceleration
} // namespace constraint
} // namespace toppra
Expand Down

0 comments on commit 2d6394d

Please sign in to comment.