Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
54a5e177
Commit
54a5e177
authored
7 years ago
by
Dennis Mannhart
Committed by
Beat Küng
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ManualSmoothingZ: comments cleanup and style fix
parent
08dfd0c4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/FlightTasks/tasks/Utility/ManualSmoothingZ.cpp
+10
-11
10 additions, 11 deletions
src/lib/FlightTasks/tasks/Utility/ManualSmoothingZ.cpp
src/lib/FlightTasks/tasks/Utility/ManualSmoothingZ.hpp
+40
-11
40 additions, 11 deletions
src/lib/FlightTasks/tasks/Utility/ManualSmoothingZ.hpp
with
50 additions
and
22 deletions
src/lib/FlightTasks/tasks/Utility/ManualSmoothingZ.cpp
+
10
−
11
View file @
54a5e177
...
...
@@ -34,7 +34,7 @@
/**
* @file ManualSmoothingZ.hpp
*
* This Class is used for smoothing the velocity setpoints in
Z
-direction.
* This Class is used for smoothing the velocity set
-
points in
z
-direction
NED frame
.
*/
#include
"ManualSmoothingZ.hpp"
...
...
@@ -47,7 +47,7 @@ ManualSmoothingZ::ManualSmoothingZ(const float &vel, const float &stick) :
{
_acc_max_up_h
=
param_find
(
"MPC_ACC_UP_MAX"
);
_acc_max_down_h
=
param_find
(
"MPC_ACC_DOWN_MAX"
);
_jerk_max
=
param_find
(
"MPC_JERK_MAX"
);
_jerk_max
_h
=
param_find
(
"MPC_JERK_MAX"
);
/* Load the params the very first time */
setParams
();
...
...
@@ -98,23 +98,23 @@ ManualSmoothingZ::updateAcceleration(float vel_sp[2], const float dt)
const
bool
is_current_zero
=
(
fabsf
(
_stick
)
<=
FLT_EPSILON
);
/* default is acceleration */
Intention
intention
=
Intention
::
acceleration
;
Manual
Intention
Z
intention
=
Manual
Intention
Z
::
acceleration
;
/* check zero input stick */
if
(
is_current_zero
)
{
intention
=
Intention
::
brake
;
intention
=
Manual
Intention
Z
::
brake
;
}
/*
* update intention
*/
if
((
_intention
!=
Intention
::
brake
)
&&
(
intention
==
Intention
::
brake
))
{
if
((
_intention
!=
Manual
Intention
Z
::
brake
)
&&
(
intention
==
Manual
Intention
Z
::
brake
))
{
/* we start with lowest acceleration */
_acc_state_dependent
=
_acc_max_down
;
/* reset slewrate: this ensures that there
* is no delay present
because of the slew
ra
t
e
/* reset slew
-
rate: this ensures that there
* is no delay present
when user demands to b
ra
k
e
*/
vel_sp
[
1
]
=
_vel
;
...
...
@@ -122,7 +122,7 @@ ManualSmoothingZ::updateAcceleration(float vel_sp[2], const float dt)
}
switch
(
intention
)
{
case
Intention
::
brake
:
{
case
Manual
Intention
Z
::
brake
:
{
/* limit jerk when braking to zero */
float
jerk
=
(
_acc_max_up
-
_acc_state_dependent
)
/
dt
;
...
...
@@ -137,10 +137,9 @@ ManualSmoothingZ::updateAcceleration(float vel_sp[2], const float dt)
break
;
}
case
Intention
::
acceleration
:
{
case
Manual
Intention
Z
::
acceleration
:
{
_acc_state_dependent
=
(
getMaxAcceleration
(
vel_sp
)
-
_acc_max_down
)
_acc_state_dependent
=
(
getMaxAcceleration
()
-
_acc_max_down
)
*
fabsf
(
_stick
)
+
_acc_max_down
;
break
;
}
...
...
@@ -170,7 +169,7 @@ ManualSmoothingZ::getMaxAcceleration(float vel_sp[2])
/* at rest */
return
_acc_max_up
;
}
else
if
(
vel_sp
[
0
]
<
0.0
f
)
{
}
else
if
(
vel_sp
[
0
]
<
0.0
f
)
{
/* braking downward */
return
_acc_max_down
;
...
...
This diff is collapsed.
Click to expand it.
src/lib/FlightTasks/tasks/Utility/ManualSmoothingZ.hpp
+
40
−
11
View file @
54a5e177
...
...
@@ -41,39 +41,68 @@
#include
<systemlib/param/param.h>
/* User intention: brake or acceleration */
enum
class
ManualIntentionZ
{
brake
,
acceleration
,
};
class
ManualSmoothingZ
{
public:
ManualSmoothingZ
(
const
float
&
vel
,
const
float
&
stick
);
~
ManualSmoothingZ
();
~
ManualSmoothingZ
()
{}
;
/* Smooths velocity setpoint based
* on flight direction.
* @param vel_sp[2] array: vel_sp[0] = current velocity set-point;
* vel_sp[1] = previous velocity set-point
* vel_sp will contain smoothed current previous set-point.
* @param dt: time delta in seconds
*/
void
smoothVelFromSticks
(
float
vel_sp
[
2
],
const
float
dt
);
/* Getter methods */
float
getMaxAcceleration
(
float
vel_sp
[
2
]);
ManualIntentionZ
getIntention
()
{
return
_intention
;};
/* Overwrite methods:
* Needed if different parameter values than default required.
*/
void
overwriteAccelerationUp
(
float
acc_max_up
)
{
_acc_max_up
=
acc_max_up
;};
void
overwriteAccelerationDown
(
float
acc_max_down
)
{
_acc_max_down
=
acc_max_down
;};
void
overwriteJerkMax
(
float
jerk_max
)
{
_jerk_max
=
jerk_max
;};
private
:
enum
class
Intention
{
brake
,
acceleration
,
};
Intention
_intention
{
Intention
::
brake
};
/* User intention: brake or acceleration */
ManualIntentionZ
_intention
{
ManualIntentionZ
::
acceleration
};
/* Dependency injection: vehicle velocity in z-direction;
* stick input in z-direction
*/
const
float
&
_vel
;
const
float
&
_stick
;
/* Acceleration that depends on vehicle state
* _acc_max_down <= _acc_state_dependent <= _acc_max_up
*/
float
_acc_state_dependent
{
0.0
f
};
/* Params */
param_t
_acc_max_up_h
{
PARAM_INVALID
};
param_t
_acc_max_down_h
{
PARAM_INVALID
};
param_t
_jerk_max_h
{
PARAM_INVALID
};
float
_acc_max_up
{
0.0
f
};
float
_acc_max_down
{
0.0
f
};
float
_jerk_max
{
10000.0
f
};
float
_acc_state_dependent
{
0.0
f
};
int
_parameter_sub
{
-
1
};
/* Helper methods */
void
velocitySlewRate
(
float
vel_sp
[
2
],
const
float
dt
);
void
updateParams
();
void
updateAcceleration
(
float
&
vel_sp_prev
,
const
float
dt
);
void
setParams
();
float
getMaxAcceleration
();
void
updateParams
();
void
updateAcceleration
(
float
vel_sp
[
2
],
const
float
dt
);
};
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