hungpham2511 / toppra

robotic motion planning library
https://hungpham2511.github.io/toppra/index.html
MIT License
625 stars 170 forks source link

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

Closed hungpham2511 closed 5 years ago

hungpham2511 commented 5 years ago

Some changes:

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 131


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%
<!-- Total: 78 99 78.79% -->
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%
<!-- Total: 10 -->
Totals Coverage Status
Change from base Build 124: -1.3%
Covered Lines: 1150
Relevant Lines: 1394

💛 - Coveralls
hungpham2511 commented 5 years ago

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 commented 5 years ago

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.