Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Ardupilot
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
OpenSource
Ardupilot
Commits
3a529b2c
"firmware/application/apps/ais_app.cpp" did not exist on "1e0d452f57c3761983665d1af292e09bb0109f81"
Commit
3a529b2c
authored
10 years ago
by
Jonathan Challinger
Committed by
Randy Mackay
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Copter: utilize get_control_mid for throttle calculations
parent
9375fc89
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
ArduCopter/Attitude.pde
+20
-18
20 additions, 18 deletions
ArduCopter/Attitude.pde
with
20 additions
and
18 deletions
ArduCopter/Attitude.pde
+
20
−
18
View file @
3a529b2c
...
...
@@ -124,27 +124,23 @@ set_throttle_takeoff()
// get_pilot_desired_throttle - transform pilot's throttle input to make cruise throttle mid stick
// used only for manual throttle modes
// returns throttle output 0 to 1000
#define THROTTLE_IN_MIDDLE 500 // the throttle mid point
static
int16_t
get_pilot_desired_throttle
(
int16_t
throttle_control
)
{
int16_t
throttle_out
;
// exit immediately in the simple cases
if
(
throttle_control
==
0
||
g
.
throttle_mid
==
500
)
{
return
throttle_control
;
}
int16_t
mid_stick
=
g
.
rc_3
.
get_control_mid
();
// ensure reasonable throttle values
throttle_control
=
constrain_int16
(
throttle_control
,
0
,
1000
);
g
.
throttle_mid
=
constrain_int16
(
g
.
throttle_mid
,
300
,
700
);
// check throttle is above, below or in the deadband
if
(
throttle_control
<
THROTTLE_IN_MIDDLE
)
{
if
(
throttle_control
<
mid_stick
)
{
// below the deadband
throttle_out
=
g
.
throttle_min
+
((
float
)(
throttle_control
-
g
.
throttle_min
))
*
((
float
)(
g
.
throttle_mid
-
g
.
throttle_min
))
/
((
float
)(
500
-
g
.
throttle_min
));
}
else
if
(
throttle_control
>
THROTTLE_IN_MIDDLE
)
{
throttle_out
=
g
.
throttle_min
+
((
float
)(
throttle_control
-
g
.
throttle_min
))
*
((
float
)(
g
.
throttle_mid
-
g
.
throttle_min
))
/
((
float
)(
mid_stick
-
g
.
throttle_min
));
}
else
if
(
throttle_control
>
mid_stick
)
{
// above the deadband
throttle_out
=
g
.
throttle_mid
+
((
float
)(
throttle_control
-
500
))
*
(
float
)(
1000
-
g
.
throttle_mid
)
/
500.0
f
;
throttle_out
=
g
.
throttle_mid
+
((
float
)(
throttle_control
-
mid_stick
))
*
(
float
)(
1000
-
g
.
throttle_mid
)
/
mid_stick
;
}
else
{
// must be in the deadband
throttle_out
=
g
.
throttle_mid
;
...
...
@@ -156,8 +152,6 @@ static int16_t get_pilot_desired_throttle(int16_t throttle_control)
// get_pilot_desired_climb_rate - transform pilot's throttle input to
// climb rate in cm/s. we use radio_in instead of control_in to get the full range
// without any deadzone at the bottom
#define THROTTLE_IN_DEADBAND_TOP (THROTTLE_IN_MIDDLE+g.throttle_deadzone) // top of the deadband
#define THROTTLE_IN_DEADBAND_BOTTOM (THROTTLE_IN_MIDDLE-g.throttle_deadzone) // bottom of the deadband
static
int16_t
get_pilot_desired_climb_rate
(
int16_t
throttle_control
)
{
int16_t
desired_rate
=
0
;
...
...
@@ -167,19 +161,24 @@ static int16_t get_pilot_desired_climb_rate(int16_t throttle_control)
return
0
;
}
int16_t
mid_stick
=
g
.
rc_3
.
get_control_mid
();
int16_t
deadband_top
=
mid_stick
+
g
.
throttle_deadzone
;
int16_t
deadband_bottom
=
mid_stick
-
g
.
throttle_deadzone
;
// ensure a reasonable throttle value
throttle_control
=
constrain_int16
(
throttle_control
,
0
,
1000
);
throttle_control
=
constrain_int16
(
throttle_control
,
g
.
throttle_min
,
1000
);
// ensure a reasonable deadzone
g
.
throttle_deadzone
=
constrain_int16
(
g
.
throttle_deadzone
,
0
,
400
);
// check throttle is above, below or in the deadband
if
(
throttle_control
<
THROTTLE_IN_DEADBAND_BOTTOM
)
{
if
(
throttle_control
<
deadband_bottom
)
{
// below the deadband
desired_rate
=
(
int32_t
)
g
.
pilot_velocity_z_max
*
(
throttle_control
-
THROTTLE_IN_DEADBAND_BOTTOM
)
/
(
THROTTLE_IN_MIDDLE
-
g
.
throttle_
deadzone
);
}
else
if
(
throttle_control
>
THROTTLE_IN_DEADBAND_TOP
)
{
desired_rate
=
(
int32_t
)
g
.
pilot_velocity_z_max
*
(
throttle_control
-
deadband_bottom
)
/
(
deadband_bottom
-
g
.
throttle_
min
);
}
else
if
(
throttle_control
>
deadband_top
)
{
// above the deadband
desired_rate
=
(
int32_t
)
g
.
pilot_velocity_z_max
*
(
throttle_control
-
THROTTLE_IN_DEADBAND_TOP
)
/
(
THROTTLE_IN_MIDDLE
-
g
.
throttle_deadzone
);
desired_rate
=
(
int32_t
)
g
.
pilot_velocity_z_max
*
(
throttle_control
-
deadband_top
)
/
(
1000
-
deadband_top
);
}
else
{
// must be in the deadband
desired_rate
=
0
;
...
...
@@ -209,6 +208,9 @@ static int16_t get_throttle_pre_takeoff(int16_t throttle_control)
return
0
;
}
int16_t
mid_stick
=
g
.
rc_3
.
get_control_mid
();
int16_t
deadband_top
=
mid_stick
+
g
.
throttle_deadzone
;
// sanity check throttle input
throttle_control
=
constrain_int16
(
throttle_control
,
0
,
1000
);
...
...
@@ -221,8 +223,8 @@ static int16_t get_throttle_pre_takeoff(int16_t throttle_control)
}
// check throttle is below top of deadband
if
(
throttle_control
<
THROTTLE_IN_DEADBAND_TOP
)
{
throttle_out
=
g
.
throttle_min
+
((
float
)(
throttle_control
-
g
.
throttle_min
))
*
((
float
)(
get_non_takeoff_throttle
()
-
g
.
throttle_min
))
/
((
float
)(
THROTTLE_IN_DEADBAND_TOP
-
g
.
throttle_min
));
if
(
throttle_control
<
deadband_top
)
{
throttle_out
=
g
.
throttle_min
+
((
float
)(
throttle_control
-
g
.
throttle_min
))
*
((
float
)(
get_non_takeoff_throttle
()
-
g
.
throttle_min
))
/
((
float
)(
deadband_top
-
g
.
throttle_min
));
}
else
{
// must be in the deadband
throttle_out
=
get_non_takeoff_throttle
();
...
...
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