Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autonomous_driving_tools
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
mobile_robotics
autonomous_driving
autonomous_driving_tools
Commits
0241b30e
Commit
0241b30e
authored
2 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Updated the trapezoid velocity profile generation.
parent
627526aa
No related branches found
Branches containing commit
Tags
v75
Tags containing commit
1 merge request
!2
Solved a bug when creating a new geometry object: the sale factor is...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/vel_trapezoid.cpp
+28
-20
28 additions, 20 deletions
src/vel_trapezoid.cpp
with
28 additions
and
20 deletions
src/vel_trapezoid.cpp
+
28
−
20
View file @
0241b30e
...
@@ -20,54 +20,62 @@ void CVelTrapezoid::generate(double start_vel,double end_vel,double max_vel, dou
...
@@ -20,54 +20,62 @@ void CVelTrapezoid::generate(double start_vel,double end_vel,double max_vel, dou
this
->
set_end_vel
(
end_vel
);
this
->
set_end_vel
(
end_vel
);
this
->
set_max_vel
(
max_vel
);
this
->
set_max_vel
(
max_vel
);
this
->
set_max_acc
(
max_acc
);
this
->
set_max_acc
(
max_acc
);
this
->
acc_time
=
(
max_vel
-
start_vel
)
/
max_acc
;
if
(
start_vel
==
max_vel
)
this
->
dec_time
=-
(
end_vel
-
max_vel
)
/
max_acc
;
this
->
acc_time
=
0.0
;
this
->
acc_length
=
start_vel
*
this
->
acc_time
+
(
max_vel
-
start_vel
)
*
this
->
acc_time
/
2.0
;
else
this
->
dec_length
=
end_vel
*
this
->
dec_time
-
(
end_vel
-
max_vel
)
*
this
->
dec_time
/
2.0
;
this
->
acc_time
=
fabs
(
max_vel
-
start_vel
)
/
max_acc
;
if
(
end_vel
==
max_vel
)
this
->
dec_time
=
0.0
;
else
this
->
dec_time
=
fabs
(
end_vel
-
max_vel
)
/
max_acc
;
this
->
acc_length
=
std
::
min
(
start_vel
,
max_vel
)
*
this
->
acc_time
+
fabs
(
max_vel
-
start_vel
)
*
this
->
acc_time
/
2.0
;
this
->
dec_length
=
std
::
min
(
end_vel
,
max_vel
)
*
this
->
dec_time
+
fabs
(
end_vel
-
max_vel
)
*
this
->
dec_time
/
2.0
;
this
->
length
=
length
;
this
->
length
=
length
;
this
->
generated
=
true
;
this
->
generated
=
true
;
}
}
bool
CVelTrapezoid
::
generate
(
double
start_vel
,
double
end_vel
,
double
max_vel
,
double
max_acc
,
double
length
,
double
&
new_start_vel
,
double
&
new_max_vel
)
bool
CVelTrapezoid
::
generate
(
double
start_vel
,
double
end_vel
,
double
max_vel
,
double
max_acc
,
double
length
,
double
&
new_start_vel
,
double
&
new_max_vel
)
{
{
/*
if(start_vel>max_vel)
if(start_vel>max_vel)
throw CException(_HERE_,"Start velocity must be smaller than the maximum velocity");
throw CException(_HERE_,"Start velocity must be smaller than the maximum velocity");
if(end_vel>max_vel)
if(end_vel>max_vel)
throw CException(_HERE_,"End velocity must be smaller than the maximum velocity");
throw CException(_HERE_,"End velocity must be smaller than the maximum velocity");
if(max_acc<=0.0)
if(max_acc<=0.0)
throw CException(_HERE_,"Acceleration must be positive");
throw CException(_HERE_,"Acceleration must be positive");
*/
if
(
start_vel
>
max_vel
)
start_vel
=
max_vel
;
if
(
end_vel
>
max_vel
)
end_vel
=
max_vel
;
if
(
max_acc
<=
0.0
)
max_acc
=
0.0
;
this
->
generate
(
start_vel
,
end_vel
,
max_vel
,
max_acc
,
length
);
this
->
generate
(
start_vel
,
end_vel
,
max_vel
,
max_acc
,
length
);
if
(
length
-
this
->
acc_length
-
this
->
dec_length
>
0.0
)
if
(
(
length
-
this
->
acc_length
-
this
->
dec_length
)
>
0.0
)
{
{
this
->
time
=
(
length
-
this
->
acc_length
-
this
->
dec_length
)
/
this
->
max_vel
+
this
->
acc_time
+
this
->
dec_time
;
this
->
time
=
(
length
-
this
->
acc_length
-
this
->
dec_length
)
/
this
->
max_vel
+
this
->
acc_time
+
this
->
dec_time
;
new_start_vel
=
this
->
start_vel
;
new_start_vel
=
this
->
start_vel
;
new_max_vel
=
this
->
max_vel
;
new_max_vel
=
this
->
max_vel
;
return
true
;
return
true
;
}
}
else
else
{
{
double
value
=-
pow
(
this
->
start_vel
-
this
->
end_vel
,
2.0
)
*
pow
(
this
->
max_acc
-
1.0
,
2.0
)
-
2.0
*
this
->
length
*
pow
(
this
->
max_acc
,
2.0
)
*
(
this
->
max_acc
-
1
.0
);
new_max_vel
=
sqrt
(
length
*
this
->
max_acc
+
(
pow
(
start_vel
,
2.0
)
+
pow
(
end_vel
,
2.0
))
/
2
.0
);
if
(
value
>=
0.0
)
if
(
new_max_vel
>=
start_vel
)
{
{
new_max_vel
=
((
this
->
max_acc
-
1.0
)
*
(
this
->
start_vel
+
this
->
end_vel
)
-
sqrt
(
value
))
/
(
2.0
*
(
this
->
max_acc
-
1.0
));
this
->
generate
(
this
->
start_vel
,
this
->
end_vel
,
new_max_vel
,
this
->
max_acc
,
this
->
length
);
this
->
generate
(
this
->
start_vel
,
this
->
end_vel
,
new_max_vel
,
this
->
max_acc
,
this
->
length
);
this
->
time
=
(
length
-
this
->
acc_length
-
this
->
dec_length
)
/
new_max_vel
+
this
->
acc_time
+
this
->
dec_time
;
this
->
time
=
(
length
-
this
->
acc_length
-
this
->
dec_length
)
/
new_max_vel
+
this
->
acc_time
+
this
->
dec_time
;
new_start_vel
=
this
->
start_vel
;
new_start_vel
=
this
->
start_vel
;
return
true
;
}
}
else
else
{
{
value
=-
this
->
length
*
(
this
->
max_acc
-
1.0
);
new_max_vel
=
sqrt
(
pow
(
end_vel
,
2.0
)
+
2
*
length
*
this
->
max_acc
);
if
(
value
>
0.0
)
this
->
generate
(
this
->
start_vel
,
this
->
end_vel
,
new_max_vel
,
this
->
max_acc
,
this
->
length
);
{
this
->
time
=
(
length
-
this
->
acc_length
-
this
->
dec_length
)
/
new_max_vel
+
this
->
acc_time
+
this
->
dec_time
;
new_max_vel
=
((
this
->
max_acc
-
1.0
)
*
this
->
end_vel
-
this
->
max_acc
*
sqrt
(
value
))
/
(
this
->
max_acc
-
1.0
);
new_start_vel
=
this
->
start_vel
;
new_start_vel
=
new_max_vel
;
return
true
;
this
->
generate
(
new_start_vel
,
this
->
end_vel
,
new_max_vel
,
this
->
max_acc
,
length
);
this
->
time
=
(
this
->
length
-
this
->
dec_length
)
/
new_max_vel
+
this
->
dec_time
;
}
else
throw
CException
(
_HERE_
,
"Impossible to create trapezoid"
);
}
}
return
false
;
}
}
}
}
...
...
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