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
8036efd7
Commit
8036efd7
authored
5 years ago
by
Matthias Grob
Committed by
Lorenz Meier
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
mc_pos_control: refactor takeoff trigger conditions to be positive
parent
5e238833
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/mc_pos_control/mc_pos_control_main.cpp
+6
-7
6 additions, 7 deletions
src/modules/mc_pos_control/mc_pos_control_main.cpp
with
6 additions
and
7 deletions
src/modules/mc_pos_control/mc_pos_control_main.cpp
+
6
−
7
View file @
8036efd7
...
...
@@ -104,7 +104,7 @@ public:
private:
// smooth takeoff vertical velocity ramp state
bool
_in_takeoff_ramp
=
false
;
/**< true while takeoff ramp is applied */
bool
_
velocity
_triggered_takeoff
=
false
;
/**< true if takeoff was triggered by a
velocity
setpoint */
bool
_
position
_triggered_takeoff
=
false
;
/**< true if takeoff was triggered by a
position
setpoint */
float
_takeoff_ramp_velocity
=
-
1.
f
;
/**< current value of the smooth takeoff ramp */
float
_takeoff_reference_z
;
/**< z-position when takeoff ramp was initiated */
...
...
@@ -992,14 +992,13 @@ MulticopterPositionControl::update_takeoff_ramp(const float z_sp, const float vz
}
// upwards velocity setpoint larger than a minimal speed
_
velocity_triggered_takeoff
=
PX4_ISFINITE
(
vz_sp
)
&&
vz_sp
<
-
0.3
f
;
const
bool
velocity_triggered_takeoff
=
PX4_ISFINITE
(
vz_sp
)
&&
vz_sp
<
-
0.3
f
;
// upwards jerk setpoint
const
bool
jerk_triggered_takeoff
=
PX4_ISFINITE
(
jz_sp
)
&&
jz_sp
<
-
FLT_EPSILON
;
// position setpoint above the minimum altitude
const
bool
position_triggered_takeoff
=
PX4_ISFINITE
(
z_sp
)
&&
(
z_sp
<
(
_states
.
position
(
2
)
-
min_altitude
));
_
position_triggered_takeoff
=
PX4_ISFINITE
(
z_sp
)
&&
(
z_sp
<
(
_states
.
position
(
2
)
-
min_altitude
));
_velocity_triggered_takeoff
|=
jerk_triggered_takeoff
;
if
(
_velocity_triggered_takeoff
||
position_triggered_takeoff
)
{
if
(
velocity_triggered_takeoff
||
jerk_triggered_takeoff
||
_position_triggered_takeoff
)
{
// takeoff was triggered, start velocity ramp
_takeoff_ramp_velocity
=
takeoff_ramp_initialization
;
_in_takeoff_ramp
=
true
;
...
...
@@ -1012,7 +1011,7 @@ MulticopterPositionControl::update_takeoff_ramp(const float z_sp, const float vz
float
takeoff_desired_velocity
=
-
vz_sp
;
// if takeoff was triggered by a position setpoint, ramp to the takeoff speed parameter
if
(
!
_velocity
_triggered_takeoff
)
{
if
(
_position
_triggered_takeoff
)
{
takeoff_desired_velocity
=
_param_mpc_tko_speed
.
get
();
}
...
...
@@ -1029,7 +1028,7 @@ MulticopterPositionControl::update_takeoff_ramp(const float z_sp, const float vz
_takeoff_ramp_velocity
=
math
::
min
(
_takeoff_ramp_velocity
,
takeoff_desired_velocity
);
// smooth takeoff is achieved once desired altitude/velocity setpoint is reached
if
(
!
_velocity
_triggered_takeoff
)
{
if
(
_position
_triggered_takeoff
)
{
_in_takeoff_ramp
=
_states
.
position
(
2
)
-
0.2
f
>
math
::
max
(
z_sp
,
_takeoff_reference_z
-
_param_mpc_land_alt2
.
get
());
}
else
{
...
...
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