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
ad21bdca
Commit
ad21bdca
authored
5 years ago
by
Pierre Fernbach
Committed by
Pierre Fernbach
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
piecewise : curves_ is now a vector of shared ptr of curve_abc
parent
ff398ecd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/curves/piecewise_curve.h
+19
-16
19 additions, 16 deletions
include/curves/piecewise_curve.h
with
19 additions
and
16 deletions
include/curves/piecewise_curve.h
+
19
−
16
View file @
ad21bdca
...
...
@@ -10,6 +10,7 @@
#include
"curve_abc.h"
#include
"curve_conversion.h"
#include
<boost/smart_ptr/shared_ptr.hpp>
namespace
curves
{
/// \class PiecewiseCurve.
...
...
@@ -34,6 +35,7 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
typedef
curve_abc
<
Time
,
Numeric
,
Safe
,
point_t
,
point_derivate_t
>
curve_t
;
// parent class
typedef
boost
::
shared_ptr
<
curve_t
>
curve_ptr_t
;
typedef
typename
std
::
vector
<
curve_t
>
t_curve_t
;
typedef
typename
std
::
vector
<
curve_ptr_t
>
t_curve_ptr_t
;
typedef
typename
std
::
vector
<
Time
>
t_time_t
;
typedef
piecewise_curve
<
Time
,
Numeric
,
Safe
,
Point
,
Point_derivate
>
piecewise_curve_t
;
public:
...
...
@@ -77,7 +79,7 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
// std::cout<<"[Min,Max]=["<<T_min_<<","<<T_max_<<"]"<<" t="<<t<<std::endl;
throw
std
::
out_of_range
(
"can't evaluate piecewise curve, out of range"
);
}
return
curves_
.
at
(
find_interval
(
t
))(
t
);
return
(
*
curves_
.
at
(
find_interval
(
t
))
)
(
t
);
}
/// \brief Evaluate the derivative of order N of curve at time t.
...
...
@@ -90,7 +92,7 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
if
(
Safe
&
!
(
T_min_
<=
t
&&
t
<=
T_max_
))
{
throw
std
::
invalid_argument
(
"can't evaluate piecewise curve, out of range"
);
}
return
(
curves_
.
at
(
find_interval
(
t
))).
derivate
(
t
,
order
);
return
(
*
curves_
.
at
(
find_interval
(
t
))).
derivate
(
t
,
order
);
}
/**
...
...
@@ -98,10 +100,11 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
* @param order order of derivative
* @return
*/
piecewise_curve
<
Time
,
Numeric
,
Safe
,
point_derivate_t
,
std
::
vector
<
point_derivate_t
,
Eigen
::
aligned_allocator
<
Point
>
>
,
Curve
>
compute_derivate
(
const
std
::
size_t
order
)
const
{
piecewise_curve
<
Time
,
Numeric
,
Safe
,
point_derivate_t
,
std
::
vector
<
point_derivate_t
,
Eigen
::
aligned_allocator
<
Point
>
>
,
Curve
>
res
;
for
(
typename
t_curve_t
::
const_iterator
itc
=
curves_
.
begin
();
itc
<
curves_
.
end
();
++
itc
)
{
res
.
add_curve
(
itc
->
compute_derivate
(
order
));
piecewise_curve_t
compute_derivate
(
const
std
::
size_t
order
)
const
{
piecewise_curve_t
res
;
for
(
typename
t_curve_ptr_t
::
const_iterator
itc
=
curves_
.
begin
();
itc
<
curves_
.
end
();
++
itc
)
{
res
.
add_curve
((
*
itc
)
->
compute_derivate
(
order
));
}
return
res
;
}
...
...
@@ -125,7 +128,7 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
throw
std
::
invalid_argument
(
"All the curves in a piecewiseCurve should have the same dimension"
);
}
curves_
.
push_back
(
cf
);
curves_
.
push_back
(
boost
::
make_shared
<
curve_t
>
(
cf
)
)
;
size_
=
curves_
.
size
();
T_max_
=
cf
.
max
();
if
(
size_
==
1
)
{
...
...
@@ -147,10 +150,10 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
if
(
order
==
0
){
point_t
value_end
,
value_start
;
while
(
isContinuous
&&
i
<
(
size_
-
1
))
{
curve_t
current
=
curves_
.
at
(
i
);
curve_t
next
=
curves_
.
at
(
i
+
1
);
value_end
=
current
(
current
.
max
());
value_start
=
next
(
next
.
min
());
curve_
ptr_
t
current
=
curves_
.
at
(
i
);
curve_
ptr_
t
next
=
curves_
.
at
(
i
+
1
);
value_end
=
(
*
current
)
(
current
->
max
());
value_start
=
(
*
next
)
(
next
->
min
());
if
(
!
value_end
.
isApprox
(
value_start
,
MARGIN
))
{
isContinuous
=
false
;
}
...
...
@@ -159,10 +162,10 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
}
else
{
point_derivate_t
value_end
,
value_start
;
while
(
isContinuous
&&
i
<
(
size_
-
1
))
{
curve_t
current
=
curves_
.
at
(
i
);
curve_t
next
=
curves_
.
at
(
i
+
1
);
value_end
=
current
.
derivate
(
current
.
max
(),
order
);
value_start
=
next
.
derivate
(
next
.
min
(),
order
);
curve_
ptr_
t
current
=
curves_
.
at
(
i
);
curve_
ptr_
t
next
=
curves_
.
at
(
i
+
1
);
value_end
=
current
->
derivate
(
current
->
max
(),
order
);
value_start
=
next
->
derivate
(
next
->
min
(),
order
);
if
(
!
value_end
.
isApprox
(
value_start
,
MARGIN
))
{
isContinuous
=
false
;
}
...
...
@@ -362,7 +365,7 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point,Point_deriv
/* Attributes */
std
::
size_t
dim_
;
// Dim of curve
t_curve_t
curves_
;
// for curves 0/1/2 : [ curve0, curve1, curve2 ]
t_curve_
ptr_
t
curves_
;
// for curves 0/1/2 : [ curve0, curve1, curve2 ]
t_time_t
time_curves_
;
// for curves 0/1/2 : [ Tmin0, Tmax0,Tmax1,Tmax2 ]
std
::
size_t
size_
;
// Number of segments in piecewise curve = size of curves_
Time
T_min_
,
T_max_
;
...
...
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