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

Change how solver wrappers are configured and Implement Automatic Scaling #21

Merged
merged 21 commits into from
Nov 9, 2018

Conversation

hungpham2511
Copy link
Owner

@hungpham2511 hungpham2511 commented Nov 7, 2018

Some changes:

  • Each solver now enforces its own limits on x, u and so on. This is to ensure numerical stability for solvers like ECOS or Seidel.
  • A bug fixed in Seidel.
  • Test cases reorganized
  • Implement problem scaling, accessible via argument parameter scaling. Auto-scaling is available, used by setting scaling to 1.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 131

  • 78 of 99 (78.79%) changed or added relevant lines in 13 files are covered.
  • 10 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-1.3%) to 82.496%

Changes Missing Coverage Covered Lines Changed/Added Lines %
toppra/algorithm/algorithm.py 2 3 66.67%
toppra/interpolator.py 2 3 66.67%
toppra/solverwrapper/cvxpy_solverwrapper.py 12 20 60.0%
toppra/algorithm/reachabilitybased/reachability_algorithm.py 25 36 69.44%
Files with Coverage Reduction New Missed Lines %
toppra/constraint/canonical_conic.py 1 86.96%
toppra/solverwrapper/hot_qpoases_solverwrapper.py 2 90.91%
toppra/solverwrapper/qpoases_solverwrapper.py 2 87.21%
toppra/solverwrapper/ecos_solverwrapper.py 5 94.78%
Totals Coverage Status
Change from base Build 124: -1.3%
Covered Lines: 1150
Relevant Lines: 1394

💛 - Coveralls

@hungpham2511
Copy link
Owner Author

Seidel fails to solve the following instance at difference scaling levels. Tested at 1e-1, 1e-2 and 1e-3.

import toppra as ta
import toppra.constraint as constraint
import toppra.algorithm as algo
import numpy as np
import matplotlib.pyplot as plt

ta.setup_logging("DEBUG")


def main():
    # waypts = [[0], [5], [10]]
    # path = ta.SplineInterpolator([0, 0.5, 1.0], waypts)
    waypts = [[0], [1e-8], [0]]
    path = ta.SplineInterpolator([0, 0.5, 1.0], waypts)
    # NOTE: When constructing a path, you must "align" the waypoint
    # properly yourself. For instance, if the waypoints are [0, 1, 10]
    # like in the above example, the path position should be aligned
    # like [0, 0.1, 1.0]. If this is not done, the CubicSpline
    # Interpolator might result undesirable oscillating paths!
    vlim = np.array([[-10, 10]])
    alim = np.array([[-4, 4]])
    pc_vel = constraint.JointVelocityConstraint(vlim)
    pc_acc = constraint.JointAccelerationConstraint(
        alim, discretization_scheme=constraint.DiscretizationType.Interpolation)

    instance = algo.TOPPRA([pc_vel, pc_acc], path, solver_wrapper='seidel',
                           gridpoints=np.linspace(0, 1.0, 1001), scaling=1e-3)
    jnt_traj, aux_traj, data = instance.compute_trajectory(0, 0, return_data=True)

@hungpham2511
Copy link
Owner Author

For pathological cases, like path with minimal/near zero motions, seidel solver wrapper works badly. Probably because it does not scale the Linear Program prior to solving. Since reimplementing seidel does not justify the benefit, as one can always switch to a more stable solver wrapper such as qpOASES for these cases, we no longer require seidel to pass tests with very small motions.

@hungpham2511 hungpham2511 changed the title Several changes to how solver wrappers are configured Change how solver wrappers are configured and Implement Automatic Scaling Nov 9, 2018
@hungpham2511 hungpham2511 merged commit 386881e into master Nov 9, 2018
@hungpham2511 hungpham2511 deleted the hung-dev branch November 9, 2018 16:17
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.

None yet

2 participants