Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Baitboat
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
Baitboat
Commits
eb1fb63e
Commit
eb1fb63e
authored
11 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
APM_Control: added logging of parameter changes in AUTOTUNE
this will make it easier to analyse logs
parent
92714b09
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
libraries/APM_Control/AP_AutoTune.cpp
+42
-7
42 additions, 7 deletions
libraries/APM_Control/AP_AutoTune.cpp
libraries/APM_Control/AP_AutoTune.h
+3
-1
3 additions, 1 deletion
libraries/APM_Control/AP_AutoTune.h
with
45 additions
and
8 deletions
libraries/APM_Control/AP_AutoTune.cpp
+
42
−
7
View file @
eb1fb63e
...
@@ -260,31 +260,66 @@ void AP_AutoTune::check_save(void)
...
@@ -260,31 +260,66 @@ void AP_AutoTune::check_save(void)
last_save_ms
=
hal
.
scheduler
->
millis
();
last_save_ms
=
hal
.
scheduler
->
millis
();
}
}
/*
log a parameter change from autotune
*/
void
AP_AutoTune
::
log_param_change
(
float
v
,
const
prog_char_t
*
suffix
)
{
if
(
!
dataflash
.
logging_started
())
{
return
;
}
char
key
[
AP_MAX_NAME_SIZE
+
1
];
if
(
type
==
AUTOTUNE_ROLL
)
{
strncpy_P
(
key
,
PSTR
(
"RLL2SRV_"
),
8
);
strncpy_P
(
&
key
[
8
],
suffix
,
AP_MAX_NAME_SIZE
-
8
);
}
else
{
strncpy_P
(
key
,
PSTR
(
"PTCH2SRV_"
),
9
);
strncpy_P
(
&
key
[
9
],
suffix
,
AP_MAX_NAME_SIZE
-
9
);
}
key
[
AP_MAX_NAME_SIZE
]
=
0
;
dataflash
.
Log_Write_Parameter
(
key
,
v
);
}
/*
/*
set a float and save a float if it has changed by more than
set a float and save a float if it has changed by more than
0.1%. This reduces the number of insignificant EEPROM writes
0.1%. This reduces the number of insignificant EEPROM writes
*/
*/
void
AP_AutoTune
::
save_float_if_changed
(
AP_Float
&
v
,
float
value
)
void
AP_AutoTune
::
save_float_if_changed
(
AP_Float
&
v
,
float
value
,
const
prog_char_t
*
suffix
)
{
{
float
old_value
=
v
.
get
();
float
old_value
=
v
.
get
();
v
.
set
(
value
);
v
.
set
(
value
);
if
(
value
<=
0
||
fabsf
((
value
-
old_value
)
/
value
)
>
0.001
f
)
{
if
(
value
<=
0
||
fabsf
((
value
-
old_value
)
/
value
)
>
0.001
f
)
{
v
.
save
();
v
.
save
();
log_param_change
(
v
.
get
(),
suffix
);
}
}
}
}
/*
set a int16 and save if changed
*/
void
AP_AutoTune
::
save_int16_if_changed
(
AP_Int16
&
v
,
int16_t
value
,
const
prog_char_t
*
suffix
)
{
int16_t
old_value
=
v
.
get
();
v
.
set
(
value
);
if
(
old_value
!=
v
.
get
())
{
v
.
save
();
log_param_change
(
v
.
get
(),
suffix
);
}
}
/*
/*
save a set of gains
save a set of gains
*/
*/
void
AP_AutoTune
::
save_gains
(
const
ATGains
&
v
)
void
AP_AutoTune
::
save_gains
(
const
ATGains
&
v
)
{
{
current
=
last_save
;
current
=
last_save
;
save_float_if_changed
(
current
.
tau
,
v
.
tau
);
save_float_if_changed
(
current
.
tau
,
v
.
tau
,
PSTR
(
"TCONST"
)
);
save_float_if_changed
(
current
.
P
,
v
.
P
);
save_float_if_changed
(
current
.
P
,
v
.
P
,
PSTR
(
"P"
)
);
save_float_if_changed
(
current
.
I
,
v
.
I
);
save_float_if_changed
(
current
.
I
,
v
.
I
,
PSTR
(
"I"
)
);
save_float_if_changed
(
current
.
D
,
v
.
D
);
save_float_if_changed
(
current
.
D
,
v
.
D
,
PSTR
(
"D"
)
);
current
.
rmax
.
set_and_save_ifchanged
(
v
.
rmax
);
save_int16_if_changed
(
current
.
rmax
,
v
.
rmax
,
PSTR
(
"RMAX"
)
);
current
.
imax
.
set_and_save_ifchanged
(
v
.
imax
);
save_int16_if_changed
(
current
.
imax
,
v
.
imax
,
PSTR
(
"IMAX"
)
);
last_save
=
current
;
last_save
=
current
;
}
}
...
...
This diff is collapsed.
Click to expand it.
libraries/APM_Control/AP_AutoTune.h
+
3
−
1
View file @
eb1fb63e
...
@@ -95,7 +95,9 @@ private:
...
@@ -95,7 +95,9 @@ private:
void
write_log_headers
(
void
);
void
write_log_headers
(
void
);
void
write_log
(
float
servo
,
float
demanded
,
float
achieved
);
void
write_log
(
float
servo
,
float
demanded
,
float
achieved
);
void
save_float_if_changed
(
AP_Float
&
v
,
float
value
);
void
log_param_change
(
float
v
,
const
prog_char_t
*
suffix
);
void
save_float_if_changed
(
AP_Float
&
v
,
float
value
,
const
prog_char_t
*
suffix
);
void
save_int16_if_changed
(
AP_Int16
&
v
,
int16_t
value
,
const
prog_char_t
*
suffix
);
};
};
#endif // __AP_AUTOTUNE_H__
#endif // __AP_AUTOTUNE_H__
...
...
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