Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
ndcurves
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
loco-3d
ndcurves
Commits
795d6e9a
Commit
795d6e9a
authored
5 years ago
by
JasonChmn
Committed by
Pierre Fernbach
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[exact_cubic] Add serialization for exact cubic / binding python => Test OK
parent
66d3a01a
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/curves/exact_cubic.h
+18
-1
18 additions, 1 deletion
include/curves/exact_cubic.h
python/curves_python.cpp
+2
-1
2 additions, 1 deletion
python/curves_python.cpp
python/test/test.py
+5
-0
5 additions, 0 deletions
python/test/test.py
tests/Main.cpp
+18
-0
18 additions, 0 deletions
tests/Main.cpp
with
43 additions
and
2 deletions
include/curves/exact_cubic.h
+
18
−
1
View file @
795d6e9a
...
...
@@ -32,6 +32,9 @@
#include
<functional>
#include
<vector>
#include
"serialization/archive.hpp"
#include
"serialization/eigen-matrix.hpp"
namespace
curves
{
/// \class ExactCubic.
...
...
@@ -41,7 +44,8 @@ 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
>
>
struct
exact_cubic
:
public
piecewise_curve
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
,
SplineBase
>
struct
exact_cubic
:
public
piecewise_curve
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
,
SplineBase
>
//,
//public serialization::Serializable< exact_cubic<Time, Numeric, Dim, Safe, Point, T_Point, SplineBase> >
{
typedef
Point
point_t
;
typedef
T_Point
t_point_t
;
...
...
@@ -55,10 +59,14 @@ struct exact_cubic : public piecewise_curve<Time, Numeric, Dim, Safe, Point, T_P
typedef
typename
t_spline_t
::
const_iterator
cit_spline_t
;
typedef
curve_constraints
<
Point
,
Dim
>
spline_constraints
;
typedef
exact_cubic
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
,
SplineBase
>
exact_cubic_t
;
typedef
piecewise_curve
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
,
SplineBase
>
piecewise_curve_t
;
/* Constructors - destructors */
public:
exact_cubic
(){}
/// \brief Constructor.
/// \param wayPointsBegin : an iterator pointing to the first element of a waypoint container.
/// \param wayPointsEns : an iterator pointing to the last element of a waypoint container.
...
...
@@ -253,6 +261,15 @@ struct exact_cubic : public piecewise_curve<Time, Numeric, Dim, Safe, Point, T_P
subSplines
.
push_back
(
create_quintic
<
Time
,
Numeric
,
Dim
,
Safe
,
Point
,
T_Point
>
(
a0
,
b0
,
c0
,
d
,
e
,
f
,
init_t
,
end_t
));
}
public
:
// Serialization of the class
friend
class
boost
::
serialization
::
access
;
template
<
class
Archive
>
void
serialize
(
Archive
&
ar
,
const
unsigned
int
version
){
ar
&
BOOST_SERIALIZATION_BASE_OBJECT_NVP
(
exact_cubic_t
);
}
};
}
// namespace curves
#endif //_CLASS_EXACTCUBIC
...
...
This diff is collapsed.
Click to expand it.
python/curves_python.cpp
+
2
−
1
View file @
795d6e9a
...
...
@@ -408,7 +408,7 @@ BOOST_PYTHON_MODULE(curves)
/** BEGIN exact_cubic curve**/
class_
<
exact_cubic_t
>
(
"exact_cubic"
,
no_
init
)
(
"exact_cubic"
,
init
<>
()
)
.
def
(
"__init__"
,
make_constructor
(
&
wrapExactCubicConstructor
))
.
def
(
"__init__"
,
make_constructor
(
&
wrapExactCubicConstructorConstraint
))
.
def
(
"min"
,
&
exact_cubic_t
::
min
)
...
...
@@ -417,6 +417,7 @@ BOOST_PYTHON_MODULE(curves)
.
def
(
"derivate"
,
&
exact_cubic_t
::
derivate
)
.
def
(
"getNumberSplines"
,
&
exact_cubic_t
::
getNumberSplines
)
.
def
(
"getSplineAt"
,
&
exact_cubic_t
::
getSplineAt
)
.
def
(
SerializableVisitor
<
exact_cubic_t
>
())
;
/** END exact_cubic curve**/
...
...
This diff is collapsed.
Click to expand it.
python/test/test.py
+
5
−
0
View file @
795d6e9a
...
...
@@ -238,6 +238,11 @@ class TestCurves(unittest.TestCase):
a
.
derivate
(
0.4
,
2
)
a
.
getNumberSplines
()
a
.
getSplineAt
(
0
)
# Test serialization
a
.
saveAsText
(
"
serialization_pc.test
"
)
b
=
exact_cubic
()
b
.
loadFromText
(
"
serialization_pc.test
"
)
self
.
assertTrue
((
a
(
0.4
)
==
b
(
0.4
)).
all
())
return
def
test_exact_cubic_constraint
(
self
):
...
...
This diff is collapsed.
Click to expand it.
tests/Main.cpp
+
18
−
0
View file @
795d6e9a
...
...
@@ -1443,6 +1443,7 @@ void serializationCurvesTest(bool& error)
std
::
string
errMsg2
(
"in serializationCurveTest, Error While serializing Bezier : "
);
std
::
string
errMsg3
(
"in serializationCurveTest, Error While serializing Cubic Hermite : "
);
std
::
string
errMsg4
(
"in serializationCurveTest, Error While serializing Piecewise curves : "
);
std
::
string
errMsg5
(
"in serializationCurveTest, Error While serializing Exact cubic : "
);
point_t
a
(
1
,
1
,
1
);
// in [0,1[
point_t
b
(
2
,
1
,
1
);
// in [1,2[
point_t
c
(
3
,
1
,
1
);
// in [2,3]
...
...
@@ -1494,6 +1495,23 @@ void serializationCurvesTest(bool& error)
piecewise_cubic_hermite_curve_t
pchc_test
;
pchc_test
.
loadFromText
(
fileName
);
CompareCurves
<
piecewise_polynomial_curve_t
,
piecewise_cubic_hermite_curve_t
>
(
ppc
,
pchc_test
,
errMsg4
,
error
);
// Test serialization on exact cubic
curves
::
T_Waypoint
waypoints
;
for
(
double
i
=
0
;
i
<=
1
;
i
=
i
+
0.2
)
{
waypoints
.
push_back
(
std
::
make_pair
(
i
,
point_t
(
i
,
i
,
i
)));
}
spline_constraints_t
constraints
;
constraints
.
end_vel
=
point_t
(
0
,
0
,
0
);
constraints
.
init_vel
=
point_t
(
0
,
0
,
0
);
constraints
.
end_acc
=
point_t
(
0
,
0
,
0
);
constraints
.
init_acc
=
point_t
(
0
,
0
,
0
);
exact_cubic_t
ec
(
waypoints
.
begin
(),
waypoints
.
end
(),
constraints
);
ec
.
saveAsText
(
fileName
);
exact_cubic_t
ec_test
;
ec_test
.
loadFromText
(
fileName
);
CompareCurves
<
exact_cubic_t
,
exact_cubic_t
>
(
ec
,
ec_test
,
errMsg5
,
error
);
}
int
main
(
int
/*argc*/
,
char
**
/*argv[]*/
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment