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
03aa2822
Commit
03aa2822
authored
13 years ago
by
Jason Short
Browse files
Options
Downloads
Patches
Plain Diff
re-implemented WII Dampening filter for Marco.
parent
9c7b8586
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
+41
-10
41 additions, 10 deletions
ArduCopter/Attitude.pde
with
41 additions
and
10 deletions
ArduCopter/Attitude.pde
+
41
−
10
View file @
03aa2822
...
@@ -107,17 +107,34 @@ get_acro_yaw(int32_t target_rate)
...
@@ -107,17 +107,34 @@ get_acro_yaw(int32_t target_rate)
static
int
static
int
get_rate_roll
(
int32_t
target_rate
)
get_rate_roll
(
int32_t
target_rate
)
{
{
int16_t
rate_d1
=
0
;
static
int16_t
rate_d2
=
0
;
static
int16_t
rate_d3
=
0
;
static
int32_t
last_rate
=
0
;
static
int32_t
last_rate
=
0
;
int32_t
current_rate
=
(
omega
.
x
*
DEGX100
);
int32_t
current_rate
=
(
omega
.
x
*
DEGX100
);
// History of last 3 dir
rate_d3
=
rate_d2
;
rate_d2
=
rate_d1
;
rate_d1
=
current_rate
-
last_rate
;
last_rate
=
current_rate
;
// rate control
// rate control
target_rate
=
target_rate
-
current_rate
;
target_rate
=
target_rate
-
current_rate
;
target_rate
=
g
.
pid_rate_roll
.
get_pid
(
target_rate
,
G_Dt
);
target_rate
=
g
.
pid_rate_roll
.
get_pid
(
target_rate
,
G_Dt
);
// Dampening
// Dampening
int16_t
d_temp
=
(
float
)(
current_rate
-
last_rate
)
*
g
.
stabilize_d
;
//int16_t d_temp = (float)(current_rate - last_rate) * g.stabilize_d;
target_rate
-=
constrain
(
d_temp
,
-
500
,
500
);
//target_rate -= constrain(d_temp, -500, 500);
last_rate
=
current_rate
;
//last_rate = current_rate;
// D term
// I had tried this before with little result. Recently, someone mentioned to me that
// MultiWii uses a filter of the last three to get around noise and get a stronger signal.
// Works well! Thanks!
int16_t
d_temp
=
(
rate_d1
+
rate_d2
+
rate_d3
)
*
g
.
stabilize_d
;
target_rate
-=
d_temp
;
// output control:
// output control:
return
constrain
(
target_rate
,
-
2500
,
2500
);
return
constrain
(
target_rate
,
-
2500
,
2500
);
...
@@ -126,17 +143,31 @@ get_rate_roll(int32_t target_rate)
...
@@ -126,17 +143,31 @@ get_rate_roll(int32_t target_rate)
static
int
static
int
get_rate_pitch
(
int32_t
target_rate
)
get_rate_pitch
(
int32_t
target_rate
)
{
{
int16_t
rate_d1
=
0
;
static
int16_t
rate_d2
=
0
;
static
int16_t
rate_d3
=
0
;
static
int32_t
last_rate
=
0
;
static
int32_t
last_rate
=
0
;
int32_t
current_rate
=
(
omega
.
y
*
DEGX100
);
int32_t
current_rate
=
(
omega
.
y
*
DEGX100
);
// History of last 3 dir
rate_d3
=
rate_d2
;
rate_d2
=
rate_d1
;
rate_d1
=
current_rate
-
last_rate
;
last_rate
=
current_rate
;
// rate control
// rate control
target_rate
=
target_rate
-
current_rate
;
target_rate
=
target_rate
-
current_rate
;
target_rate
=
g
.
pid_rate_pitch
.
get_pid
(
target_rate
,
G_Dt
);
target_rate
=
g
.
pid_rate_pitch
.
get_pid
(
target_rate
,
G_Dt
);
// Dampening
// Dampening
int16_t
d_temp
=
(
float
)(
current_rate
-
last_rate
)
*
g
.
stabilize_d
;
//int16_t d_temp = (float)(current_rate - last_rate) * g.stabilize_d;
target_rate
-=
constrain
(
d_temp
,
-
500
,
500
);
//target_rate -= constrain(d_temp, -500, 500);
last_rate
=
current_rate
;
//last_rate = current_rate;
// D term
int16_t
d_temp
=
(
rate_d1
+
rate_d2
+
rate_d3
)
*
g
.
stabilize_d
;
target_rate
-=
d_temp
;
// output control:
// output control:
return
constrain
(
target_rate
,
-
2500
,
2500
);
return
constrain
(
target_rate
,
-
2500
,
2500
);
...
...
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