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
4b68dd48
Commit
4b68dd48
authored
11 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
Copter: use ins.wait_for_sample() for main loop
this takes advantage of the INS specific method to wait for a sample
parent
8e5d1430
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
ArduCopter/ArduCopter.pde
+24
-27
24 additions, 27 deletions
ArduCopter/ArduCopter.pde
ArduCopter/defines.h
+2
-0
2 additions, 0 deletions
ArduCopter/defines.h
with
26 additions
and
27 deletions
ArduCopter/ArduCopter.pde
+
24
−
27
View file @
4b68dd48
...
@@ -953,40 +953,37 @@ static void perf_update(void)
...
@@ -953,40 +953,37 @@ static void perf_update(void)
void
loop
()
void
loop
()
{
{
// wait for an INS sample
if
(
!
ins
.
wait_for_sample
(
1000
))
{
Log_Write_Error
(
ERROR_SUBSYSTEM_MAIN
,
ERROR_CODE_INS_DELAY
);
return
;
}
uint32_t
timer
=
micros
();
uint32_t
timer
=
micros
();
// We want this to execute fast
// check loop time
// ----------------------------
perf_info_check_loop_time
(
timer
-
fast_loopTimer
);
if
(
ins
.
sample_available
())
{
// check loop time
perf_info_check_loop_time
(
timer
-
fast_loopTimer
);
G_Dt
=
(
float
)(
timer
-
fast_loopTimer
)
/
1000000.
f
;
// used by PI Loops
// used by PI Loops
fast_loopTimer
=
timer
;
G_Dt
=
(
float
)(
timer
-
fast_loopTimer
)
/
1000000.
f
;
fast_loopTimer
=
timer
;
// for mainloop failure monitoring
// for mainloop failure monitoring
mainLoop_count
++
;
mainLoop_count
++
;
// Execute the fast loop
// Execute the fast loop
// ---------------------
// ---------------------
fast_loop
();
fast_loop
();
// tell the scheduler one tick has passed
// tell the scheduler one tick has passed
scheduler
.
tick
();
scheduler
.
tick
();
// run all the tasks that are due to run. Note that we only
// run all the tasks that are due to run. Note that we only
// have to call this once per loop, as the tasks are scheduled
// have to call this once per loop, as the tasks are scheduled
// in multiples of the main loop tick. So if they don't run on
// in multiples of the main loop tick. So if they don't run on
// the first call to the scheduler they won't run on a later
// the first call to the scheduler they won't run on a later
// call until scheduler.tick() is called again
// call until scheduler.tick() is called again
uint32_t
time_available
=
(
timer
+
10000
)
-
micros
();
uint32_t
time_available
=
(
timer
+
10000
)
-
micros
();
scheduler
.
run
(
time_available
-
500
);
scheduler
.
run
(
time_available
-
500
);
}
if
((
timer
-
fast_loopTimer
)
<
8500
)
{
// we have plenty of time - be friendly to multi-tasking OSes
hal
.
scheduler
->
delay
(
1
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ArduCopter/defines.h
+
2
−
0
View file @
4b68dd48
...
@@ -449,6 +449,8 @@ enum ap_message {
...
@@ -449,6 +449,8 @@ enum ap_message {
#define ERROR_CODE_COMPASS_FAILED_TO_READ 2
#define ERROR_CODE_COMPASS_FAILED_TO_READ 2
// subsystem specific error codes -- gps
// subsystem specific error codes -- gps
#define ERROR_CODE_GPS_GLITCH 2
#define ERROR_CODE_GPS_GLITCH 2
// subsystem specific error codes -- main
#define ERROR_CODE_INS_DELAY 1
...
...
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