From 66f0912b9dc19f76c0382a78b8dc1a1e4ac6c9a0 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 9 Jul 2017 12:19:30 -0400 Subject: [PATCH] FW attitude don't poll parameter_update --- .../fw_att_control/fw_att_control_main.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index f96a18d479..de970b85e6 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -750,13 +750,11 @@ FixedwingAttitudeControl::task_main() battery_status_poll(); /* wakeup source */ - px4_pollfd_struct_t fds[2]; + px4_pollfd_struct_t fds[1]; /* Setup of loop */ - fds[0].fd = _params_sub; + fds[0].fd = _ctrl_state_sub; fds[0].events = POLLIN; - fds[1].fd = _ctrl_state_sub; - fds[1].events = POLLIN; _task_running = true; @@ -773,16 +771,19 @@ FixedwingAttitudeControl::task_main() /* this is undesirable but not much we can do - might want to flag unhappy status */ if (pret < 0) { - warn("poll error %d, %d", pret, errno); + PX4_WARN("poll error %d, %d", pret, errno); continue; } perf_begin(_loop_perf); /* only update parameters if they changed */ - if (fds[0].revents & POLLIN) { + bool params_updated = false; + orb_check(_params_sub, ¶ms_updated); + + if (params_updated) { /* read from param to clear updated flag */ - struct parameter_update_s update; + parameter_update_s update; orb_copy(ORB_ID(parameter_update), _params_sub, &update); /* update parameters from storage */ @@ -790,7 +791,7 @@ FixedwingAttitudeControl::task_main() } /* only run controller if attitude changed */ - if (fds[1].revents & POLLIN) { + if (fds[0].revents & POLLIN) { static uint64_t last_run = 0; float deltaT = (hrt_absolute_time() - last_run) / 1000000.0f; last_run = hrt_absolute_time();