Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jason Chemin
curves
Commits
88ff7cce
Commit
88ff7cce
authored
Aug 23, 2019
by
JasonChmn
Committed by
Pierre Fernbach
Sep 03, 2019
Browse files
[dynamic dim - polynomial] Remove dim from template + binding python
parent
c31bd106
Changes
7
Hide whitespace changes
Inline
Side-by-side
include/curves/cubic_spline.h
View file @
88ff7cce
...
...
@@ -35,13 +35,12 @@ namespace curves
return
res
;
}
template
<
typename
Time
,
typename
Numeric
,
std
::
size_t
Dim
,
bool
Safe
,
typename
Point
,
typename
T_Point
>
polynomial
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
create_cubic
(
Point
const
&
a
,
Point
const
&
b
,
Point
const
&
c
,
Point
const
&
d
,
const
Time
t_min
,
const
Time
t_max
)
template
<
typename
Time
,
typename
Numeric
,
bool
Safe
,
typename
Point
,
typename
T_Point
>
polynomial
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
create_cubic
(
Point
const
&
a
,
Point
const
&
b
,
Point
const
&
c
,
Point
const
&
d
,
const
Time
t_min
,
const
Time
t_max
)
{
T_Point
coeffs
=
make_cubic_vector
<
Point
,
T_Point
>
(
a
,
b
,
c
,
d
);
return
polynomial
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
(
coeffs
.
begin
(),
coeffs
.
end
(),
t_min
,
t_max
);
return
polynomial
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
(
coeffs
.
begin
(),
coeffs
.
end
(),
t_min
,
t_max
);
}
}
// namespace curves
#endif //_STRUCT_CUBICSPLINE
...
...
include/curves/exact_cubic.h
View file @
88ff7cce
...
...
@@ -40,7 +40,7 @@ namespace curves
template
<
typename
Time
=
double
,
typename
Numeric
=
Time
,
std
::
size_t
Dim
=
3
,
bool
Safe
=
false
,
typename
Point
=
Eigen
::
Matrix
<
Numeric
,
Eigen
::
Dynamic
,
1
>,
typename
T_Point
=
std
::
vector
<
Point
,
Eigen
::
aligned_allocator
<
Point
>
>
,
typename
SplineBase
=
polynomial
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
>
typename
SplineBase
=
polynomial
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
>
struct
exact_cubic
:
public
piecewise_curve
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
,
SplineBase
>
{
typedef
Point
point_t
;
...
...
@@ -182,9 +182,9 @@ namespace curves
for
(
int
i
=
0
;
next
!=
wayPointsEnd
;
++
i
,
++
it
,
++
next
)
{
subSplines
.
push_back
(
create_cubic
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
(
a
.
row
(
i
),
b
.
row
(
i
),
c
.
row
(
i
),
d
.
row
(
i
),
(
*
it
).
first
,
(
*
next
).
first
));
create_cubic
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
(
a
.
row
(
i
),
b
.
row
(
i
),
c
.
row
(
i
),
d
.
row
(
i
),
(
*
it
).
first
,
(
*
next
).
first
));
}
return
subSplines
;
}
...
...
@@ -218,7 +218,7 @@ namespace curves
const
num_t
&
init_t
=
wayPointsBegin
->
first
,
end_t
=
wayPointsNext
->
first
;
const
num_t
dt
=
end_t
-
init_t
,
dt_2
=
dt
*
dt
,
dt_3
=
dt_2
*
dt
;
const
point_t
d0
=
(
a1
-
a0
-
b0
*
dt
-
c0
*
dt_2
)
/
dt_3
;
subSplines
.
push_back
(
create_cubic
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
(
a0
,
b0
,
c0
,
d0
,
init_t
,
end_t
));
subSplines
.
push_back
(
create_cubic
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
(
a0
,
b0
,
c0
,
d0
,
init_t
,
end_t
));
constraints
.
init_vel
=
subSplines
.
back
().
derivate
(
end_t
,
1
);
constraints
.
init_acc
=
subSplines
.
back
().
derivate
(
end_t
,
2
);
}
...
...
@@ -247,7 +247,7 @@ namespace curves
eq
(
2
,
0
)
=
x_d_2
;
eq
(
2
,
1
)
=
x_e_2
;
eq
(
2
,
2
)
=
x_f_2
;
rhs
=
eq
.
inverse
().
eval
()
*
rhs
;
d
=
rhs
.
row
(
0
);
e
=
rhs
.
row
(
1
);
f
=
rhs
.
row
(
2
);
subSplines
.
push_back
(
create_quintic
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
(
a0
,
b0
,
c0
,
d
,
e
,
f
,
init_t
,
end_t
));
subSplines
.
push_back
(
create_quintic
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
(
a0
,
b0
,
c0
,
d
,
e
,
f
,
init_t
,
end_t
));
}
public:
...
...
include/curves/polynomial.h
View file @
88ff7cce
...
...
@@ -31,7 +31,7 @@ namespace curves
/// \f$ x(t) = a + b(t - t_{min}) + ... + d(t - t_{min})^N \f$<br>
/// where N is the order and \f$ t \in [t_{min}, t_{max}] \f$.
///
template
<
typename
Time
=
double
,
typename
Numeric
=
Time
,
std
::
size_t
Dim
=
3
,
bool
Safe
=
false
,
template
<
typename
Time
=
double
,
typename
Numeric
=
Time
,
bool
Safe
=
false
,
typename
Point
=
Eigen
::
Matrix
<
Numeric
,
Eigen
::
Dynamic
,
1
>,
typename
T_Point
=
std
::
vector
<
Point
,
Eigen
::
aligned_allocator
<
Point
>
>
>
struct
polynomial
:
public
curve_abc
<
Time
,
Numeric
,
Safe
,
Point
>
{
...
...
@@ -40,16 +40,16 @@ namespace curves
typedef
Time
time_t
;
typedef
Numeric
num_t
;
typedef
curve_abc
<
Time
,
Numeric
,
Safe
,
Point
>
curve_abc_t
;
typedef
Eigen
::
Matrix
<
double
,
Dim
,
Eigen
::
Dynamic
>
coeff_t
;
typedef
Eigen
::
Matrix
Xd
coeff_t
;
typedef
Eigen
::
Ref
<
coeff_t
>
coeff_t_ref
;
typedef
polynomial
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
polynomial_t
;
typedef
polynomial
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
polynomial_t
;
/* Constructors - destructors */
public:
/// \brief Empty constructor. Curve obtained this way can not perform other class functions.
///
polynomial
()
:
T_min_
(
0
),
T_max_
(
0
)
:
curve_abc_t
(),
dim_
(
0
),
T_min_
(
0
),
T_max_
(
0
)
{}
/// \brief Constructor.
...
...
@@ -60,8 +60,9 @@ namespace curves
/// \param max : UPPER bound on interval definition of the curve.
polynomial
(
const
coeff_t
&
coefficients
,
const
time_t
min
,
const
time_t
max
)
:
curve_abc_t
(),
dim_
(
coefficients
.
rows
()),
coefficients_
(
coefficients
),
dim_
(
Dim
),
degree_
(
coefficients
_
.
cols
()
-
1
),
degree_
(
coefficients
.
cols
()
-
1
),
T_min_
(
min
),
T_max_
(
max
)
{
safe_check
();
...
...
@@ -75,8 +76,9 @@ namespace curves
/// \param max : UPPER bound on interval definition of the spline.
polynomial
(
const
T_Point
&
coefficients
,
const
time_t
min
,
const
time_t
max
)
:
curve_abc_t
(),
dim_
(
coefficients
.
begin
()
->
size
()),
coefficients_
(
init_coeffs
(
coefficients
.
begin
(),
coefficients
.
end
())),
dim_
(
Dim
),
degree_
(
coefficients_
.
cols
()
-
1
),
degree_
(
coefficients_
.
cols
()
-
1
),
T_min_
(
min
),
T_max_
(
max
)
{
safe_check
();
...
...
@@ -90,8 +92,10 @@ namespace curves
/// \param max : UPPER bound on interval definition of the spline.
template
<
typename
In
>
polynomial
(
In
zeroOrderCoefficient
,
In
out
,
const
time_t
min
,
const
time_t
max
)
:
coefficients_
(
init_coeffs
(
zeroOrderCoefficient
,
out
)),
dim_
(
Dim
),
degree_
(
coefficients_
.
cols
()
-
1
),
:
curve_abc_t
(),
dim_
(
zeroOrderCoefficient
->
size
()),
coefficients_
(
init_coeffs
(
zeroOrderCoefficient
,
out
)),
degree_
(
coefficients_
.
cols
()
-
1
),
T_min_
(
min
),
T_max_
(
max
)
{
safe_check
();
...
...
@@ -105,8 +109,8 @@ namespace curves
polynomial
(
const
polynomial
&
other
)
:
coefficients_
(
other
.
coefficients_
),
dim_
(
other
.
dim_
),
degree_
(
other
.
degree_
),
T_min_
(
other
.
T_min_
),
T_max_
(
other
.
T_max_
)
:
dim_
(
other
.
dim_
),
coefficients_
(
other
.
coefficients_
),
degree_
(
other
.
degree_
),
T_min_
(
other
.
T_min_
),
T_max_
(
other
.
T_max_
)
{}
...
...
@@ -229,8 +233,8 @@ namespace curves
/*Helpers*/
/*Attributes*/
coeff_t
coefficients_
;
//const
std
::
size_t
dim_
;
//const
coeff_t
coefficients_
;
//const
std
::
size_t
degree_
;
//const
time_t
T_min_
,
T_max_
;
//const
/*Attributes*/
...
...
@@ -240,7 +244,7 @@ namespace curves
coeff_t
init_coeffs
(
In
zeroOrderCoefficient
,
In
highestOrderCoefficient
)
{
std
::
size_t
size
=
std
::
distance
(
zeroOrderCoefficient
,
highestOrderCoefficient
);
coeff_t
res
=
coeff_t
(
D
im
,
size
);
int
i
=
0
;
coeff_t
res
=
coeff_t
(
d
im
_
,
size
);
int
i
=
0
;
for
(
In
cit
=
zeroOrderCoefficient
;
cit
!=
highestOrderCoefficient
;
++
cit
,
++
i
)
{
res
.
col
(
i
)
=
*
cit
;
...
...
include/curves/quintic_spline.h
View file @
88ff7cce
...
...
@@ -37,12 +37,12 @@ namespace curves
return
res
;
}
template
<
typename
Time
,
typename
Numeric
,
std
::
size_t
Dim
,
bool
Safe
,
typename
Point
,
typename
T_Point
>
polynomial
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
create_quintic
(
Point
const
&
a
,
Point
const
&
b
,
Point
const
&
c
,
Point
const
&
d
,
Point
const
&
e
,
Point
const
&
f
,
template
<
typename
Time
,
typename
Numeric
,
bool
Safe
,
typename
Point
,
typename
T_Point
>
polynomial
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
create_quintic
(
Point
const
&
a
,
Point
const
&
b
,
Point
const
&
c
,
Point
const
&
d
,
Point
const
&
e
,
Point
const
&
f
,
const
Time
t_min
,
const
Time
t_max
)
{
T_Point
coeffs
=
make_quintic_vector
<
Point
,
T_Point
>
(
a
,
b
,
c
,
d
,
e
,
f
);
return
polynomial
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
(
coeffs
.
begin
(),
coeffs
.
end
(),
t_min
,
t_max
);
return
polynomial
<
Time
,
Numeric
,
Safe
,
Point
,
T_Point
>
(
coeffs
.
begin
(),
coeffs
.
end
(),
t_min
,
t_max
);
}
}
// namespace curves
#endif //_STRUCT_QUINTIC_SPLINE
...
...
python/curves_python.cpp
View file @
88ff7cce
...
...
@@ -45,16 +45,16 @@ typedef std::vector<Waypoint> T_Waypoint;
typedef
std
::
vector
<
Waypoint6
>
T_Waypoint6
;
// 3D
typedef
curves
::
polynomial
<
real
,
real
,
3
,
true
,
point3_t
,
t_point3_t
>
polynomial3_t
;
typedef
curves
::
exact_cubic
<
real
,
real
,
3
,
true
,
point3_t
,
t_point3_t
>
exact_cubic3_t
;
typedef
polynomial3_t
::
coeff_t
coeff_t
;
typedef
std
::
pair
<
real
,
point3_t
>
waypoint3_t
;
typedef
std
::
vector
<
waypoint3_t
,
Eigen
::
aligned_allocator
<
point3_t
>
>
t_waypoint3_t
;
// Dynamic dim
typedef
curves
::
cubic_hermite_spline
<
real
,
real
,
true
,
pointX_t
>
cubic_hermite_spline_t
;
typedef
curves
::
bezier_curve
<
real
,
real
,
true
,
pointX_t
>
bezier_t
;
typedef
curves
::
piecewise_curve
<
real
,
real
,
true
,
pointX_t
,
t_pointX_t
,
polynomial3_t
>
piecewise_polynomial_curve_t
;
typedef
curves
::
polynomial
<
real
,
real
,
true
,
pointX_t
,
t_pointX_t
>
polynomial_t
;
typedef
polynomial_t
::
coeff_t
coeff_t
;
typedef
curves
::
piecewise_curve
<
real
,
real
,
true
,
pointX_t
,
t_pointX_t
,
polynomial_t
>
piecewise_polynomial_curve_t
;
typedef
curves
::
piecewise_curve
<
real
,
real
,
true
,
pointX_t
,
t_pointX_t
,
bezier_t
>
piecewise_bezier_curve_t
;
typedef
curves
::
piecewise_curve
<
real
,
real
,
true
,
pointX_t
,
t_pointX_t
,
cubic_hermite_spline_t
>
piecewise_cubic_hermite_curve_t
;
...
...
@@ -65,12 +65,12 @@ EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(bernstein_t)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
cubic_hermite_spline_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
bezier_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
polynomial_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
curve_constraints_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
piecewise_polynomial_curve_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
piecewise_bezier_curve_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
piecewise_cubic_hermite_curve_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
polynomial3_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
exact_cubic3_t
)
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
(
curve_constraints3_t
)
...
...
@@ -145,38 +145,38 @@ namespace curves
/* End wrap Cubic hermite spline */
/* Wrap polynomial */
polynomial
3
_t
*
wrapPolynomial
3
Constructor1
(
const
coeff_t
&
array
,
const
real
min
,
const
real
max
)
polynomial_t
*
wrapPolynomialConstructor1
(
const
coeff_t
&
array
,
const
real
min
,
const
real
max
)
{
return
new
polynomial
3
_t
(
array
,
min
,
max
);
return
new
polynomial_t
(
array
,
min
,
max
);
}
polynomial
3
_t
*
wrapPolynomial
3
Constructor2
(
const
coeff_t
&
array
)
polynomial_t
*
wrapPolynomialConstructor2
(
const
coeff_t
&
array
)
{
return
new
polynomial
3
_t
(
array
,
0.
,
1.
);
return
new
polynomial_t
(
array
,
0.
,
1.
);
}
/* End wrap polynomial */
/* Wrap piecewise curve */
piecewise_polynomial_curve_t
*
wrapPiecewisePolynomial
3
CurveConstructor
(
const
polynomial
3
_t
&
pol
)
piecewise_polynomial_curve_t
*
wrapPiecewisePolynomialCurveConstructor
(
const
polynomial_t
&
pol
)
{
return
new
piecewise_polynomial_curve_t
(
pol
);
}
piecewise_polynomial_curve_t
*
wrapPiecewisePolynomial
3
CurveEmptyConstructor
()
piecewise_polynomial_curve_t
*
wrapPiecewisePolynomialCurveEmptyConstructor
()
{
return
new
piecewise_polynomial_curve_t
();
}
piecewise_bezier_curve_t
*
wrapPiecewiseBezier
3
CurveConstructor
(
const
bezier_t
&
bc
)
piecewise_bezier_curve_t
*
wrapPiecewiseBezierCurveConstructor
(
const
bezier_t
&
bc
)
{
return
new
piecewise_bezier_curve_t
(
bc
);
}
piecewise_bezier_curve_t
*
wrapPiecewiseBezier
3
CurveEmptyConstructor
()
piecewise_bezier_curve_t
*
wrapPiecewiseBezierCurveEmptyConstructor
()
{
return
new
piecewise_bezier_curve_t
();
}
piecewise_cubic_hermite_curve_t
*
wrapPiecewiseCubicHermite
3
CurveConstructor
(
const
cubic_hermite_spline_t
&
ch
)
piecewise_cubic_hermite_curve_t
*
wrapPiecewiseCubicHermiteCurveConstructor
(
const
cubic_hermite_spline_t
&
ch
)
{
return
new
piecewise_cubic_hermite_curve_t
(
ch
);
}
piecewise_cubic_hermite_curve_t
*
wrapPiecewiseCubicHermite
3
CurveEmptyConstructor
()
piecewise_cubic_hermite_curve_t
*
wrapPiecewiseCubicHermiteCurveEmptyConstructor
()
{
return
new
piecewise_cubic_hermite_curve_t
();
}
...
...
@@ -355,35 +355,35 @@ namespace curves
;
/** END variable points bezier curve**/
/** BEGIN polynomial curve function**/
class_
<
polynomial
3
_t
>
(
"polynomial
3
"
,
init
<>
())
.
def
(
"__init__"
,
make_constructor
(
&
wrapPolynomial
3
Constructor1
),
class_
<
polynomial_t
>
(
"polynomial"
,
init
<>
())
.
def
(
"__init__"
,
make_constructor
(
&
wrapPolynomialConstructor1
),
"Create polynomial spline from an Eigen matrix of coefficient defined for t \in [min,max]."
" The matrix should contain one coefficient per column, from the zero order coefficient,up to the highest order."
" Spline order is given by the number of the columns -1."
)
.
def
(
"__init__"
,
make_constructor
(
&
wrapPolynomial
3
Constructor2
),
.
def
(
"__init__"
,
make_constructor
(
&
wrapPolynomialConstructor2
),
"Create polynomial spline from an Eigen matrix of coefficient defined for t \in [0,1]."
" The matrix should contain one coefficient per column, from the zero order coefficient,up to the highest order."
" Spline order is given by the number of the columns -1."
)
.
def
(
"min"
,
&
polynomial
3
_t
::
min
,
"Get the LOWER bound on interval definition of the curve."
)
.
def
(
"max"
,
&
polynomial
3
_t
::
max
,
"Get the HIGHER bound on interval definition of the curve."
)
.
def
(
"dim"
,
&
polynomial
3
_t
::
dim
)
.
def
(
"__call__"
,
&
polynomial
3
_t
::
operator
(),
"Evaluate the spline at the given time."
)
.
def
(
"derivate"
,
&
polynomial
3
_t
::
derivate
,
"Evaluate the derivative of order N of curve at time t."
,
args
(
"self"
,
"t"
,
"N"
))
.
def
(
"compute_derivate"
,
&
polynomial
3
_t
::
compute_derivate
,
"Compute derivative of order N of curve at time t."
)
.
def
(
"saveAsText"
,
&
polynomial
3
_t
::
saveAsText
<
polynomial
3
_t
>
,
bp
::
args
(
"filename"
),
"Saves *this inside a text file."
)
.
def
(
"loadFromText"
,
&
polynomial
3
_t
::
loadFromText
<
polynomial
3
_t
>
,
bp
::
args
(
"filename"
),
"Loads *this from a text file."
)
.
def
(
"saveAsXML"
,
&
polynomial
3
_t
::
saveAsXML
<
polynomial
3
_t
>
,
bp
::
args
(
"filename"
,
"tag_name"
),
"Saves *this inside a XML file."
)
.
def
(
"loadFromXML"
,
&
polynomial
3
_t
::
loadFromXML
<
polynomial
3
_t
>
,
bp
::
args
(
"filename"
,
"tag_name"
),
"Loads *this from a XML file."
)
.
def
(
"saveAsBinary"
,
&
polynomial
3
_t
::
saveAsBinary
<
polynomial
3
_t
>
,
bp
::
args
(
"filename"
),
"Saves *this inside a binary file."
)
.
def
(
"loadFromBinary"
,
&
polynomial
3
_t
::
loadFromBinary
<
polynomial
3
_t
>
,
bp
::
args
(
"filename"
),
"Loads *this from a binary file."
)
//.def(SerializableVisitor<polynomial
3
_t>())
.
def
(
"min"
,
&
polynomial_t
::
min
,
"Get the LOWER bound on interval definition of the curve."
)
.
def
(
"max"
,
&
polynomial_t
::
max
,
"Get the HIGHER bound on interval definition of the curve."
)
.
def
(
"dim"
,
&
polynomial_t
::
dim
)
.
def
(
"__call__"
,
&
polynomial_t
::
operator
(),
"Evaluate the spline at the given time."
)
.
def
(
"derivate"
,
&
polynomial_t
::
derivate
,
"Evaluate the derivative of order N of curve at time t."
,
args
(
"self"
,
"t"
,
"N"
))
.
def
(
"compute_derivate"
,
&
polynomial_t
::
compute_derivate
,
"Compute derivative of order N of curve at time t."
)
.
def
(
"saveAsText"
,
&
polynomial_t
::
saveAsText
<
polynomial_t
>
,
bp
::
args
(
"filename"
),
"Saves *this inside a text file."
)
.
def
(
"loadFromText"
,
&
polynomial_t
::
loadFromText
<
polynomial_t
>
,
bp
::
args
(
"filename"
),
"Loads *this from a text file."
)
.
def
(
"saveAsXML"
,
&
polynomial_t
::
saveAsXML
<
polynomial_t
>
,
bp
::
args
(
"filename"
,
"tag_name"
),
"Saves *this inside a XML file."
)
.
def
(
"loadFromXML"
,
&
polynomial_t
::
loadFromXML
<
polynomial_t
>
,
bp
::
args
(
"filename"
,
"tag_name"
),
"Loads *this from a XML file."
)
.
def
(
"saveAsBinary"
,
&
polynomial_t
::
saveAsBinary
<
polynomial_t
>
,
bp
::
args
(
"filename"
),
"Saves *this inside a binary file."
)
.
def
(
"loadFromBinary"
,
&
polynomial_t
::
loadFromBinary
<
polynomial_t
>
,
bp
::
args
(
"filename"
),
"Loads *this from a binary file."
)
//.def(SerializableVisitor<polynomial_t>())
;
/** END polynomial function**/
/** BEGIN piecewise curve function **/
class_
<
piecewise_polynomial_curve_t
>
(
"piecewise_polynomial_curve"
,
init
<>
())
.
def
(
"__init__"
,
make_constructor
(
&
wrapPiecewisePolynomial
3
CurveConstructor
),
.
def
(
"__init__"
,
make_constructor
(
&
wrapPiecewisePolynomialCurveConstructor
),
"Create a peicewise-polynomial curve containing the given polynomial curve."
)
.
def
(
"min"
,
&
piecewise_polynomial_curve_t
::
min
,
"Set the LOWER bound on interval definition of the curve."
)
.
def
(
"max"
,
&
piecewise_polynomial_curve_t
::
max
,
"Set the HIGHER bound on interval definition of the curve."
)
...
...
@@ -404,7 +404,7 @@ namespace curves
;
class_
<
piecewise_bezier_curve_t
>
(
"piecewise_bezier_curve"
,
init
<>
())
.
def
(
"__init__"
,
make_constructor
(
&
wrapPiecewiseBezier
3
CurveConstructor
))
.
def
(
"__init__"
,
make_constructor
(
&
wrapPiecewiseBezierCurveConstructor
))
.
def
(
"min"
,
&
piecewise_bezier_curve_t
::
min
)
.
def
(
"max"
,
&
piecewise_bezier_curve_t
::
max
)
.
def
(
"dim"
,
&
piecewise_bezier_curve_t
::
dim
)
...
...
@@ -422,7 +422,7 @@ namespace curves
;
class_
<
piecewise_cubic_hermite_curve_t
>
(
"piecewise_cubic_hermite_curve"
,
init
<>
())
.
def
(
"__init__"
,
make_constructor
(
&
wrapPiecewiseCubicHermite
3
CurveConstructor
))
.
def
(
"__init__"
,
make_constructor
(
&
wrapPiecewiseCubicHermiteCurveConstructor
))
.
def
(
"min"
,
&
piecewise_cubic_hermite_curve_t
::
min
)
.
def
(
"max"
,
&
piecewise_cubic_hermite_curve_t
::
max
)
.
def
(
"dim"
,
&
piecewise_cubic_hermite_curve_t
::
dim
)
...
...
@@ -503,12 +503,12 @@ namespace curves
;
/** END bernstein polynomial**/
/** BEGIN curves conversion**/
def
(
"polynomial_from_bezier"
,
polynomial_from_curve
<
polynomial
3
_t
,
bezier_t
>
);
def
(
"polynomial_from_hermite"
,
polynomial_from_curve
<
polynomial
3
_t
,
cubic_hermite_spline_t
>
);
def
(
"polynomial_from_bezier"
,
polynomial_from_curve
<
polynomial_t
,
bezier_t
>
);
def
(
"polynomial_from_hermite"
,
polynomial_from_curve
<
polynomial_t
,
cubic_hermite_spline_t
>
);
def
(
"bezier_from_hermite"
,
bezier_from_curve
<
bezier_t
,
cubic_hermite_spline_t
>
);
def
(
"bezier_from_polynomial"
,
bezier_from_curve
<
bezier_t
,
polynomial
3
_t
>
);
def
(
"bezier_from_polynomial"
,
bezier_from_curve
<
bezier_t
,
polynomial_t
>
);
def
(
"hermite_from_bezier"
,
hermite_from_curve
<
cubic_hermite_spline_t
,
bezier_t
>
);
def
(
"hermite_from_polynomial"
,
hermite_from_curve
<
cubic_hermite_spline_t
,
polynomial
3
_t
>
);
def
(
"hermite_from_polynomial"
,
hermite_from_curve
<
cubic_hermite_spline_t
,
polynomial_t
>
);
/** END curves conversion**/
}
// End BOOST_PYTHON_MODULE
}
// namespace curves
python/test/test.py
View file @
88ff7cce
...
...
@@ -10,7 +10,7 @@ from curves import (bezier_from_hermite, bezier_from_polynomial, hermite_from_po
hermite_from_bezier
,
polynomial_from_hermite
,
polynomial_from_bezier
,
cubic_hermite_spline
,
curve_constraints3
,
curve_constraints
,
exact_cubic3
,
bezier
,
piecewise_bezier_curve
,
piecewise_cubic_hermite_curve
,
piecewise_polynomial_curve
,
polynomial
3
piecewise_polynomial_curve
,
polynomial
)
#import curves
...
...
@@ -107,8 +107,8 @@ class TestCurves(unittest.TestCase):
# - Functions : constructor, min, max, derivate, serialize, deserialize
waypoints_0
=
matrix
([[
0.
,
0.
,
0.
],
[
0.
,
0.
,
0.
]]).
transpose
()
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
a
=
polynomial
3
(
waypoints
)
# Defined on [0.,1.]
a
=
polynomial
3
(
waypoints
,
-
1.
,
3.
)
# Defined on [-1.,3.]
a
=
polynomial
(
waypoints
)
# Defined on [0.,1.]
a
=
polynomial
(
waypoints
,
-
1.
,
3.
)
# Defined on [-1.,3.]
a
.
min
()
a
.
max
()
a
(
0.4
)
...
...
@@ -118,7 +118,7 @@ class TestCurves(unittest.TestCase):
self
.
assertTrue
((
a
.
derivate
(
0.4
,
1
)
==
a_derivated
(
0.4
)).
all
())
# Test serialization
a
.
saveAsText
(
"serialization_curve.test"
)
b
=
polynomial
3
()
b
=
polynomial
()
b
.
loadFromText
(
"serialization_curve.test"
)
self
.
assertTrue
((
a
(
0.4
)
==
b
(
0.4
)).
all
())
os
.
remove
(
"serialization_curve.test"
)
...
...
@@ -164,9 +164,9 @@ class TestCurves(unittest.TestCase):
waypoints0
=
matrix
([[
0.
,
0.
,
0.
]]).
transpose
()
waypoints1
=
matrix
([[
1.
,
1.
,
1.
]]).
transpose
()
waypoints2
=
matrix
([[
1.
,
1.
,
1.
],
[
1.
,
1.
,
1.
]]).
transpose
()
pol0
=
polynomial
3
(
waypoints0
,
0.
,
0.1
)
a
=
polynomial
3
(
waypoints1
,
0.
,
1.
)
b
=
polynomial
3
(
waypoints2
,
1.
,
3.
)
pol0
=
polynomial
(
waypoints0
,
0.
,
0.1
)
a
=
polynomial
(
waypoints1
,
0.
,
1.
)
b
=
polynomial
(
waypoints2
,
1.
,
3.
)
pc
=
piecewise_polynomial_curve
(
a
)
pc
.
add_curve
(
b
)
pc
.
min
()
...
...
@@ -234,6 +234,7 @@ class TestCurves(unittest.TestCase):
return
def
test_exact_cubic
(
self
):
'''
# To test :
# - Functions : constructor, min, max, derivate, getNumberSplines, getSplineAt
waypoints = matrix([[1., 2., 3.], [4., 5., 6.]]).transpose()
...
...
@@ -252,6 +253,7 @@ class TestCurves(unittest.TestCase):
b.loadFromText("serialization_pc.test")
self.assertTrue((a(0.4) == b(0.4)).all())
os.remove("serialization_pc.test")
'''
return
def
test_exact_cubic_constraint
(
self
):
...
...
tests/Main.cpp
View file @
88ff7cce
...
...
@@ -21,7 +21,7 @@ namespace curves
typedef
Eigen
::
Vector3d
tangent_t
;
typedef
std
::
vector
<
point_t
,
Eigen
::
aligned_allocator
<
point_t
>
>
t_point_t
;
typedef
curve_abc
<
double
,
double
,
true
,
point_t
>
curve_abc_t
;
typedef
polynomial
<
double
,
double
,
3
,
true
,
point_t
,
t_point_t
>
polynomial_t
;
typedef
polynomial
<
double
,
double
,
true
,
point_t
,
t_point_t
>
polynomial_t
;
typedef
exact_cubic
<
double
,
double
,
3
,
true
,
point_t
>
exact_cubic_t
;
typedef
bezier_curve
<
double
,
double
,
true
,
point_t
>
bezier_curve_t
;
typedef
cubic_hermite_spline
<
double
,
double
,
true
,
point_t
>
cubic_hermite_spline_t
;
...
...
@@ -1242,7 +1242,7 @@ void piecewiseCurveTest(bool& error)
void
curveAbcDimDynamicTest
(
bool
&
error
)
{
typedef
curve_abc
<
double
,
double
,
true
>
curve_abc_test_t
;
typedef
polynomial
<
double
,
double
,
3
,
true
>
polynomial_test_t
;
typedef
polynomial
<
double
,
double
,
true
>
polynomial_test_t
;
typedef
exact_cubic
<
double
,
double
,
3
,
true
>
exact_cubic_test_t
;
typedef
exact_cubic_test_t
::
spline_constraints
spline_constraints_test_t
;
typedef
bezier_curve
<
double
,
double
,
true
>
bezier_curve_test_t
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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