Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
ndcurves
Commits
6aae34f4
Commit
6aae34f4
authored
Feb 07, 2019
by
Steve T
Browse files
new api is hpp_spline
parent
c2ed8387
Changes
5
Hide whitespace changes
Inline
Side-by-side
python/test/variable/qp_traj/qp_cord.py
View file @
6aae34f4
from
spline
import
*
from
hpp_
spline
import
*
from
varBezier
import
varBezier
from
convex_hull
import
*
...
...
python/test/variable/qp_traj/test_cord.py
View file @
6aae34f4
from
spline
import
*
from
hpp_
spline
import
*
from
numpy
import
matrix
,
array
,
zeros
,
ones
,
diag
,
cross
from
numpy.linalg
import
norm
...
...
@@ -130,7 +130,7 @@ def computeTrajectory(bezVar, splits, save, filename = uuid.uuid4().hex.upper()[
#solve and gen problem
def
gen
(
save
=
False
):
testConstant
=
genBezierInput
(
4
)
testConstant
=
genBezierInput
(
20
)
splits
=
genSplit
(
4
)
return
computeTrajectory
(
testConstant
,
splits
,
save
),
testConstant
...
...
python/test/variable/qp_traj/varBezier.py
View file @
6aae34f4
from
spline
import
*
from
hpp_
spline
import
*
from
numpy
import
matrix
,
array
,
zeros
,
ones
,
diag
,
cross
from
numpy.linalg
import
norm
...
...
python/test/variable/test_var.py
View file @
6aae34f4
from
spline
import
*
from
hpp_
spline
import
*
from
varBezier
import
varBezier
from
numpy
import
matrix
,
array
,
zeros
,
ones
,
diag
,
cross
from
numpy.linalg
import
norm
...
...
python/test/variable/varBezier.py
0 → 100644
View file @
6aae34f4
from
hpp_spline
import
*
from
numpy
import
matrix
,
array
,
zeros
,
ones
,
diag
,
cross
from
numpy.linalg
import
norm
__EPS
=
1e-6
import
eigenpy
eigenpy
.
switchToNumpyArray
()
_zeroMat
=
array
([[
0.
,
0.
,
0.
],[
0.
,
0.
,
0.
],[
0.
,
0.
,
0.
]]).
transpose
()
_I3
=
array
([[
1.
,
0.
,
0.
],[
0.
,
1.
,
0.
],[
0.
,
0.
,
1.
]]).
transpose
()
_zeroVec
=
array
([[
0.
,
0.
,
0.
]]).
transpose
()
def
createControlPoint
(
val
):
if
type
(
val
)
==
str
:
return
(
_I3
,
_zeroVec
)
else
:
return
(
_zeroMat
,
val
.
reshape
([
3
,
1
]))
def
createWaypointList
(
waypoints
):
mat
=
zeros
([
3
,
len
(
waypoints
)
*
3
])
vec
=
zeros
([
3
,
len
(
waypoints
)])
for
i
,
val
in
enumerate
(
waypoints
):
mvar
,
vvar
=
createControlPoint
(
val
)
mat
[:,
i
*
3
:
i
*
3
+
3
]
=
mvar
vec
[:,
i
:
i
+
1
]
=
vvar
return
mat
,
vec
class
varBezier
:
#waypoints is a list that contains either 3d arrays (constants), or a string "variable"
def
__init__
(
self
,
waypoints
=
None
,
time
=
1.
):
if
(
waypoints
!=
None
):
mat
,
vec
=
createWaypointList
(
waypoints
)
self
.
bezier
=
bezierVar
(
mat
,
vec
,
time
)
def
fromBezier
(
self
,
bez
):
var
=
varBezier
()
var
.
bezier
=
bez
return
var
#splits into n+1 continuous curves, with n the number of time values
def
split
(
self
,
times
):
timearray
=
array
(
times
).
reshape
([
-
1
,
1
])
subBeziers
=
self
.
bezier
.
split
(
timearray
)
dim
=
subBeziers
.
size
return
[
self
.
fromBezier
(
subBeziers
.
at
(
i
))
for
i
in
range
(
dim
)]
# for each control point of the curve, gives the linear depency
# of a given variable
def
waypoints
(
self
,
varId
=-
1
):
if
varId
<
0
:
return
self
.
bezier
.
waypoints
().
A
,
self
.
bezier
.
waypoints
().
b
assert
self
.
bezier
.
nbWaypoints
>
varId
mat
=
self
.
bezier
.
waypoints
().
A
[:,
varId
*
3
:
varId
*
3
+
3
]
vec
=
self
.
bezier
.
waypoints
().
b
[:,
varId
]
return
mat
,
vec
def
matrixFromWaypoints
(
self
,
varId
):
assert
(
varId
>=
0
)
mat
,
vec
=
self
.
waypoints
(
varId
)
resvec
=
zeros
(
3
)
for
i
in
range
(
0
,
mat
.
shape
[
0
]
/
3
,
1
):
resvec
+=
vec
[
i
*
3
:
i
*
3
+
3
]
return
mat
.
transpose
(),
resvec
def
toBezier3
(
self
,
x
):
wps
=
[]
for
i
in
range
(
self
.
bezier
.
nbWaypoints
):
mat
,
vec
=
self
.
matrixFromWaypoints
(
i
)
wps
+=
[
mat
.
dot
(
x
)
+
vec
]
return
bezier
(
array
(
wps
).
transpose
(),
self
.
bezier
.
max
())
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment