Skip to content

Commit f426c8e

Browse files
authored
Merge pull request #37 from hungpham2511/hung-dev
Automatic scaling for qpoases solver-wrapper
2 parents 3e65b3b + c10e94e commit f426c8e

25 files changed

+483
-200
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,7 @@ venv.bak/
101101
/site
102102

103103
# mypy
104-
.mypy_cache/
104+
.mypy_cache/
105+
106+
# emacs temp file
107+
*~

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ before_install:
2121
- ./install-fcl.sh
2222
- ./install-openrave.sh
2323
- sudo apt install python-tk
24-
- pip install --ignore-installed cython matplotlib coverage python-coveralls cvxopt --user
24+
- pip install --ignore-installed cython matplotlib coverage python-coveralls cvxopt tabulate --user
2525

2626
install:
2727
# Install dependencies
@@ -34,6 +34,7 @@ install:
3434
script:
3535
- cd $CI_SOURCE_PATH
3636
- pip install -r requirements.txt --user
37+
- pip install pandas --user # for testing
3738
- python setup.py develop --user # need to run the develop command to have coverage working. install command (below) should work just fine.
3839
# - python setup.py install --user
3940
- py.test --cov=toppra tests -Wonce

requirements.txt

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@ cython>=0.22.0
33
scipy>0.18
44
coloredlogs
55
enum34
6-
cvxpy>=0.4.11, <1.0.0
7-
pytest
8-
pytest-cov
96
matplotlib<3.0.0

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
import numpy as np
55

66
NAME = "toppra"
7-
VERSION = "0.2"
7+
VERSION = "0.3.0"
88
DESCR = "An implementation of TOPP-RA (TOPP via Reachability Analysis) for time-parametrizing" \
99
"trajectories for robots subject to kinematic (velocity and acceleration) and dynamic" \
1010
"(torque) constraints. Some other kinds of constraints are also supported."
1111
URL = "https://github.com/hungpham2511/toppra"
12+
1213
with open("requirements.txt", "r") as f:
1314
REQUIRES = [line.strip() for line in f if line.strip()]
1415

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
try:
2-
import openravepy as orpy
3-
except:
4-
# Unable to find openrave
5-
FOUND_OPENRAVEPY = False
1+
import toppra
62
import pytest
7-
3+
import openravepy as orpy
84

95
@pytest.fixture(scope="session")
106
def rave_env():
@@ -13,3 +9,24 @@ def rave_env():
139
env.Destroy()
1410
orpy.RaveDestroy()
1511

12+
13+
def pytest_addoption(parser):
14+
parser.addoption(
15+
"--loglevel", action="store", default="WARNING",
16+
help="Set toppra loglevel during testing."
17+
)
18+
19+
parser.addoption(
20+
"--robust_regex", action="store", default=".*oa.*",
21+
help="Regex to choose problems to test when running test_robustness_main.py. "
22+
"Select '.*oa.*' to run only tests for hotqpoases."
23+
)
24+
25+
parser.addoption(
26+
"--visualize", action="store_true", default=False,
27+
help="If True visualize test instance."
28+
)
29+
30+
31+
def pytest_collection_modifyitems(config, items):
32+
toppra.setup_logging(config.getoption("--loglevel"))

tests/constraint/test_joint_velocity.py

+22-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy.testing as npt
55
import toppra as ta
66
import toppra.constraint as constraint
7-
from toppra.constants import TINY, JVEL_MAXSD
7+
from toppra.constants import TINY, JVEL_MAXSD, SMALL
88
from scipy.interpolate import CubicSpline
99

1010

@@ -67,15 +67,18 @@ def test_constraint_satisfaction(self, velocity_pc_data):
6767
qs[i] * sd >= vlim[:, 0],
6868
sd >= 0, sd <= JVEL_MAXSD]
6969
prob = cvx.Problem(cvx.Maximize(sd), constraints)
70-
prob.solve(solver=cvx.ECOS, abstol=1e-9)
71-
xmax = sd.value ** 2
72-
73-
prob = cvx.Problem(cvx.Minimize(sd), constraints)
74-
prob.solve(solver=cvx.ECOS, abstol=1e-9)
75-
xmin = sd.value ** 2
70+
try:
71+
prob.solve(solver=cvx.ECOS, abstol=1e-9)
72+
xmax = sd.value ** 2
73+
74+
prob = cvx.Problem(cvx.Minimize(sd), constraints)
75+
prob.solve(solver=cvx.ECOS, abstol=1e-9)
76+
xmin = sd.value ** 2
77+
except cvx.SolverError:
78+
continue
7679

7780
# 3. They should agree
78-
npt.assert_allclose([xmin, xmax], xlimit[i], atol=TINY)
81+
npt.assert_allclose([xmin, xmax], xlimit[i], atol=SMALL)
7982

8083
# Assert non-negativity
8184
assert xlimit[i, 0] >= 0
@@ -123,16 +126,20 @@ def test_jnt_vel_varying_basic():
123126
constraints = [qs[i] * sd <= vlim[:, 1],
124127
qs[i] * sd >= vlim[:, 0],
125128
sd >= 0, sd <= JVEL_MAXSD]
126-
prob = cvx.Problem(cvx.Maximize(sd), constraints)
127-
prob.solve(solver=cvx.ECOS, abstol=1e-9)
128-
xmax = sd.value ** 2
129129

130-
prob = cvx.Problem(cvx.Minimize(sd), constraints)
131-
prob.solve(solver=cvx.ECOS, abstol=1e-9)
132-
xmin = sd.value ** 2
130+
try:
131+
prob = cvx.Problem(cvx.Maximize(sd), constraints)
132+
prob.solve(solver=cvx.ECOS, abstol=1e-9)
133+
xmax = sd.value ** 2
134+
135+
prob = cvx.Problem(cvx.Minimize(sd), constraints)
136+
prob.solve(solver=cvx.ECOS, abstol=1e-9)
137+
xmin = sd.value ** 2
138+
except cvx.SolverError:
139+
continue # ECOS can't solve this problem.
133140

134141
# 3. they should agree
135-
npt.assert_allclose([xmin, xmax], xlimit[i], atol=TINY)
142+
npt.assert_allclose([xmin, xmax], xlimit[i], atol=SMALL)
136143

137144
# assert non-negativity
138145
assert xlimit[i, 0] >= 0

tests/retime/test_general_cases.py

-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@
1111

1212
toppra.setup_logging(level="INFO")
1313

14-
try:
15-
import mosek
16-
FOUND_MOSEK = True
17-
except ImportError:
18-
FOUND_MOSEK = False
19-
20-
try:
21-
import cvxpy
22-
FOUND_CXPY = True
23-
except ImportError:
24-
FOUND_CXPY = False
25-
2614

2715
@pytest.mark.parametrize("solver_wrapper", ["cvxpy", "qpoases", "hotqpoases", "seidel"])
2816
def test_toppra_linear(basic_constraints, basic_path, solver_wrapper):

tests/retime/test_retime_wconic_constraints.py

-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55

66
toppra.setup_logging(level="INFO")
77

8-
try:
9-
import mosek
10-
FOUND_MOSEK = True
11-
except ImportError:
12-
FOUND_MOSEK = False
13-
14-
try:
15-
import cvxpy
16-
FOUND_CXPY = True
17-
except ImportError:
18-
FOUND_CXPY = False
19-
208

219
@pytest.fixture(params=[(0, 0)])
2210
def vel_accel_robustaccel(request):

tests/retime/test_retime_with_openrave.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
except ImportError:
88
FOUND_OPENRAVE = False
99

10-
toppra.setup_logging("DEBUG")
1110

1211
@pytest.fixture(scope='module')
1312
def robot_fixture():

tests/retime_robustness/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Robustness test suites
2+
=======================
3+
4+
The test suites in this folder ensure that TOPP-RA work correctly for
5+
different problem inputs. The `.yaml` files provide problem inputs,
6+
which are read and solved by `test_robustness_main.py`.
7+
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
small_joint_1:
2+
waypoints:
3+
- [-0.00038593, -0.00038593, -0.00038593]
4+
- [ 0.00013093, 0.00013093, 0.00013093]
5+
- [ 0.00064752, 0.00064752, 0.00064752]
6+
- [ 0.00116383, 0.00116383, 0.00116383]
7+
- [ 0.00167987, 0.00167987, 0.00167987]
8+
- [ 0.00219563, 0.00219563, 0.00219563]
9+
- [ 0.00271112, 0.00271112, 0.00271112]
10+
- [ 0.00322633, 0.00322633, 0.00322633]
11+
- [ 0.00374127, 0.00374127, 0.00374127]
12+
- [ 0.00425594, 0.00425594, 0.00425594]
13+
14+
ss_waypoints: [0, 1]
15+
nb_gridpoints: [51, 101]
16+
vlim: [100, 100, 100]
17+
alim: [100, 100, 100]
18+
19+
desired_duration: [0, 1.0]
20+
solver_wrapper: ['hotqpoases', 'seidel']
21+
22+
small_joint_2:
23+
waypoints:
24+
- [0, 0, 0]
25+
- [0, 1e-5, 0]
26+
- [0, 0, 0]
27+
28+
ss_waypoints: [0, 1]
29+
nb_gridpoints: [51, 101]
30+
vlim: [100, 10000, 100]
31+
alim: [100, 10000, 100]
32+
33+
desired_duration: [0]
34+
solver_wrapper: ['hotqpoases', 'seidel']
35+
36+
small_joint_3:
37+
waypoints:
38+
- [0, 0, 0]
39+
- [0, 1e-7, 0]
40+
- [0, 0, 0]
41+
42+
ss_waypoints: [0, 1]
43+
nb_gridpoints: [51, 101]
44+
vlim: [100, 1000, 100]
45+
alim: [100, 1000, 100]
46+
47+
desired_duration: [0]
48+
solver_wrapper: ['hotqpoases', 'seidel']
49+
50+
51+
issue26:
52+
remark: "From JadBadMobile. https://github.com/hungpham2511/toppra/issues/26"
53+
waypoints:
54+
- [-3.85929168e-04, -3.85929168e-04, -3.85929168e-04]
55+
- [-2.13610365e-04, -2.13610365e-04, -2.13610365e-04]
56+
- [-4.13223272e-05, -4.13223272e-05, -4.13223272e-05]
57+
- [ 1.30934967e-04, 1.30934967e-04, 1.30934967e-04]
58+
- [ 3.03161539e-04, 3.03161539e-04, 3.03161539e-04]
59+
- [ 4.75357412e-04, 4.75357412e-04, 4.75357412e-04]
60+
- [ 6.47522605e-04, 6.47522605e-04, 6.47522605e-04]
61+
- [ 8.19657141e-04, 8.19657141e-04, 8.19657141e-04]
62+
- [ 9.91761041e-04, 9.91761041e-04, 9.91761041e-04]
63+
- [ 1.16383433e-03, 1.16383433e-03, 1.16383433e-03]
64+
65+
ss_waypoints: [0, 1]
66+
nb_gridpoints: [51, 101]
67+
vlim: [1000, 1000, 1000]
68+
alim: [1000, 2000, 10000]
69+
70+
desired_duration: [0, 1.0]
71+
solver_wrapper: ['hotqpoases', 'seidel']
72+
73+
two_points_1:
74+
waypoints:
75+
- [0, 0, 0]
76+
- [0, 1, 0]
77+
78+
ss_waypoints: [0, 1]
79+
nb_gridpoints: [51, 101, 501]
80+
vlim: [100, 100, 100]
81+
alim: [100, 100, 100]
82+
83+
desired_duration: [0, 1.0]
84+
optimal_duration: 0.2
85+
solver_wrapper: ['hotqpoases', 'seidel']
86+
87+
two_points_2:
88+
waypoints:
89+
- [0, 0, 0]
90+
- [0, 1e-4, 0]
91+
92+
ss_waypoints: [0, 1]
93+
nb_gridpoints: [51, 101, 1001]
94+
vlim: [100, 100, 100]
95+
alim: [100, 100, 100]
96+
97+
desired_duration: [0]
98+
optimal_duration: 0.002
99+
solver_wrapper: ['hotqpoases', 'seidel']
100+

0 commit comments

Comments
 (0)