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
57731bb3
Commit
57731bb3
authored
12 years ago
by
Randy Mackay
Browse files
Options
Downloads
Patches
Plain Diff
Copter: adopt compass test from arduplane
parent
c232d7af
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/test.pde
+72
-19
72 additions, 19 deletions
ArduCopter/test.pde
with
72 additions
and
19 deletions
ArduCopter/test.pde
+
72
−
19
View file @
57731bb3
...
...
@@ -798,31 +798,84 @@ test_baro(uint8_t argc, const Menu::arg *argv)
static
int8_t
test_mag
(
uint8_t
argc
,
const
Menu
::
arg
*
argv
)
{
if
(
g
.
compass_enabled
)
{
print_hit_enter
();
uint8_t
delta_ms_fast_loop
;
while
(
1
)
{
delay
(
100
);
if
(
compass
.
read
())
{
float
heading
=
compass
.
calculate_heading
(
ahrs
.
get_dcm_matrix
());
cliSerial
->
printf_P
(
PSTR
(
"Heading: %ld, XYZ: %d, %d, %d
\n
"
),
(
wrap_360_cd
(
ToDeg
(
heading
)
*
100
))
/
100
,
compass
.
mag_x
,
compass
.
mag_y
,
compass
.
mag_z
);
}
else
{
cliSerial
->
println_P
(
PSTR
(
"not healthy"
));
if
(
!
g
.
compass_enabled
)
{
cliSerial
->
printf_P
(
PSTR
(
"Compass: "
));
print_enabled
(
false
);
return
(
0
);
}
compass
.
set_orientation
(
MAG_ORIENTATION
);
if
(
!
compass
.
init
())
{
cliSerial
->
println_P
(
PSTR
(
"Compass initialisation failed!"
));
return
0
;
}
ahrs
.
init
();
ahrs
.
set_fly_forward
(
true
);
ahrs
.
set_compass
(
&
compass
);
report_compass
();
// we need the AHRS initialised for this test
ins
.
init
(
AP_InertialSensor
::
COLD_START
,
ins_sample_rate
,
flash_leds
);
ahrs
.
reset
();
int16_t
counter
=
0
;
float
heading
=
0
;
print_hit_enter
();
while
(
1
)
{
delay
(
20
);
if
(
millis
()
-
fast_loopTimer
>
19
)
{
delta_ms_fast_loop
=
millis
()
-
fast_loopTimer
;
G_Dt
=
(
float
)
delta_ms_fast_loop
/
1000.
f
;
// used by DCM integrator
fast_loopTimer
=
millis
();
// INS
// ---
ahrs
.
update
();
medium_loopCounter
++
;
if
(
medium_loopCounter
==
5
)
{
if
(
compass
.
read
())
{
// Calculate heading
Matrix3f
m
=
ahrs
.
get_dcm_matrix
();
heading
=
compass
.
calculate_heading
(
m
);
compass
.
null_offsets
();
}
medium_loopCounter
=
0
;
}
if
(
cliSerial
->
available
()
>
0
)
{
return
(
0
);
counter
++
;
if
(
counter
>
20
)
{
if
(
compass
.
healthy
)
{
Vector3f
maggy
=
compass
.
get_offsets
();
cliSerial
->
printf_P
(
PSTR
(
"Heading: %ld, XYZ: %d, %d, %d,
\t
XYZoff: %6.2f, %6.2f, %6.2f
\n
"
),
(
wrap_360_cd
(
ToDeg
(
heading
)
*
100
))
/
100
,
(
int
)
compass
.
mag_x
,
(
int
)
compass
.
mag_y
,
(
int
)
compass
.
mag_z
,
maggy
.
x
,
maggy
.
y
,
maggy
.
z
);
}
else
{
cliSerial
->
println_P
(
PSTR
(
"compass not healthy"
));
}
counter
=
0
;
}
}
}
else
{
cliSerial
->
printf_P
(
PSTR
(
"Compass: "
));
print_enabled
(
false
);
return
(
0
);
if
(
cliSerial
->
available
()
>
0
)
{
break
;
}
}
// save offsets. This allows you to get sane offset values using
// the CLI before you go flying.
cliSerial
->
println_P
(
PSTR
(
"saving offsets"
));
compass
.
save_offsets
();
return
(
0
);
}
...
...
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