From 782ba00d4b460707c21b09d5eb3fbcfc46c3e2c3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 26 Dec 2015 15:08:38 +1100 Subject: [PATCH] Tracker: convert to Hz based task table --- AntennaTracker/AntennaTracker.cpp | 37 +++++++++++++------------------ AntennaTracker/Tracker.h | 2 -- AntennaTracker/system.cpp | 2 +- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/AntennaTracker/AntennaTracker.cpp b/AntennaTracker/AntennaTracker.cpp index 2a60457149..9d972d761b 100644 --- a/AntennaTracker/AntennaTracker.cpp +++ b/AntennaTracker/AntennaTracker.cpp @@ -21,12 +21,7 @@ #include "Tracker.h" -#define SCHED_TASK(func, _interval_ticks, _max_time_micros) {\ - .function = FUNCTOR_BIND(&tracker, &Tracker::func, void),\ - AP_SCHEDULER_NAME_INITIALIZER(func)\ - .interval_ticks = _interval_ticks,\ - .max_time_micros = _max_time_micros,\ -} +#define SCHED_TASK(func, _interval_ticks, _max_time_micros) SCHED_TASK_CLASS(Tracker, &tracker, func, _interval_ticks, _max_time_micros) /* scheduler table - all regular tasks apart from the fast_loop() @@ -35,21 +30,21 @@ microseconds) */ const AP_Scheduler::Task Tracker::scheduler_tasks[] = { - SCHED_TASK(update_ahrs, 1, 1000), - SCHED_TASK(read_radio, 1, 200), - SCHED_TASK(update_tracking, 1, 1000), - SCHED_TASK(update_GPS, 5, 4000), - SCHED_TASK(update_compass, 5, 1500), - SCHED_TASK(update_barometer, 5, 1500), - SCHED_TASK(gcs_update, 1, 1700), - SCHED_TASK(gcs_data_stream_send, 1, 3000), - SCHED_TASK(compass_accumulate, 1, 1500), - SCHED_TASK(barometer_accumulate, 1, 900), - SCHED_TASK(update_notify, 1, 100), - SCHED_TASK(check_usb_mux, 5, 300), - SCHED_TASK(gcs_retry_deferred, 1, 1000), - SCHED_TASK(one_second_loop, 50, 3900), - SCHED_TASK(compass_cal_update, 1, 100), + SCHED_TASK(update_ahrs, 50, 1000), + SCHED_TASK(read_radio, 50, 200), + SCHED_TASK(update_tracking, 50, 1000), + SCHED_TASK(update_GPS, 10, 4000), + SCHED_TASK(update_compass, 10, 1500), + SCHED_TASK(update_barometer, 10, 1500), + SCHED_TASK(gcs_update, 50, 1700), + SCHED_TASK(gcs_data_stream_send, 50, 3000), + SCHED_TASK(compass_accumulate, 50, 1500), + SCHED_TASK(barometer_accumulate, 50, 900), + SCHED_TASK(update_notify, 50, 100), + SCHED_TASK(check_usb_mux, 10, 300), + SCHED_TASK(gcs_retry_deferred, 50, 1000), + SCHED_TASK(one_second_loop, 1, 3900), + SCHED_TASK(compass_cal_update, 50, 100), }; /** diff --git a/AntennaTracker/Tracker.h b/AntennaTracker/Tracker.h index 40de71c345..b1344cdb5c 100644 --- a/AntennaTracker/Tracker.h +++ b/AntennaTracker/Tracker.h @@ -88,8 +88,6 @@ public: void loop() override; private: - const AP_InertialSensor::Sample_rate ins_sample_rate = AP_InertialSensor::RATE_50HZ; - Parameters g; // main loop scheduler diff --git a/AntennaTracker/system.cpp b/AntennaTracker/system.cpp index 20927fa287..e9d532f2b8 100644 --- a/AntennaTracker/system.cpp +++ b/AntennaTracker/system.cpp @@ -77,7 +77,7 @@ void Tracker::init_tracker() ahrs.init(); ahrs.set_fly_forward(false); - ins.init(ins_sample_rate); + ins.init(scheduler.get_loop_rate_hz()); ahrs.reset(); init_barometer();