Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hpp-spline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Humanoid Path Planner
hpp-spline
Commits
85687ecf
Commit
85687ecf
authored
6 years ago
by
Steve T
Browse files
Options
Downloads
Patches
Plain Diff
[BUG FIX] evalXXX methods do not consider time
parent
bf71c76b
No related branches found
No related tags found
1 merge request
!9
[BUG FIX] evalXXX methods do not consider time
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/hpp/spline/bezier_curve.h
+8
-6
8 additions, 6 deletions
include/hpp/spline/bezier_curve.h
tests/Main.cpp
+6
-3
6 additions, 3 deletions
tests/Main.cpp
with
14 additions
and
9 deletions
include/hpp/spline/bezier_curve.h
+
8
−
6
View file @
85687ecf
...
...
@@ -141,7 +141,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
virtual
point_t
operator
()(
const
time_t
t
)
const
{
num_t
nT
=
t
/
T_
;
if
(
Safe
&!
(
0
<=
nT
&&
nT
<=
1
))
if
(
Safe
&!
(
0
<=
t
&&
t
<=
T_
))
{
throw
std
::
out_of_range
(
"can't evaluate bezier curve, out of range"
);
// TODO
}
...
...
@@ -166,7 +166,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
+
3
*
pts_
[
2
]
*
nT
*
nT
*
dt
+
pts_
[
3
]
*
nT
*
nT
*
nT
);
default
:
return
mult_T_
*
evalHorner
(
nT
);
return
evalHorner
(
t
);
break
;
}
}
...
...
@@ -227,20 +227,22 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
///
point_t
evalBernstein
(
const
Numeric
u
)
const
{
const
Numeric
t
=
u
/
T_
;
point_t
res
=
point_t
::
Zero
(
Dim
);
typename
t_point_t
::
const_iterator
pts_it
=
pts_
.
begin
();
for
(
typename
std
::
vector
<
Bern
<
Numeric
>
>::
const_iterator
cit
=
bernstein_
.
begin
();
cit
!=
bernstein_
.
end
();
++
cit
,
++
pts_it
)
res
+=
cit
->
operator
()(
u
)
*
(
*
pts_it
);
return
res
;
res
+=
cit
->
operator
()(
t
)
*
(
*
pts_it
);
return
res
*
mult_T_
;
}
///
/// \brief Evaluates all Bernstein polynomes for a certain degree using horner's scheme
///
point_t
evalHorner
(
const
Numeric
t
)
const
point_t
evalHorner
(
const
Numeric
v
)
const
{
const
Numeric
t
=
v
/
T_
;
typename
t_point_t
::
const_iterator
pts_it
=
pts_
.
begin
();
Numeric
u
,
bc
,
tn
;
u
=
1.0
-
t
;
...
...
@@ -253,7 +255,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
bc
=
bc
*
((
num_t
)(
degree_
-
i
+
1
))
/
i
;
tmp
=
(
tmp
+
tn
*
bc
*
(
*
pts_it
))
*
u
;
}
return
(
tmp
+
tn
*
t
*
(
*
pts_it
));
return
(
tmp
+
tn
*
t
*
(
*
pts_it
))
*
mult_T_
;
}
const
t_point_t
&
waypoints
()
const
{
return
pts_
;}
...
...
This diff is collapsed.
Click to expand it.
tests/Main.cpp
+
6
−
3
View file @
85687ecf
...
...
@@ -181,11 +181,14 @@ void BezierCurveTest(bool& error)
ComparePoints
(
d
,
res1
,
errMsg
+
"3(1) "
,
error
);
//testing bernstein polynomes
bezier_curve_t
cf5
(
params
.
begin
(),
params
.
end
(),
2.
);
std
::
string
errMsg2
(
"In test BezierCurveTest ; Bernstein polynoms do not evaluate as analytical evaluation"
);
for
(
double
d
=
0.
;
d
<
1
.
;
d
+=
0.1
)
for
(
double
d
=
0.
;
d
<
2
.
;
d
+=
0.1
)
{
ComparePoints
(
cf3
.
evalBernstein
(
d
)
,
cf3
(
d
),
errMsg2
,
error
);
ComparePoints
(
cf3
.
evalHorner
(
d
)
,
cf3
(
d
),
errMsg2
,
error
);
ComparePoints
(
cf5
.
evalBernstein
(
d
)
,
cf5
(
d
),
errMsg2
,
error
);
ComparePoints
(
cf5
.
evalHorner
(
d
)
,
cf5
(
d
),
errMsg2
,
error
);
ComparePoints
(
cf5
.
compute_derivate
(
1
).
evalBernstein
(
d
)
,
cf5
.
compute_derivate
(
1
)
(
d
),
errMsg2
,
error
);
ComparePoints
(
cf5
.
compute_derivate
(
1
).
evalHorner
(
d
)
,
cf5
.
compute_derivate
(
1
)
(
d
),
errMsg2
,
error
);
}
bool
error_in
(
true
);
...
...
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